A CLI tool to manage multiple Claude Code model configurations with easy switching.
中文文档: README-zh.md | Chinese Documentation: README-zh.md
- ✅ Multiple model configuration management
- ✅ Quick model switching
- ✅ Configuration change history
- ✅ Cross-platform support (Windows, Mac, Linux)
- ✅ Local data storage
- ✅ Track last selected model
- ✅ Interactive mode available
- ✅ Direct claude launcher (run
cmto launch claude with current model) - ✅ Automatic
--dangerously-skip-permissionsflag for seamless file access
- Node.js (v18 or higher) - Download here
- npm (comes with Node.js)
- claude CLI tool (optional, for direct launching) - Installation guide
npm install -g @wilson_janet/claude-code-model-switch
# Verify installation
cm --version-
Add your first model configuration:
cm add -n my-config -t YOUR_TOKEN -b https://api.anthropic.com -d "My config" -
Run claude with your model:
cm
You can optionally specify default models for each Claude model tier:
cm add -n production \
-t sk-ant-xxx \
-b https://api.anthropic.com \
-d "Production environment" \
--opus-model claude-opus-4-5-20251101 \
--sonnet-model claude-sonnet-4-5-20250929 \
--haiku-model claude-haiku-4-5-20251001These optional model configurations will be passed to Claude Code as environment variables:
ANTHROPIC_DEFAULT_OPUS_MODELANTHROPIC_DEFAULT_SONNET_MODELANTHROPIC_DEFAULT_HAIKU_MODEL
If not specified, Claude Code will use its official default values.
To enable shell autocompletion (e.g., for cm use <TAB>), run:
cm completionThis will launch an interactive setup wizard to configure your shell (Bash, Zsh, or Fish).
Alternatively, you can manually configure it by adding the following to your shell configuration file (e.g., .zshrc or .bashrc):
###-begin-cm-completion-###
if type complete &>/dev/null; then
_cm_completion () {
local words cword
if type _get_comp_words_by_ref &>/dev/null; then
_get_comp_words_by_ref -n = -n @ -n : -w words -i cword
else
cword="$COMP_CWORD"
words=("${COMP_WORDS[@]}")
fi
local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
cm completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
if type __ltrim_colon_completions &>/dev/null; then
__ltrim_colon_completions "$cur"
fi
}
complete -o default -F _cm_completion cm
fi
###-end-cm-completion-###Or just follow the instructions from cm completion.
| Command | Description | Example |
|---|---|---|
cm |
Launch claude with current model | cm |
cm add |
Add new model config | cm add -n dev -t sk-ant-xxx -b https://api.anthropic.com |
cm update [name] |
Update model config (interactive if no name) | cm update dev -n "dev-new" -d "Updated" |
cm use [name] |
Switch model and launch Claude (interactive if no name) | cm use or cm use dev |
cm current |
Show current model | cm current |
cm history |
Show change history | cm history -l 20 |
cm interactive |
Menu-driven mode | cm interactive |
# Add different environments
cm add -n dev -t sk-dev-xxx -b https://api.anthropic.com -d "Development"
cm add -n staging -t sk-staging-xxx -b https://api.anthropic.com -d "Staging"
cm add -n production -t sk-prod-xxx -b https://api.anthropic.com -d "Production"
# Switch between them
cm use dev
cm use production
# Update a model
cm update dev -n staging -d "Moved to staging"For a user-friendly menu interface:
cm interactiveInteractive mode now supports configuring default models per tier when adding a new model. Select "Add a new model" and you can optionally set default models for Opus, Sonnet, and Haiku.
In addition to adding, interactive mode also supports updating model configurations (Update a model), allowing you to modify model names, descriptions, tokens, base URLs, and default configurations for each model tier.
- API tokens are stored in plain text in your local config file
- Configurations are stored locally at:
- macOS/Linux:
~/.config/claude-model-manager/ - Windows:
%APPDATA%\claude-model-manager\
- macOS/Linux:
- Keep your config directory secure
For developers who want to contribute or understand the technical details, see DEVELOPMENT.md.
MIT