npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@weishiren/claude-config-switcher

v2.0.0

Published

A CLI tool for quickly switching between different Claude configuration files

Readme

Claude 配置切换器(claude-config-switcher)

Claude 配置切换器是一个简洁的命令行工具,用于在本地快速切换不同的 Claude 环境配置。它管理一个统一的配置文件 claudeEnvConfig.json,切换时直接替换 ~/.claude/settings.json 中的 env 字段。


🌟 主要特性

  • 单一配置文件:所有环境配置集中在一个文件中管理
  • 简单切换:一键切换环境,直接替换 settings.json 的 env 字段
  • 交互式选择:支持交互式列表选择或命令行参数快速切换
  • 配置验证:验证配置文件格式,确保配置正确

🚀 典型使用场景

  • 多账号管理:工作/个人账号快速切换
  • 环境隔离:开发、测试、生产环境使用不同配置
  • 代理设置:国内外网络环境下使用不同代理配置
  • 模型切换:根据不同任务需求切换 Claude 模型

📦 安装与使用

全局安装

npm install -g @weishiren/claude-config-switcher

安装完成后,可以直接在任意目录使用:

# 交互模式
ccs

# 直接切换到指定模型
ccs work
ccs personal

使用 npx(无需全局安装)

npx @weishiren/claude-config-switcher
npx @weishiren/claude-config-switcher work

配置文件格式

配置文件路径

~/.claude-config-switch/claudeEnvConfig.json

配置文件示例

{
  "work": {
    "ANTHROPIC_API_KEY": "sk-work-xxx",
    "ANTHROPIC_BASE_URL": "https://api.anthropic.com",
    "ANTHROPIC_MODEL": "claude-3-sonnet-20240229"
  },
  "personal": {
    "ANTHROPIC_API_KEY": "sk-personal-yyy",
    "ANTHROPIC_BASE_URL": "https://custom-api.example.com"
  },
  "dev": {
    "ANTHROPIC_API_KEY": "sk-dev-zzz",
    "ANTHROPIC_BASE_URL": "http://localhost:8080"
  }
}

目标文件

切换后,~/.claude/settings.jsonenv 字段会被替换:

{
  "env": {
    "ANTHROPIC_API_KEY": "sk-work-xxx",
    "ANTHROPIC_BASE_URL": "https://api.anthropic.com",
    "ANTHROPIC_MODEL": "claude-3-sonnet-20240229"
  }
}

注意:settings.json 中的其他顶层字段在切换时会保留。


命令行用法

ccs [model] [options]

命令

| 命令 | 说明 | |------|------| | ccs | 交互式选择模型 | | ccs <model> | 直接切换到指定模型(如 ccs work) | | ccs -l, --list | 列出所有可用模型 | | ccs -i, --info | 显示当前 env 配置 | | ccs -V, --validate | 验证配置文件格式 | | ccs -h, --help | 显示帮助信息 | | ccs --version | 显示版本号 |

示例

# 交互式选择
ccs

# 切换到 work 环境
ccs work

# 切换到 personal 环境
ccs personal

# 列出所有模型
ccs -l

# 查看当前配置
ccs -i

# 验证配置文件
ccs -V
ccs -V --verbose  # 显示详细配置内容

工作原理

  1. 读取 ~/.claude-config-switch/claudeEnvConfig.json 配置文件
  2. 根据模型名称获取对应的环境变量配置
  3. 读取 ~/.claude/settings.json 文件
  4. 用新的环境变量替换 env 字段(保留其他字段)
  5. 写回 ~/.claude/settings.json

🤝 贡献指南

欢迎提交 Issue 和 Pull Request 来改进这个工具!

开发环境设置

git clone https://github.com/weishiren/claude-config-switcher.git
cd claude-config-switcher
npm install
npm link  # 链接到全局以便测试

运行测试

npm test
npm run test:coverage
npm run lint

📄 许可证

MIT License - 详见 LICENSE 文件


🆘 故障排除

常见问题

Q: 配置文件在哪里?

A: 配置文件位于 ~/.claude-config-switch/claudeEnvConfig.json,首次运行会自动创建空配置。

Q: 切换后 settings.json 的其他配置会丢失吗?

A: 不会。切换只会替换 env 字段,其他顶层字段会保留。

Q: 如何验证配置是否正确?

A: 使用 ccs -V 命令验证配置文件格式。

获取帮助

ccs --help