ccswitch
Skill2 starsChanged 3 months agoApache-2.0View on GitHub
Install, configure, or use ccswitch. Switches Claude Code between the user's Claude subscription and third-party models (OpenRouter, Groq) per project, mid-session, in both directions. Use when the user wants to run Claude Code on a cheaper or different model, mentions OpenRouter/Groq with Claude Code, asks to switch providers or save on usage, or hits the `diagnostics.previous_message_id` 400 error.
- Pipes a download into a shell
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- FrankieeW/agent-skillstheir own version, first seen Mar 19, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- FrankieeW/agent-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
Never print, echo, or write these keys anywhere.
- Very specific: line 49
Only <project>/.claude/settings.local.json (the env block) plus ccswitch's own state in ~/.ccswitch.json.
- Very specific: line 64
If the user reports that 400 error, ccswitch fix on that session id is the remedy.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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
ccswitch
A CLI that switches a single project between the user's Claude subscription and any Anthropic-compatible provider, without breaking the running session.
Install it
bun install -g @unclecode/ccswitch # requires Bun: curl -fsSL https://bun.sh/install | bash
ccswitch install # keys check, /switch command, auto-restart hookThen make sure a provider key is exported in the user's shell profile, so Claude Code inherits it:
- OpenRouter:
export OPENROUTER_API_KEY=..., keys at https://openrouter.ai/keys - Groq:
export GROQ_API_KEY=..., keys at https://console.groq.com/keys
Never print, echo, or write these keys anywhere. ccswitch reads them from the environment itself.
Use it
ccswitch # interactive picker
ccswitch use z-ai/glm-5.3-flash # switch this project
ccswitch use groq:moonshotai/kimi-k2-instruct # provider-prefixed
ccswitch back # back to the Claude subscription
ccswitch back --clean # also remove the empty override keys
ccswitch status # what this project is using
ccswitch list / add / remove # manage favorite models
ccswitch fix [session-id] [--dry-run] # repair an already-poisoned transcript
ccswitch heal # restart this project's proxy if it stoppedDay to day the user should only need /switch inside Claude Code. The proxy starts on
demand and a SessionStart hook restarts it after a reboot, so there is no service to run.
After switching to another provider, always tell the user to run /model and select that
model. Otherwise the session keeps using its previous model at the new provider's price -
which can be far more expensive than intended.
Switching back needs no restart and no repair: keep working in the same session.
What it changes
Only <project>/.claude/settings.local.json (the env block) plus ccswitch's own state in
~/.ccswitch.json. Other projects and sessions are unaffected. Every change is backed up to
~/.ccswitch-backups/<project>/. Claude credentials are never touched.
Why it exists
Claude Code sends diagnostics.previous_message_id on each request; Anthropic requires it to
start with msg_. Third-party endpoints return their own id formats (OpenRouter: gen-…),
Claude Code persists them into the session transcript, and switching back then fails with a
permanent 400, surviving restarts, since the id is re-read from the transcript.
ccswitch runs a local proxy (127.0.0.1) that rewrites ids to msg_ form before they are
written, so the problem cannot occur. ccswitch fix repairs transcripts damaged before
ccswitch was in use.
If the user reports that 400 error, ccswitch fix on that session id is the remedy.
Troubleshooting
<PROVIDER>_API_KEY is not set, the key must be exported in the shell that launched Claude Code, not only in the current one.proxy unavailablewarning, Bun is missing or every port in range is taken. Check~/.ccswitch.log. Switching still works, but switching back will then needccswitch fix.- Connection refused in a switched project, the proxy is not running (e.g. after a
reboot without the hook installed). Run
ccswitch heal. - Model not found upstream, verify the exact model id on the provider's models page; ids
must match exactly (e.g.
z-ai/glm-5.3-flash). - Tool calls misbehaving on a cheap model, not all models handle Claude Code's tool calling well. Suggest a known-good one rather than debugging the model.
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.

