ccenv
A convenient command-line tool for quickly switching between different Claude API configurations.
中文
Features
- 🔄 Interactive configuration selection menu
- ⭐ Current active configuration marked with
*
- 🎯 Cursor defaults to the currently active configuration
- 🔧 Automatic environment variable management (unset old config, set new config)
- 🚀 Auto-launch
claude command after switching
- ⚙️ Support for direct configuration name specification for quick switching
- 🌍 Internationalization support (English/中文)
- 🔍 Smart language detection based on system locale
- 📦 npm global installation support, cross-platform compatibility
Installation
Method 1: Install via npm (Recommended)
npm install -g @william-zxs/ccenv
Method 2: Local Development Installation
- Clone or download this project
- Run in the project directory:
npm install -g .
npm installation will automatically:
- Create configuration directory
~/.ccenv/
- Generate default configuration file
~/.ccenv/settings.json
- Install
ccenv command to global PATH
Usage
Step 1: Configure API Keys (Required)
After installation, you need to configure your API keys first:
ccenv edit
This will open the configuration file in an editor. Fill in your API keys for each provider:
Replace the empty ANTHROPIC_AUTH_TOKEN values with your actual API keys.
Step 2: Switch Configurations
Interactive Selection
ccenv
This will display the configuration menu with color-coded token status:
- 🟢 Green checkmark: API key configured
- 🔴 Red X: API key missing
Direct Switching
ccenv kimi
ccenv glm
ccenv qwen
ccenv deepseek
List All Configurations
ccenv ls
Shows all available configurations with their status.
Language Settings
ccenv lang
ccenv lang zh
ccenv lang en
ccenv --lang en ls
ccenv supports internationalization with:
- Automatic language detection based on system locale
- Persistent language settings saved to configuration file
- Temporary language override using
--lang parameter
- Supported languages: English (
en), Chinese (zh)
Configuration File
The configuration file is located at ~/.ccenv/settings.json with the following format:
{
"defaultProfile": null,
"profiles": [
{
"name": "kimi",
"env": {
"ANTHROPIC_BASE_URL": "https://api.moonshot.cn/anthropic",
"ANTHROPIC_AUTH_TOKEN": "sk-your-moonshot-api-key",
"ANTHROPIC_MODEL": "kimi-k2-turbo-preview",
"ANTHROPIC_SMALL_FAST_MODEL": "kimi-k2-turbo-preview"
}
},
{
"name": "glm",
"env": {
"ANTHROPIC_BASE_URL": "https://open.bigmodel.cn/api/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your-zhipu-api-key.xxx"
}
},
{
"name": "qwen",
"env": {
"ANTHROPIC_BASE_URL": "https://dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy",
"ANTHROPIC_AUTH_TOKEN": "sk-your-alibaba-api-key"
}
},
{
"name": "deepseek",
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_AUTH_TOKEN": "sk-your-deepseek-api-key",
"ANTHROPIC_MODEL": "deepseek-chat",
"ANTHROPIC_SMALL_FAST_MODEL": "deepseek-chat"
}
}
]
}
Supported Environment Variables
ANTHROPIC_BASE_URL - API base URL
ANTHROPIC_AUTH_TOKEN - Authentication token
ANTHROPIC_MODEL - Default model
ANTHROPIC_SMALL_FAST_MODEL - Small fast model
Built-in Configurations
The following API configurations are included by default:
- kimi - Moonshot AI (月之暗面)
- glm - Zhipu AI (智谱AI)
- qwen - Alibaba Tongyi Qianwen (阿里通义千问)
- deepseek - DeepSeek AI (深度求索)
How It Works
- Read the
~/.ccenv/settings.json configuration file
- Detect the currently active configuration (via
CCENV_PROFILE environment variable)
- Display interactive menu with current configuration marked and token status color-coded
- After user selects a new configuration:
- Clear existing related environment variables
- Set new configuration environment variables
- Set
CCENV_PROFILE to track active configuration
Development and Local Testing
If you want to develop or test locally:
git clone <repository-url>
cd ccenv
npm install
node src/cli.js
npm link
ccenv
Important Notes
- Environment variables are scoped to the current shell session only
- Ensure
claude command is properly installed
- Node.js version requirement: >= 14.0.0
Custom Configuration
You can edit the ~/.ccenv/settings.json file to add or modify configurations. Modified configurations take effect immediately without reinstallation.
Publishing to npm
To publish a new version to npm:
npm version patch
npm publish