Skip to content

Repository files navigation

CCS - Claude Code Switch

Lightweight CLI to switch between AI model providers for Claude Code.

Features

  • Switch between Anthropic (OAuth) and custom API providers (GLM, etc.)
  • Interactive provider management: ccs add, ccs remove
  • Self-update: ccs update
  • Simple commands: ccs glm, ccs anthropic
  • Shell aliases: claude-glm, claude-anthropic, ccm, ccc
  • Auto-clean: removes large cache files on startup
  • Config validation: Zod schema validation with helpful error messages
  • No TTY issues: runs Claude in foreground (fixes "suspended tty output" bug)
  • MCP Sync: Automatically syncs MCP servers across all providers
  • Resource Sync: Shares commands, settings, plugins, skills, agents, CLAUDE.md across providers

Installation

NOTE: The npm package cc-switch is not yet published to npm. Please use the manual install or one-line install method.

Option 1: One-line install (Recommended)

curl -fsSL https://raw.githubusercontent.com/dev-toolings/ccm-manager/main/install.sh | bash

This will:

  • Clone the repository to ~/.ccs
  • Install dependencies (bun or npm required)
  • Create a default .ccsignore file to prevent OOM errors

Option 2: Manual install

# Clone
git clone https://github.com/dev-toolings/ccm-manager.git ~/.ccs
# Install dependenciescd~/.ccs && bun install
# Add to ~/.zshrc or ~/.bashrcecho'export PATH="$HOME/.ccs/bin:$PATH"'>>~/.zshrc
echo'eval "$(ccs alias)"'>>~/.zshrc
source~/.zshrc

Option 3: npm/bun (Not yet available)

# With bun (faster)
bun install -g cc-switch
# Or with npm
npm install -g cc-switch

Coming soon: The npm package will be published once stable. For now, please use Option 1 or 2.

Updating

# Update to latest versioncd~/.ccs && git pull
# Rebuild
bun install
bun run build

Quick Start

# Add a new provider interactively
ccs add glm
# List all providers
ccs list
# Switch to a provider
ccs glm
# Run Claude with current provider
ccs
# Run Claude with a specific provider
ccs run glm

Commands

CommandDescription
ccsRun Claude with current provider
ccs statusShow current provider
ccs list / ccs lsList all providers
ccs use <provider>Switch to a provider
ccs run [provider]Run Claude (optional provider switch)
ccs add <key>Add a new provider interactively
ccs remove <key> / ccs rmRemove a provider
ccs sync [provider]Sync shared resources & MCP servers
ccs sync --allSync all providers
ccs updateUpdate CCS to latest version
ccs aliasGenerate shell aliases
ccs alias -iShow shell setup instructions
ccs configShow config file path

Shell Aliases

After running eval "$(ccs alias)":

ccm glm # = ccs glm (switch provider)
ccc # = ccs run (run Claude)
ccc glm # = ccs run glm
claude-glm # Direct provider alias
claude-anthropic # Direct provider alias

Configuration

Config is stored at ~/.ccs/config.json (or $CCS_CONFIG_PATH if set).

Example Configuration

{
"current": "anthropic",
"providers": {
"anthropic": {
"name": "Anthropic (OAuth)",
"type": "oauth",
"configDir": "~/.claude"
},
"glm": {
"name": "GLM-4.7",
"type": "api_key",
"description": "GLM-4.7 via Z.AI",
"configDir": "~/.claude-glm",
"env": {
"ANTHROPIC_AUTH_TOKEN": "your-token",
"ANTHROPIC_MODEL": "glm-4.7",
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic"
}
}
}
}

Provider Types

TypeDescriptionRequired Fields
oauthAnthropic OAuth loginconfigDir
api_keyCustom API providerconfigDir, env with API credentials

Environment Variables for Providers

For api_key providers, you can set:

VariableDescription
ANTHROPIC_AUTH_TOKENAuthentication token
ANTHROPIC_API_KEYAPI key
ANTHROPIC_MODELModel name
ANTHROPIC_BASE_URLAPI endpoint URL

Adding Providers

Interactive (Recommended)

ccs add my-provider
# Follow the prompts

Manual

Edit ~/.ccs/config.json directly.

Environment Variables

VariableDescription
CCS_CONFIG_PATHCustom config file path

Auto-Cleanup

CCS automatically cleans up large cache directories before launching Claude:

  • shell-snapshots/ if > 10MB
  • debug/ if > 5MB

This prevents Claude from slowing down due to accumulated cache files.

Resource Sync

CCS automatically syncs shared resources from ~/.claude to all provider config directories:

ResourceTypeDescription
commands/symlinkCustom slash commands
settings.jsonsymlinkStatus line, plugins config
plugins/symlinkInstalled plugins
skills/symlinkUser skills
agents/symlinkCustom agents
CLAUDE.mdsymlinkUser instructions
AGENTS.mdsymlinkAgent instructions
prompts/symlinkPrompt templates

Manual Sync

# Sync all providers
ccs sync --all
# Sync with force (recreate symlinks)
ccs sync --all --force
# Sync specific provider
ccs sync glm

MCP Server Sync

CCS automatically syncs MCP servers from ~/.claude.json to all provider config directories.

When you run ccs run glm, your MCP servers (web-search, assistant-ui, etc.) are automatically available.

Adding MCP Servers (Important!)

Always use -s user flag to add MCP servers globally:

# HTTP server
claude mcp add my-server -s user --transport http https://api.example.com/mcp
# stdio server (npx)
claude mcp add next-devtools -s user -- npx next-devtools-mcp@latest
# stdio server with args
claude mcp add assistant-ui -s user -- npx -y @assistant-ui/mcp-docs-server

MCP Scopes

FlagScopeSynced by CCSStorage
-s userGlobal✅ Yes~/.claude.json
-s localProject (private)❌ NoProject config
-s projectProject (shared)❌ No.mcp.json

Rule: Always use -s user so CCS syncs MCP servers to all providers.

How it works

  1. MCP servers are stored in ~/.claude.json (source of truth)
  2. On each ccs run <provider>, MCP servers are merged into ~/<provider-config>/.claude.json
  3. New servers are added, existing servers are updated

Verify MCP Sync

# Check MCP servers for a specific provider
CLAUDE_CONFIG_DIR=~/.claude-glm claude mcp list

Troubleshooting

"TTY suspended" issues

CCS runs Claude with stdio: 'inherit', which fixes terminal issues. If you still have problems, ensure you're running ccs directly (not through a pipe).

Config validation errors

If your config is invalid, CCS will show detailed errors:

[ccs] Invalid config.json:
- providers.glm.env.ANTHROPIC_BASE_URL: Invalid url
[ccs] Using default config. Fix your config.json or delete it to regenerate.

Reset to defaults

Delete the config file to reset:

rm ~/.ccs/config.json

Uninstall

# Remove the installation directory
rm -rf ~/.ccs
# Remove lines from ~/.zshrc or ~/.bashrc:# export PATH="$HOME/.ccs/bin:$PATH"# eval "$(ccs alias)"

Requirements

License

MIT - See LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages