A terminal-based tool to switch between different AI providers for Claude Code and Codex Perfect for headless environments like servers
English | 简体中文
- Features
- Use Cases
- Quick Start
- Global Alias Installation
- Supported Providers
- Switching Flow
- Custom Provider
- Relationship with AI CLI Tools
- FAQ
- Design Conventions
- Roadmap
- License
- ✨ Pre-configured Providers: Built-in
zhipuand88codeconfigurations without hardcoded secrets - 🔄 Dual Sync: Updates both Claude Code (
settings.json) and Codex (auth.json) simultaneously - 🎯 Custom Provider: Easily add new providers via command-line parameters
- 💾 Auto Backup: Automatically backs up configurations before switching, even recovers from corrupted files
- 🧹 Smart Cleanup: Automatically removes redundant configuration keys when switching providers
Connect to remote servers via SSH and quickly switch between different AI providers in headless environments without manually editing configuration files.
Example Scenario:
ssh user@server
ccsw 88code # Switch to 88code provider
claude code # Start working with new configManage AI tool configurations in containerized environments without GUI, perfect for automated development and testing deployments.
Example Scenario:
# Dockerfile
RUN git clone https://github.com/Boulea7/ccsw.git && \
cd ccsw && \
./bootstrap.sh && \
export CODE88_ANTHROPIC_AUTH_TOKEN=${API_TOKEN} && \
ccsw 88codeUnified configuration management on AWS, Alibaba Cloud, Tencent Cloud and other cloud hosts, supporting batch deployment scripts.
Example Scenario:
# Batch configure multiple servers
ansible all -m shell -a "cd ~/ccsw && ccsw zhipu"Dynamically switch AI tool provider configurations in automated testing and deployment workflows.
Example Scenario (GitHub Actions):
- name: Switch AI Provider
run: |
cd ~/ccsw
ccsw 88code
claude code analyze --file src/main.pyUse different AI providers for development, testing, and production environments. Switch with one command without memorizing complex configurations.
Example Scenario:
# Development environment
ccsw zhipu
# Production environment
ccsw 88code
# Quick rollback
cd ~/.claude && cp settings.json.bak-20250117-143052 settings.json- Python 3.6 or higher
- Git (for cloning the repository)
- Claude Code or Codex installed
git clone https://github.com/Boulea7/ccsw.git && cd ccswDescription: Download the project to your local machine. All operations will be performed in the ccsw directory.
Expected Output:
Cloning into 'ccsw'...
remote: Enumerating objects: 42, done.
remote: Counting objects: 100% (42/42), done.
...
./bootstrap.shDescription: The script automatically detects your shell (zsh or bash) and adds the ccsw alias to your configuration file.
Expected Output:
Detected shell: zsh
Adding ccsw alias to /Users/yourname/.zshrc...
✅ Alias 'ccsw' added successfully!
Please run: source ~/.zshrc
export ZHIPU_ANTHROPIC_AUTH_TOKEN="your_zhipu_token"
export CODE88_ANTHROPIC_AUTH_TOKEN="your_88code_token"
export CODE88_OPENAI_API_KEY="your_88code_token" # For Codex, defaults to aboveDescription: Set API tokens as environment variables. ccsw will automatically read them. It's recommended to add these to ~/.zshrc or ~/.bashrc.
Tip: If you only use Claude Code (not Codex), you can skip CODE88_OPENAI_API_KEY.
source ~/.zshrc # Or source ~/.bashrc if using bashDescription: Activate the newly added ccsw alias. Alternatively, restart your terminal.
ccsw zhipu # Switch to Zhipu
ccsw 88code # Switch to 88code
ccsw 88 # Use alias shortcut (88 = 88code)Expected Output:
[claude] Backed up previous settings to /Users/yourname/.claude/settings.json.bak-20250117-143052
[claude] Switched Claude Code environment to: 88code
[codex] Backed up previous auth to /Users/yourname/.codex/auth.json.bak-20250117-143052
[codex] Updated auth.json (OpenAI compatible).
Tip: After switching, restart Claude Code or Codex for the new configuration to take effect.
Run the following command to test if ccsw is working:
ccsw --helpExpected Output:
usage: ccsw.py [-h] [--token TOKEN] [--base-url BASE_URL] ...
Switch Claude Code / Codex providers
...
Recommended method using bootstrap.sh (auto-detects zsh/bash):
./bootstrap.sh
source ~/.zshrc # Or ~/.bashrcTo configure manually, add to ~/.zshrc (or ~/.bashrc):
alias ccsw="python3 $HOME/ccsw/ccsw.py"Then run source ~/.zshrc to reload the configuration.
| Provider | Claude Code | Codex | Special Config | Environment Variable |
|---|---|---|---|---|
| zhipu | ✅ | ❌ | 3000s timeout Disable non-essential traffic |
ZHIPU_ANTHROPIC_AUTH_TOKEN |
| 88code | ✅ | ✅ | None | CODE88_ANTHROPIC_AUTH_TOKENCODE88_OPENAI_API_KEY |
| Custom | ✅ | Optional | Custom | CLI parameter --token |
Alias Support:
glm→zhipu88→88code
graph TD
A[User runs: ccsw zhipu] --> B{Check env var}
B -->|Exists| C[Read token]
B -->|Not found| D[❌ Error: Token required]
C --> E[Backup config]
E --> F[Update settings.json]
F --> G[Save config]
G --> H{Configure Codex?}
H -->|Yes| I[Update auth.json]
H -->|No| J[Skip Codex]
I --> K[✅ Switch complete]
J --> K
How It Works:
- Read Token: Obtain API token from environment variable or CLI parameter
- Backup Config: Copy current config to a timestamped backup file
- Update Config: Modify the
envfield in~/.claude/settings.json - Sync Codex (Optional): Update
~/.codex/auth.jsonif OpenAI-compatible endpoint is provided - Cleanup: Automatically remove Zhipu-specific keys when switching to
88code
Besides built-in zhipu and 88code, you can add custom providers:
python3 ccsw.py myvendor \
--token "<your_token>" \
--base-url "https://api.myvendor.com/anthropic" \
--openai-base-url "https://api.myvendor.com/openai/v1" \
--timeout 30000 \
--disable-nonessential-traffic| Parameter | Required | Description |
|---|---|---|
--token |
✅ | Anthropic-compatible auth token (built-in providers can use env vars) |
--base-url |
⭕ | Anthropic Base URL (built-in providers have defaults) |
--openai-base-url |
⭕ | OpenAI-compatible endpoint (for Codex, optional) |
--codex-token |
⭕ | API Key for Codex (defaults to --token value) |
--timeout |
⭕ | API timeout in milliseconds (string or number) |
--disable-nonessential-traffic |
⭕ | Disable non-essential traffic (sets CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1) |
--skip-codex |
⭕ | Only update Claude Code, skip Codex configuration |
ccsw myvendor --token "sk-xxx" --base-url "https://api.example.com" --skip-codexThis project only handles configuration switching, not replacing any CLI tools. You continue using your existing tools (Codex, Claude Code, other Anthropic-compatible CLIs), but switch providers before calling them with ccsw ....
Usage Flow:
ccsw 88code # Switch config
↓
Restart Claude Code # Activate new config
↓
Normal usage # Enjoy new provider
After switching, restart/reconnect Claude Code or run Codex in a new terminal to use the latest env.
Error Message:
Token is required. Provide --token or set ZHIPU_ANTHROPIC_AUTH_TOKEN
Solution:
graph TD
A[Token error] --> B[Run echo to check env var]
B --> C{Output empty?}
C -->|Yes| D[Export environment variable]
C -->|No| E[Check token format]
D --> F[Re-run ccsw zhipu]
E --> G{Token has quotes?}
G -->|No| H[Add quotes]
G -->|Yes| I[Contact provider to verify validity]
Quick Fix:
# Check environment variable
echo $ZHIPU_ANTHROPIC_AUTH_TOKEN
# If empty, export token
export ZHIPU_ANTHROPIC_AUTH_TOKEN="your_token_here"
# Or specify in command
ccsw zhipu --token "your_token_here"Solution:
graph TD
A[ccsw command not found] --> B[Reload config file]
B --> C{Working?}
C -->|No| D[Check if alias added correctly]
D --> E{Found alias?}
E -->|No| F[Re-run bootstrap.sh]
E -->|Yes| G[Check path correctness]
G --> H{File exists?}
H -->|No| I[Check repo clone location]
H -->|Yes| J[Try restarting terminal]
C -->|Yes| K[✅ Problem solved]
Quick Fix:
# Method 1: Reload configuration
source ~/.zshrc # Or source ~/.bashrc
# Method 2: Restart terminal
# Close current terminal, open new one
# Method 3: Run script manually (without alias)
python3 ~/ccsw/ccsw.py zhipuEach switch creates a timestamped backup file for easy recovery:
# Navigate to config directory
cd ~/.claude
# List all backup files (reverse chronological)
ls -lt settings.json.bak-*
# Copy backup to restore (replace XXXXXXXX with actual timestamp)
cp settings.json.bak-20250117-143052 settings.jsonBackup File Naming:
settings.json.bak-YYYYmmdd-HHMMSS: Normal backupsettings.json.corrupt-YYYYmmdd-HHMMSS: Corrupted file backup
No. ccsw is a small script/alias with a single responsibility: modify the env field in local configuration files.
You still need to use real AI programming tools like Claude Code, Codex, etc. ccsw only handles switching configurations between different providers.
graph TD
A[Problem persists] --> B[Check if backup exists]
B --> C{Backup exists?}
C -->|Yes| D[Restore recent backup]
C -->|No| E[Check if config is corrupted]
E --> F[Delete corrupted settings.json]
F --> G[Re-run ccsw]
D --> H{Problem solved?}
H -->|No| I[Submit GitHub Issue]
H -->|Yes| J[✅ Complete]
Contact:
- Submit Issue: GitHub Issues
- Check logs:
~/.claude/settings.json.bak-*files can help diagnose issues
- Config File Location: Fixed at
~/.claude/settings.json(Claude Code) and~/.codex/auth.json(Codex) - Backup Strategy:
- Copy to
settings.json.bak-YYYYmmdd-HHMMSSbefore each write - Save as
settings.json.corrupt-YYYYmmdd-HHMMSSwhen file is corrupted
- Copy to
- Security Principles:
- No secrets in repository
.gitignoreexcludes local secret files (.env.local), backup files, and local config directories
- Environment Variable Priority:
- CLI parameter
--token - Built-in provider env vars (e.g.,
ZHIPU_ANTHROPIC_AUTH_TOKEN) - Default values (if available)
- CLI parameter
- Add provider config file (YAML/JSON) reading to extend without code modification
- Add
--listto output current config and available providers - Support Windows PowerShell alias configuration script
- Add interactive switching mode (like
fzf) - Support multi-configuration management (e.g.,
work,personalprofiles)
This project is licensed under the MIT License. See LICENSE for details.