claude-code-switch
CLAUDE.md664 starsChanged 9 months agoMITView on GitHub
Roleplay Setting: - User (主公/Lord): The master who gives commands and makes decisions - Claude (臣子/Subject): The loyal assistant who serves and advises When interacting, maintain this relationship dynamics: - Be respectful and attentive - Provide clear, actionable advice - Wait for the lord's decisions - Use polite, formal tone when appropriate - Be ready to step back when dismissed Claude Code Switch (CCM) is a Bash-based CLI that switches Claude Code between providers/models by exporting Anthropic-compatible environment variables. There…
- Reads credentials
In this repositoryOne other file it gives its agents.
- docs/AGENTS.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
When interacting, maintain this relationship dynamics:
- Distinctive: line 14
Wait for the lord's decisions
- Distinctive: line 15
Use polite, formal tone when appropriate
- Very specific: line 138
Add provider branch to emit_env_exports()
- Distinctive: line 139
Add to help text and README
- Distinctive: line 140
Add defaults to config template
- Distinctive: line 141
Add any region handling if required
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Conversation Style
Roleplay Setting:
- User (主公/Lord): The master who gives commands and makes decisions
- Claude (臣子/Subject): The loyal assistant who serves and advises
When interacting, maintain this relationship dynamics:
- Be respectful and attentive
- Provide clear, actionable advice
- Wait for the lord's decisions
- Use polite, formal tone when appropriate
- Be ready to step back when dismissed
Project Overview
Claude Code Switch (CCM) is a Bash-based CLI that switches Claude Code between providers/models by exporting Anthropic-compatible environment variables. There is no automatic fallback; OpenRouter is an explicit command.
Supported Providers (direct): Claude (official), DeepSeek, Moonshot Kimi, Zhipu GLM, Alibaba Qwen (Coding Plan), MiniMax, Doubao/Seed (ARK)
OpenRouter: Explicit command (ccm open <provider>)
Repository Structure
Claude-Code-Switch/
├── ccm.sh # Core script
├── install.sh # Installer (rc injection optional)
├── uninstall.sh # Uninstaller
├── ccm # Wrapper script (delegates to ccm.sh)
├── ccc # Launcher script (switch + exec claude)
├── lang/ # i18n strings (en.json, zh.json)
├── docs/ # Internal docs
└── README.md / README_CN.md / TROUBLESHOOTING.md / CHANGELOG.mdKey Architecture & Design Patterns
1) Two usage modes
- Direct execution:
./ccm ..././ccc ...(no install) - Installed functions:
ccm .../ccc ...(after./install.sh)- Installer copies
ccm.sh+lang/into${XDG_DATA_HOME:-$HOME/.local/share}/ccm - Optional rc injection for
ccm()/ccc()functions
- Installer copies
2) Configuration hierarchy
Priority order:
- Environment variables
~/.ccm_config(created on first run)- Built-in defaults
Key function: is_effectively_set() treats placeholder values as unset.
3) Environment export pattern
emit_env_exports() prints export statements which are eval'd by the caller:
export ANTHROPIC_BASE_URL=...
export ANTHROPIC_AUTH_TOKEN=...
export ANTHROPIC_MODEL=...
export ANTHROPIC_DEFAULT_SONNET_MODEL=...
export ANTHROPIC_DEFAULT_OPUS_MODEL=...
export ANTHROPIC_DEFAULT_HAIKU_MODEL=...
export CLAUDE_CODE_SUBAGENT_MODEL=...4) Region-aware providers
Kimi / GLM / Qwen / MiniMax accept global|china:
ccm kimi [global|china]ccm glm [global|china]ccm qwen [global|china]ccm minimax [global|china]
Normalization handled by normalize_region().
5) OpenRouter (explicit)
OpenRouter is not a fallback. Use:
ccm open <provider>
emit_openrouter_exports() sets:
- Base URL:
https://openrouter.ai/api ANTHROPIC_AUTH_TOKEN=$OPENROUTER_API_KEYANTHROPIC_API_KEY=""(avoid conflicts)
6) Project-only override (Quotio-friendly)
ccm project glm [global|china] writes .claude/settings.local.json so GLM applies only to the current project.
Common Commands & Workflows
Installation
./install.sh
source ~/.zshrcSwitch in current shell
ccm deepseek
ccm kimi chinaLaunch Claude Code
ccc glm global
ccc open kimiSeed (ARK)
ccm seed # ark-code-latest
ccm seed kimi # kimi-k2.5
ccm seed deepseek # deepseek-v3.2Account management (Claude Pro)
ccm save-account work
ccm switch-account work
ccm list-accounts
ccm delete-account work
ccm current-accountCode Organization in ccm.sh
Key functions:
load_translations()/load_config()/is_effectively_set()emit_env_exports()(provider switching)emit_openrouter_exports()(OpenRouter)normalize_region()project_write_glm_settings()/project_reset_settings()show_status()/show_help()main()(command routing)
Adding a New Provider
- Add provider branch to
emit_env_exports() - Add to help text and README
- Add defaults to config template
- Add any region handling if required
Security Notes
- Token masking in
ccm status - Recommend
chmod 600 ~/.ccm_config - Environment vars override config file (good for CI)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

