claude-code-config-switch
v1.0.0
Published
A TypeScript Node.js tool for managing Claude Code settings.json configuration switching
Maintainers
Readme
Claude Code Config Switch
A simple CLI tool to manage multiple Claude Code configuration profiles, allowing you to quickly switch between different API endpoints and authentication configurations.
Why Use This Tool?
Claude Code uses ~/.claude/settings.json to configure API endpoints and authentication information. If you need to switch between different environments (development, production, or different API keys), manually editing the configuration file can be tedious.
This tool allows you to:
- 🔄 Create and save multiple configuration profiles
- ⚡ Switch between configurations with a single command
- 🧹 Easily reset all configurations
- 💾 Automatically backup and manage configuration files
Installation
Global Installation
# Using npm
npm install -g claude-code-config-switch
# Using pnpm
pnpm install -g claude-code-config-switch
# Using yarn
yarn global add claude-code-config-switchRun Without Installing
# Using npx
npx claude-code-config-switch --help
# Using pnpm
pnpx claude-code-config-switch --help
# Using yarn
yarn dlx claude-code-config-switch --helpUsage
Create Configuration
# Interactive configuration creation
ccs create
# Create configuration with a specific name
ccs create productionThe system will prompt you to enter:
- Configuration name (if not specified)
ANTHROPIC_BASE_URL(API endpoint)ANTHROPIC_AUTH_TOKEN(authentication token)ANTHROPIC_API_KEY(optional, API key)ANTHROPIC_MODEL(optional, default model)ANTHROPIC_SMALL_FAST_MODEL(optional, fast model)
Switch Configuration
# List all available configurations and select one to switch
ccs env
# Directly switch to a specific configuration
ccs env productionReset Configuration
# Clear all Claude Code environment variable configurations
ccs reset⚠️ Note: The reset operation only removes Claude Code-related environment variables and does not affect other configurations in settings.json.
View Help
ccs --helpHow It Works
Storage Location
- Configuration files: Stored in
~/.claude-config/directory - Naming format:
claude-config.{config-name}.json - Active configuration: Applied to
~/.claude/settings.json
Configuration Switching
When you switch configurations, the tool will:
- Read the specified configuration file
- Clean up existing Claude Code environment variables in
settings.json - Merge the new configuration into
settings.json - Preserve other non-Claude Code related configurations
Managed Environment Variables
The tool manages the following environment variables:
ANTHROPIC_BASE_URLANTHROPIC_AUTH_TOKENANTHROPIC_API_KEYANTHROPIC_MODELANTHROPIC_SMALL_FAST_MODEL
Examples
Creating Development and Production Environment Configurations
# Create development environment configuration
ccs create development
# Enter development environment API information...
# Create production environment configuration
ccs create production
# Enter production environment API information...
# Switch between the two environments
ccs env development
ccs env productionView Current Configuration
# List all configurations
ccs envExample output:
Available configurations:
1. development (https://dev-api.anthropic.com)
2. production (https://api.anthropic.com)Configuration File Format
Configuration files are in standard JSON format:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.anthropic.com",
"ANTHROPIC_AUTH_TOKEN": "your-auth-token",
"ANTHROPIC_API_KEY": "your-api-key"
}
}Compatibility
- Operating Systems: Supports Windows, macOS, Linux
- Node.js: Requires Node.js 16 or higher
- Claude Code: Compatible with all Claude Code versions using
~/.claude/settings.json
Development
# Clone the project
git clone https://github.com/your-username/claude-code-config-switch.git
cd claude-code-config-switch
# Install dependencies
pnpm install
# Run in development mode
pnpm dev
# Build
pnpm build
# Run tests
pnpm test
# Generate test coverage report
pnpm test:coverageLicense
MIT License - see LICENSE file for details
Contributing
Issues and pull requests are welcome!
Support
If you find this tool useful, please give it a ⭐️!
Note: This tool is a third-party utility created to simplify Claude Code configuration management and is not affiliated with Anthropic.
