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

@wangxiaoerqqq/ccs

v2.0.1

Published

Claude Code Switcher - A CLI tool to quickly switch AI providers and models

Readme

CCS - Claude Code Switcher

一个极简风格的 CLI 工具,用于在 Claude Code 中即时切换 AI 提供商和模型。

功能特点

  • 快速切换: 一条命令即可切换提供商和模型
  • 多提供商支持: 支持阿里百炼、智谱 GLM、DeepSeek、火山引擎、MiniMax、美团 LongCat 等主流 AI 平台
  • 灵活配置: 支持提供商和模型两级 env 配置,模型代号与真实模型名分离
  • 安全存储: API 密钥加密存储在本地
  • 热加载: 自动发送重载信号,无需重启 Claude Code
  • 跨平台: 支持 macOS、Linux、Windows

安装

# npm
npm install -g @wangxiaoerqqq/ccs

# 或使用 pnpm
pnpm add -g @wangxiaoerqqq/ccs

# 或使用 yarn
yarn global add @wangxiaoerqqq/ccs

快速开始

1. 初始化配置

ccs init

这将引导你设置各个平台的 API 密钥。

2. 切换提供商

# 切换到阿里百炼(使用默认模型)
ccs aliyun

# 切换到智谱 GLM 并指定模型
ccs zhipu glm-5.1

# 切换到 DeepSeek
ccs deepseek

# 仅切换模型(保持当前提供商)
ccs model qwen-max

3. 查看状态

# 列出所有提供商和模型
ccs list

# 查看当前配置
ccs current

# 查看特定提供商的模型列表
ccs models zhipu

支持的提供商

| 提供商 | 命令 | 默认模型 | |--------|------|----------| | 阿里百炼 | ccs aliyun | qwen-turbo | | 智谱 GLM | ccs zhipu | glm-5.1 | | 火山引擎豆包 | ccs volc | doubao-pro-32k | | DeepSeek | ccs deepseek | v4pro | | Moonshot Kimi | ccs moonshot | kimi-k2.6 | | MiniMax | ccs minimax | m3 | | Anthropic 官方 | ccs anthropic | claude-sonnet-4-6 | | 美团官方 | ccs longcat | longcat-2-preview |

命令参考

ccs init

初始化 CCS 配置,交互式引导设置 API 密钥。

ccs <provider> [model]

切换到指定提供商和模型。

ccs aliyun              # 切换到阿里百炼(默认模型)
ccs zhipu glm-5.1       # 切换到智谱 GLM 的 glm-5.1 模型
ccs minimax m3         # 切换到 MiniMax-M3

ccs model <model>

仅切换模型,保持当前提供商不变。

ccs model qwen-max      # 切换到 qwen-max 模型

ccs set-key <provider> [api-key]

设置提供商的 API 密钥。

ccs set-key zhipu              # 交互式输入
ccs set-key aliyun sk-xxx      # 直接设置

ccs list / ccs ls

列出所有可用的提供商和模型,含模型代号和真实 API 模型名。

ccs current

显示当前的提供商和模型配置。当代号与真实模型名不同时,额外显示 Real model 行。

ccs models [provider]

列出提供商的所有可用模型。

ccs models             # 当前提供商的模型
ccs models zhipu       # 智谱 GLM 的所有模型

ccs edit

打开提供商配置文件进行编辑。

ccs reload

发送重载信号到 Claude Code 进程。

配置文件

配置文件存储位置:

| 平台 | 配置目录 | |------|----------| | macOS/Linux | ~/.config/ccs/ | | Windows | %APPDATA%\ccs\ |

文件说明

  • providers.json - 提供商和模型配置
  • current.json - 当前选择的提供商和模型
  • secrets.enc - 加密存储的 API 密钥
  • .key - 本地加密密钥(请勿分享)

providers.json 结构

每个提供商可以配置两级 env

  • provider 级 env:所有模型共享的基础环境变量(如 ANTHROPIC_BASE_URL
  • model 级 env:覆盖或追加模型专属的环境变量(如 ENDPOINT_ID

模型的 model 字段为真实 API 模型名,而 key 为用户使用的友好代号:

{
  "moonshot": {
    "name": "Moonshot Kimi",
    "env": {
      "ANTHROPIC_BASE_URL": "https://api.moonshot.cn/v1"
    },
    "models": {
      "kimi-8k": {
        "name": "Kimi 8K",
        "model": "moonshot-v1-8k",
        "default": true
      }
    }
  }
}

上例中用户使用 ccs moonshot kimi-8k,实际写入 ANTHROPIC_MODEL 的值为 moonshot-v1-8k

模型也可配置 env 字段覆盖 provider 级的同名变量(undefined 值会被跳过不覆盖):

{
  "deepseek": {
    "name": "DeepSeek",
    "env": {
      "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
      "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro"
    },
    "models": {
      "deepseek-v4-flash": {
        "name": "DeepSeek V4 Flash",
        "model": "deepseek-v4-flash",
        "env": {
          "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-flash"
        }
      }
    }
  }
}

切换 deepseek-v4-flash 时,ANTHROPIC_DEFAULT_OPUS_MODEL 会被覆盖为 deepseek-v4-flash

添加自定义提供商

编辑 ~/.config/ccs/providers.json

{
  "my-provider": {
    "name": "我的提供商",
    "env": {
      "ANTHROPIC_BASE_URL": "https://api.example.com/anthropic"
    },
    "models": {
      "model-1": {
        "name": "Model 1",
        "model": "real-model-name-1",
        "default": true
      },
      "model-2": {
        "name": "Model 2",
        "model": "real-model-name-2",
        "env": {
          "CUSTOM_VAR": "model-specific-value"
        }
      }
    }
  }
}

热加载机制

CCS 支持自动重载 Claude Code 配置:

  1. 切换提供商后,自动检测 Claude Code 进程
  2. 发送 SIGHUP 信号触发重载
  3. 如使用 Shell wrapper,会话自动继续

Shell Wrapper(推荐)

创建 ~/bin/claude-wrapper.sh

#!/bin/bash
while claude "$@"; [ $? -eq 129 ]; do
  set -- -c
done

然后在终端中使用此脚本启动 Claude Code。

开发

# 克隆仓库
git clone https://gitee.com/xiaoerlangqqq/ccs.git
cd ccs

# 安装依赖
npm install

# 构建
npm run build

# 测试
npm test

# 开发模式(监听文件变化)
npm run dev

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

相关项目

  • Genzhen/ccs - 本项目上游,Fork 后在此基础上进行了功能扩展与持续维护
  • Claude Code - Anthropic 官方 CLI 工具