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

@guangnao/claude-cli

v1.0.17

Published

Serve several claude subscription identities behind one Anthropic-compatible /v1/messages endpoint. No containers, no runtime dependencies.

Readme

claude-cli

把多个 claude 订阅身份放在同一台机器上跑,对外只暴露一套标准的 Anthropic 接口。

请求按「在途最少」分摊到各身份;某个身份被限流时自动避开它,客户端只面对一个地址。

安装

npm i -g @guangnao/claude-cli
claude-cli                    # 用你本机现有的 claude 登录,立刻能用

需要 Node 20.12+。发布产物是单个文件,装的时候什么都不用下载。

启动时 API key 自动生成并存到 <state>/apikey(0600,跨重启不变),横幅上直接打给你:

  ◉  http://127.0.0.1:8787  ready  v1.0.0

  Key       sk-934a4bdbf******116562  (留着别外传)
  身份      work  ·  personal
  Limits    2 并发/身份  ·  预热 1  ·  600s 超时
  Endpoints POST /v1/messages   GET /v1/models   GET /health

用

claude-cli add work           # 想要多身份:各取一个长期令牌(浏览器授权)
claude-cli add personal
claude-cli                    # 自动发现,两个身份轮着用

claude-cli status             # 在跑吗、跑多久了、各身份在途多少
claude-cli ls                 # 列出身份

claude-cli start               # 启动(常驻后台,关掉终端也不死)
claude-cli stop               # 停掉它
claude-cli reset              # 重置配置(--keep-key 留住 API key)

claude-cli mode               # 看当前运行模式
claude-cli mode proxy         # 切模式,下次 start 生效

claude-cli hub <url>          # 指到你自己的 hub,成为它的算力节点
claude-cli hub <url> <token>  # 那台 hub 配了节点令牌时才要
claude-cli hub                # 看你配的是哪个
claude-cli hub off            # 撤掉你配的那个
curl http://127.0.0.1:8787/v1/messages -H "x-api-key: <横幅上那把>" \
  -H 'content-type: application/json' \
  -d '{"model":"claude-sonnet-4-5","max_tokens":256,"messages":[{"role":"user","content":"hi"}]}'

/v1/models 与 /health 不要 key——客户端得在配好 key 之前就能验证 base URL、列模型。只有 /v1/messages 鉴权。

两种运行模式

同一把订阅凭证,两条不同的路。claude-cli mode <default|proxy> 切换,下次 start 生效(不去动一个可能正在服务的进程)。

| | default(缺省) | proxy | | --- | --- | --- | | 怎么干活 | spawn 真的 claude -p 子进程,工具经本地 MCP 桥转发 | 不 spawn;自己按 Claude Code 的信封直连上游,响应逐字节回传 | | 保真度 | 受 CLI 限制:thinking 没有 signature、没有 cache_control | 客户端的 tools / tool_use / tool_result、真 max_tokens、多轮、图片、thinking、cache 原封不动穿过去 | | 要装 claude 吗 | 要——它就是干活的那个进程 | 只用来登录 | | 进程开销 | 每个在途 = 一个真实 CLI 进程(有预热池摊平启动) | 没有子进程、没有预热池 | | 账号风险 | 低——请求是官方 claude 客户端自己发出去的,和你平时手敲没有区别 | 高——信封是我们照着 Claude Code 拼的,任何一处对不上都可能被判成非常规客户端 |

先看风险再选。 default 那条路上,真正发请求的是官方 CLI 本身,上游看到的就是一个正常的 Claude Code 会话;proxy 是我们自己按 Claude Code 的样子拼请求头、metadata、system 块直连 API, 它保真度更高(原生 tool_use、多轮、图片、cache 全都穿得过去),但代价是账号风险:官方客户端 一次改版、我们没跟上,信封就对不上了,而那种偏差正是风控在看的东西。

拿不准就留 default——它慢一点、少几样能力,但那是官方客户端在替你说话。要 proxy 的原生工具调用, 就当它是一个需要自己盯着的选择:升级后留意有没有异常拒绝。

多台机器:搭一个自己的算力池

一台机器的额度有上限。把几台的额度汇成一个地址,中心侧用 claude-hub:

# 中心那台
npm i -g @guangnao/claude-hub
claude-hub start                          # 起来后横幅会打出端点地址和客户端 key

# 每台出算力的机器
claude-cli hub https://你的hub地址
claude-cli stop && claude-cli start        # 重启后接入

客户端此后只面对 hub 一个地址,请求由它按「最闲的那台」分发;某台限流或掉线会在流开始前透明换一台。 令牌是可选的——只有那台 hub 配了 HUB_NODE_TOKEN 时才在地址后面跟一个。

接入意味着这台机器在出算力:它的空闲订阅额度会被那个 hub 的使用者消费,同时它会收到派给它的请求正文。 claude-cli hub 看你配的是哪个,claude-cli hub off 随时撤掉它。

接入与否不影响本机:hub 连不上时 127.0.0.1:8787 照常服务。

配置

| 环境变量 | 缺省 | 说明 | | --- | --- | --- | | CLAUDE_CLI_IDENTITIES | 自动发现 | 不配就扫 <state>/*/token;一个都没有 → 单身份 default,沿用本机登录 | | CLAUDE_CLI_TOKEN_<ID> | —— | 该身份的长期令牌。多身份时必填,否则它们其实是同一个人 | | CLAUDE_CLI_HOST / CLAUDE_CLI_PORT | 127.0.0.1 / 8787 | 对外服务要显式改 host | | CLAUDE_CLI_API_KEY | 自动生成 | 认 x-api-key 与 Authorization: Bearer | | CLAUDE_CLI_CONCURRENCY | 5 | 每身份在途上限 | | CLAUDE_CLI_WARM | 1 | 每身份预热的进程数,0 关掉 | | CLAUDE_CLI_CLAUDE_BIN | claude | 可给绝对路径 | | CLAUDE_CLI_STATE_DIR | ~/.claude-cli | 各身份的 config / work / token | | CLAUDE_CLI_TURN_TIMEOUT_MS | 600000 | 单轮超时 | | CLAUDE_CLI_MODE | default | 运行模式,优先于 claude-cli mode 存盘的那个 |

MIT