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

@lesliecheung/claude-source-switcher

v1.0.1

Published

Switch between different Claude API configurations quickly

Readme

Claude Switcher

简洁的 Claude API 配置切换工具。

安装

npm install -g claude-switcher

使用

# 添加配置
cs add official https://api.anthropic.com sk-ant-xxxxx
cs add local http://localhost:8080

# 列出配置  
cs ls
# * official → https://api.anthropic.com 🔑
#   local → http://localhost:8080

# 切换配置
cs use official
# ✓ Switched to: official

# 查看当前配置
cs
# official → https://api.anthropic.com

# 删除配置
cs rm local
# ✓ Removed: local

# 交互式模式
cs i

命令

| 命令 | 别名 | 描述 | |------|------|------| | cs | | 显示当前配置 | | cs add <name> <endpoint> [key] | | 添加新配置 | | cs use <name> | | 切换到配置 | | cs ls | list | 列出所有配置 | | cs rm <name> | remove | 删除配置 | | cs current | | 显示当前配置 | | cs i | interactive | 交互式模式 |

长命令别名

如果喜欢更明确的命令名,也可以使用:

claude-switch add test http://test.com
claude-switch use test  
claude-switch ls

使用方法

命令行模式

# 列出所有配置的源
claude-source list
claude-source ls

# 添加新源
claude-source add -n "官方源" -e "https://api.claude.ai" -k "your-api-key"
claude-source add -n "备用源" -e "https://backup.claude.ai"

# 切换源
claude-source switch "官方源"
claude-source use "备用源"

# 显示当前活动源
claude-source current

# 删除源
claude-source remove "备用源"
claude-source rm "备用源"

# 交互式模式
claude-source interactive
claude-source i

交互式模式

运行 claude-source interactive 进入交互式界面,提供以下选项:

  • 📋 列出所有源
  • ➕ 添加新源
  • 🔄 切换源
  • ❌ 删除源
  • 📍 显示当前源
  • 🚪 退出

配置文件

配置文件存储在 ~/.claude-code/ 目录下:

  • sources.json - 所有源的配置信息
  • active-source.json - 当前活动源信息

配置文件格式

// sources.json
[
  {
    "name": "官方源",
    "endpoint": "https://api.claude.ai",
    "apiKey": "your-api-key",
    "createdAt": "2025-01-01T00:00:00.000Z"
  },
  {
    "name": "备用源",
    "endpoint": "https://backup.claude.ai",
    "apiKey": null,
    "createdAt": "2025-01-01T00:00:00.000Z"
  }
]

// active-source.json
{
  "name": "官方源",
  "endpoint": "https://api.claude.ai",
  "apiKey": "your-api-key",
  "createdAt": "2025-01-01T00:00:00.000Z"
}

开发

项目结构

claude-code-source-switcher/
├── bin/
│   └── claude-source.js          # CLI 入口文件
├── src/
│   └── source-switcher.js        # 核心功能类
├── index.js                      # 模块导出
├── package.json                  # 项目配置
└── README.md                     # 文档

添加新功能

  1. 修改 src/source-switcher.js 添加核心逻辑
  2. 在 bin/claude-source.js 中添加新的 CLI 命令
  3. 更新文档

注意事项

  • API 密钥将以明文存储在本地配置文件中,请确保文件权限安全
  • 首次添加源时会自动设为活动源
  • 删除当前活动源时会自动切换到第一个可用源

许可证

MIT