Skip to content

daylenjeez/ccm-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ccm

Claude Code Model Switcher

Switch Claude Code custom model configurations from the terminal in seconds.

npm version license node

中文文档 | English

Install · Quick Start · Commands · How It Works


✨ Highlights

  • 🔌 cc-switch Integration — Reads cc-switch database directly, zero migration
  • 🧙 Interactive Wizardccm add guides you step by step, type < to go back
  • One-command Switchccm use OpenRouter or ccm ls with arrow keys
  • 🛡️ Safe Switching — Preserves language, permissions and other personal settings
  • 🪶 Lightweight — No extra features, just model switching. Tiny footprint, fast startup, no background processes
  • 🚀 Zero Config — Just ccm init and follow the prompts, no docs needed
  • 🌍 i18n — English / 中文 (ccm locale set en/zh)

📦 Install

npm install -g @daylenjeez/ccm-switch

🚀 Quick Start

ccm init   # Auto-detects cc-switch or initializes standalone mode
ccm add    # Interactive wizard to add a provider

🔌 cc-switch Integration

Already using cc-switch? When the cc-switch database is detected, ccm works directly with it instead of using standalone storage:

$ ccm init
✓ Initialized
✓ cc-switch detected — ccm will use cc-switch's configuration store directly

You can also run ccm sync at any time to pull the latest cc-switch configurations into standalone mode.

➕ Adding Configurations

Interactive wizard (recommended)

$ ccm add
Provider name (e.g. OpenRouter): OpenRouter

Choose how to add:
  1) Step by step     # guided prompts, type < to go back
  2) Write JSON       # opens $EDITOR

ANTHROPIC_BASE_URL: https://openrouter.ai/api/v1
ANTHROPIC_AUTH_TOKEN: sk-or-xxx
ANTHROPIC_MODEL: anthropic/claude-opus-4.6
ANTHROPIC_DEFAULT_OPUS_MODEL (optional):
ANTHROPIC_DEFAULT_SONNET_MODEL (optional):
ANTHROPIC_DEFAULT_HAIKU_MODEL (optional):

✓ Saved configuration "OpenRouter"
Switch to this configuration now? (Y/n)

Edit JSON directly

Standalone mode: ~/.ccm/config.json
{
  "profiles": {
    "OpenRouter": {
      "env": {
        "ANTHROPIC_BASE_URL": "https://openrouter.ai/api/v1",
        "ANTHROPIC_AUTH_TOKEN": "sk-or-...",
        "ANTHROPIC_MODEL": "anthropic/claude-opus-4.6"
      }
    }
  }
}

Aliases are stored in ~/.ccm/rc.json:

{
  "aliases": {
    "or": "OpenRouter"
  }
}

📖 Commands

Core

Command Alias Description
ccm init Initialize, auto-detect cc-switch
ccm list ls Interactive list & switch
ccm use <name> Switch by name
ccm add new Interactive add wizard
ccm save <name> Save current settings as profile
ccm show [name] View config details (all configs in JSON if no name)
ccm modify [name] edit Edit existing configuration
ccm remove [name] rm Interactive or named delete
ccm current Show active configuration
ccm sync Sync cc-switch configs into standalone
ccm import [file] Import configs from JSON (stdin if no file)
ccm clear Clean up data files

Aliases

Command Description
ccm alias set <short> <name> Create alias, e.g. ccm alias set or OpenRouter
ccm alias rm <short> Remove alias
ccm alias list / ls List all aliases
ccm alias set or OpenRouter
ccm use or  # same as: ccm use OpenRouter

Locale

Command Description
ccm locale / ls List & switch language
ccm locale set <lang> Set language (zh / en)

Examples

# Switch provider
$ ccm use OpenRouter
✓ Switched to OpenRouter
  Model: anthropic/claude-opus-4.6
  Restart Claude Code to apply

# View current config
$ ccm current
Current configuration: OpenRouter
  ANTHROPIC_BASE_URL: https://openrouter.ai/api/v1
  ANTHROPIC_MODEL: anthropic/claude-opus-4.6
  ANTHROPIC_AUTH_TOKEN: sk-or-v1...a3f2

# Save current settings.json as a new profile
$ ccm save my-backup
✓ Saved current configuration as "my-backup"

⚙️ How It Works

Claude Code reads ~/.claude/settings.json on startup. The env field controls the API provider and model:

Variable Description
ANTHROPIC_BASE_URL API endpoint URL
ANTHROPIC_AUTH_TOKEN Authentication token
ANTHROPIC_MODEL Default model (optional)
ANTHROPIC_DEFAULT_OPUS_MODEL Model used when selecting Opus via /model
ANTHROPIC_DEFAULT_SONNET_MODEL Model used when selecting Sonnet via /model
ANTHROPIC_DEFAULT_HAIKU_MODEL Model used when selecting Haiku via /model

ccm use writes the selected profile into settings.json while preserving personal settings (language, permissions, etc.). Restart Claude Code to apply.

🗑️ Uninstall

Removing ccm only removes the CLI itself. Your data files are left behind.

Use ccm clear to delete them automatically, or clean them up manually:

  • ~/.ccm/rc.json — aliases and locale
  • ~/.ccm/config.json — profiles
  • ~/.claude/settings.json — may still contain an active env profile written by ccm

Then remove the CLI:

npm uninstall -g @daylenjeez/ccm-switch

📄 License

MIT

Packages

 
 
 

Contributors