A lightweight utility to manage Claude Code Router (CCR) models and synchronize them with your Claude Code settings seamlessly.
Languages: English | 中文
- 📋 View Router Config: Display current router configuration in a formatted table with route keys, providers, and models.
- 👀 View Models: List all available providers and models configured in your CCR
config.json. - ➕ Add Models: Select a provider from a menu and add new models.
- 🔄 Update Router:
- Global Update: Change the model for ALL routes at once.
- Granular Update: Change the model for a specific route (e.g.,
default,think,webSearch) via an interactive menu.
- ⚡ Auto-Sync: Automatically restarts the
ccrservice and updates~/.claude/settings.jsonwith the selected model. - 🚀 Global Command: Installs as a
ccrswitchcommand usable from anywhere. - 💾 Preset Management: Save and restore complete router configuration snapshots.
Ensure you have the following installed:
- macOS (10.12+) or Linux (with Bash shell)
- Python 3 (3.8+)
- uv (Fast Python package installer and runner)
- ccr (Claude Code Router)
Install with a single command:
curl -fsSL https://raw.githubusercontent.com/hjnnjh/claude-code-router-switch/master/install.sh | bashTo install a specific version:
CCR_SWITCH_VERSION=v1.1.0 curl -fsSL https://raw.githubusercontent.com/hjnnjh/claude-code-router-switch/master/install.sh | bash- Clone or download this repository.
- Make the installation script executable and run it:
chmod +x install.sh
./install.sh- Check for dependencies (
python3,uv,ccr). - Install the tool to
~/.local/share/ccr-switch. - Create a global
ccrswitchcommand in~/.local/bin.
Note: Ensure ~/.local/bin is in your $PATH.
Run the tool from anywhere in your terminal:
ccrswitch----------------------------------------
CCR Model Manager
----------------------------------------
1. View Current Router Config
2. View Models
3. Add Model to Provider
4. Update Router (All Routes)
5. Update Router (Single Route)
6. Apply Changes & Exit (Update Configs & Restart)
----------------------------------------
Presets Management:
7. View Presets
8. Save Current Config as Preset
9. Load Preset
0. View Preset Details
----------------------------------------
d. Delete Preset
q. Quit (Without Applying)
----------------------------------------
- Select an option.
- Follow the interactive prompts to choose providers and models.
- Use the Preset features to save and restore configurations.
- Select Apply Changes & Exit to save your configuration, restart CCR, and update Claude Code.
To remove the tool completely:
./uninstall.shThis will remove:
- The
ccrswitchcommand from~/.local/bin - The installation directory
~/.local/share/ccr-switch
sync_ccr.sh: Main interactive menu script (Bash).ccr_helper.py: Helper script for JSON manipulation and CLI operations (Python).install.sh: Installation script.uninstall.sh: Uninstallation script..spec-workflow/: Specification and workflow templates for project documentation.
Displays all active routes in a formatted table:
ccrswitch
# Then select option 1: View Current Router ConfigOutput Example:
Current Router Configuration:
-----------------------------------------------------------------------
Route Key | Provider | Model
-----------------------------------------------------------------------
default | Copilot Coding Plan | claude-sonnet-4.5
background | Copilot Coding Plan | claude-haiku-4.5
think | Copilot Coding Plan | claude-sonnet-4.5
webSearch | Poe | claude-haiku-4.5
-----------------------------------------------------------------------
Total: 4 route(s)
Save and restore entire router configurations:
- Save Preset: Capture current configuration with an optional description.
- Load Preset: Restore a previously saved configuration.
- View Presets: List all saved presets with timestamps.
- View Preset Details: Show detailed information of a specific preset.
- Delete Preset: Remove a saved preset.
This allows you to quickly switch between different router configurations without manual adjustment.
Cause: The Router section in ~/.claude-code-router/config.json is empty or missing.
Solution:
- Ensure CCR is properly installed and configured.
- Check that
~/.claude-code-router/config.jsoncontains valid routes.
Cause: Routes in the configuration don't follow the provider,model format.
Solution:
- Edit
~/.claude-code-router/config.jsonto verify route format. - Ensure routes are formatted as
"route_key": "provider_name,model_name".
For scripted bulk modifications, you can invoke the helper directly:
# List all models
uv run python ccr_helper.py list
# List all providers
uv run python ccr_helper.py list_providers
# View router configuration
uv run python ccr_helper.py show_router
# Get all route keys
uv run python ccr_helper.py get_router_keys
# Add model to provider
uv run python ccr_helper.py add_model "provider_name" "model_name"
# Update single route
uv run python ccr_helper.py update_router "route_key" "provider_name" "model_name"
# Update all routes
uv run python ccr_helper.py update_router_all "provider_name" "model_name"
# Update Claude Code settings
uv run python ccr_helper.py update_settings "model_name"~/.claude-code-router/config.json: Main configuration file containing Providers, Models, and Router sections.~/.claude/settings.json: Claude Code settings file containing the currently selected model.~/.claude-code-router/presets/: Directory for saved preset configuration files.
Feel free to submit issues, fork the repository, and create pull requests for any improvements.
This project is licensed under the MIT License - see the LICENSE file for details.
