JSPM

claude-settings-switch

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 66
  • Score
    100M100P100Q60858F
  • License ISC

Claude Code settings.json switcher CLI tool - Easily manage and switch between multiple Claude Code configurations

Package Exports

  • claude-settings-switch
  • claude-settings-switch/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (claude-settings-switch) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CC Switch

🚀 Claude Code 配置切换器 - 轻松管理多个 Claude Code 配置

CC Switch 是一个命令行工具,帮助您轻松管理和切换多个 Claude Code 配置。支持存储多组 URL 和 Token,并可一键切换,提升开发效率。

✨ 特性

  • 🔧 多配置管理 - 存储和管理多个 Claude Code 配置
  • 🔄 一键切换 - 快速切换不同的 URL 和 Token
  • 🛡️ 安全存储 - Token 安全遮蔽显示,配置文件权限保护
  • 💾 自动备份 - 切换前自动备份,支持手动备份和恢复
  • 🔍 智能检测 - 自动检测 Claude Code 配置文件位置
  • 🌐 多语言界面 - 支持中英文界面,交互式语言切换

📦 安装

npm 全局安装

npm install -g claude-settings-switch

安装完成后,您可以直接使用 ccs 命令。

⚠️ 注意:npm全局安装虽然方便,但建议优先使用源码安装以确保代码安全性

从源码安装

macOS / Linux

git clone https://github.com/songunity/ClaudeCode-Switch.git
cd ClaudeCode-Switch
npm install
./install.sh

Windows

git clone https://github.com/songunity/ClaudeCode-Switch.git
cd ClaudeCode-Switch
npm install
install.bat

🚀 快速开始

1. 检查系统状态

ccs diagnostics

2. 添加配置

# 添加开发环境配置
ccs add dev https://api.anthropic.com sk-ant-api03-xxxxxxxxxxxxxxxx

# 添加生产环境配置  
ccs add prod https://api.anthropic.com sk-ant-api03-yyyyyyyyyyyyyyyy

3. 切换配置

# 切换到开发环境(推荐使用简写)
ccs sw dev

# 切换到生产环境
ccs sw prod

4. 语言切换

# 交互式语言切换(推荐)
ccs la

# 或使用完整命令
ccs lang

# 直接切换到中文
ccs la zh

# 直接切换到英文  
ccs la en

5. 查看状态

# 查看所有配置
ccs list

# 查看当前配置
ccs current

📋 命令参考

基础命令

  • ccs add|a <name> <url> <token> - 添加新配置
  • ccs list|ls - 显示所有配置
  • ccs switch|sw <name> - 切换到指定配置(无参数时进入交互模式)
  • ccs remove|rm <name> - 删除配置
  • ccs current|cur - 显示当前配置

界面与语言

  • ccs language|lang|la [lang] - 语言切换(无参数时进入交互模式)
    • ccs la - 交互式选择语言
    • ccs la zh - 切换到中文界面
    • ccs la en - 切换到英文界面

管理命令

  • ccs backup - 创建手动备份
  • ccs restore <backup-file> - 从备份恢复
  • ccs diagnostics|diag - 系统诊断

帮助命令

  • ccs --help - 显示帮助信息
  • ccs --version|-v - 显示版本信息
  • ccs help <command> - 显示特定命令帮助

🛡️ 安全特性

  • Token 安全: 根据 token 类型智能遮蔽显示,配置文件权限设置为 600
  • 自动备份: 每次切换前自动创建备份,保留最近 5 个备份文件
  • 权限保护: 自动检查和设置适当的文件权限

📁 配置文件

  • CCS 配置: ~/.ccswitcher/configs.json - 存储所有 CCS 配置
  • Claude 配置: 自动检测 ~/.claude/settings.json.claude/settings.json 等位置

🔧 使用流程

# 1. 初次设置
ccs diagnostics                         # 检查系统状态
ccs add dev https://dev-api.com sk-dev   # 添加开发配置
ccs add prod https://api.com sk-prod     # 添加生产配置

# 2. 日常使用
ccs list                                # 查看所有配置
ccs sw dev                              # 切换到开发环境(推荐简写)
ccs sw prod                             # 切换到生产环境
ccs current                             # 检查当前状态
ccs la                                  # 交互式语言切换

🐛 故障排除

常见问题

配置文件不存在

ccs diagnostics  # 运行诊断检查

权限被拒绝

chmod 755 ~/.claude
chmod 644 ~/.claude/settings.json

切换后配置不生效

ccs current                # 检查当前状态
ccs switch <config-name>   # 重新切换

错误代码

  • CONFIG_NOT_FOUND - 配置不存在,使用 ccs list 查看可用配置
  • CONFIG_EXISTS - 配置名称已存在,选择不同名称或删除现有配置
  • CLAUDE_CONFIG_NOT_FOUND - Claude 配置文件不存在,请先运行 Claude Code
  • PERMISSION_DENIED - 权限不足,检查并修复文件权限

🆘 获取帮助

  • 内置帮助: ccs --helpccs diagnostics
  • 问题报告: GitHub Issues

报告问题时请包含:

  1. CCS 版本:ccs --version
  2. 系统诊断:ccs diagnostics
  3. 具体错误信息

📝 许可证

此项目基于 ISC 许可证开源。


Happy Coding with CC Switch! 🚀