AndreaChiacchia/claude-hopper
claudehopper
一个 Claude Code CLI 模组,可在运行中的会话内切换多个已保存的 Claude 账户,无需再次登录,并带有用量条和页脚账户标签。
关于这个 mod
一个用于 Claude Code CLI 的模组,可在多个 Claude 账户之间切换,无需再次登录。切换发生在运行中的会话内:你的下一条消息会通过另一个账户发出,对话继续进行。
功能:
- 账户切换面板(
/account,或点击右下角的账户名称)。按 1-9 或 Enter 进行切换。 - 一览所有已保存账户的用量:5 小时和每周窗口,带有进度条、重置倒计时和进度差量。
- 记住登录状态,因此每个账户只需
/login一次。 - 在启动时和
/login前后自动保存账户。 - 当前账户在页脚显示为
⇄ <name>。
安装:仅限 Claude Code CLI,v2.1.296+ 且 Node.js 在 PATH 中。将文件夹添加到 ~/.claude/settings.json 中的 CLAUDE_CODE_PLUGIN_DIRS,或使用 claude --plugin-dir <path> 加载。目前仅限 Windows 的保管库加密(DPAPI)。MIT 许可。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add AndreaChiacchia/claude-hopper claude plugin install claudehopper
原文 / README
Claude-Hopper
A mod for the Claude Code CLI for switching between several Claude accounts without logging in again. A switch happens inside the running session: your next message goes out on the other account, and the conversation carries on.
Accounts
1: ● personal max
[email protected]
5h █░░░░ 3% 3h19m [+31%]
wk ░░░░░ 0% 6d18h
2: ○ work team
[email protected] · Acme · 2h ago
5h ░░░░░ 0% reset
wk █████ 97% 3d12h [-47%]
↵ switch r: refresh esc close
Features
- Account switcher panel (
/account, or click the account name in the bottom right). Press 1–9 or Enter to switch. - Usage at a glance for every saved account: the 5-hour and weekly windows with bar, reset countdown and pace delta (
[+n%]under an even burn rate,[-n%]over it, hidden under 5 points). - Remembers logins. Each account's tokens are kept until its refresh token expires, so
/loginis needed only once per account. - Saves accounts automatically. The account you're logged in to is saved on startup.
/loginsaves the account you're leaving before the login and the new one after it. - Current account in the footer:
⇄ <name>in the bottom-right corner, next to Claude Code's mode labels.
Install
Claude Code CLI only. The mod runs in the CLI in any terminal, including the terminals built into VS Code or JetBrains. It does not run in the Claude desktop app, the VS Code extension's chat panel, the web or mobile, because it needs to run local commands, which the mod API allows only in the CLI.
You also need Claude Code 2.1.296 or later and Node.js on PATH. The vault encryption is Windows-only for now; see Limitations.
Load it in every session by adding the folder to CLAUDE_CODE_PLUGIN_DIRS in ~/.claude/settings.json:
{
"env": {
"CLAUDE_CODE_PLUGIN_DIRS": "C:\\Users\\<you>\\projects\\mods\\claude-hopper"
}
}
Or load it for a single session with claude --plugin-dir <path to this folder>.
Usage
| Command | What it does |
|---|---|
| /account | Open the switcher panel |
| /account <name> | Switch to a saved account (same as /account switch <name>) |
| /account add [name] | Save the logged-in account, or rename it |
| /account rename <old> <new> | Rename a saved account |
| /account remove <name> | Forget a saved account |
| /account list | List saved accounts |
To add another account, run /login with it. Accounts are named after the email address; rename them with /account rename.
The helper also runs from a terminal: node bin/ch.js list, node bin/ch.js switch <name>, node bin/ch.js help.
How it works
Claude Code keeps its login in two files: the tokens in ~/.claude/.credentials.json (claudeAiOauth) and the identity in ~/.claude.json (oauthAccount). It re-reads the credentials file before each request, so replacing those two entries switches accounts without a restart.
- Vault:
~/.claudehopper/.accounts.jsonholds names, emails and plans;secrets/holds each account's tokens, encrypted with Windows DPAPI (readable only by your Windows user);usage.jsonholds the last usage reading of each account. - Token refreshes: Claude Code renews the access token and replaces the refresh token from time to time. Claude-Hopper saves the current tokens back to the vault every 10 minutes and before every switch, so the stored copy stays valid.
- Which account is active is read from a fingerprint of the token in the credentials file, not from
~/.claude.json, which a running session may rewrite with its old identity. A token it has never seen is checked with Anthropic's profile endpoint before it's stored, so tokens are never filed under the wrong account. - Usage comes from the rate-limit readings Claude Code gets with each response. An account you're not using shows its last reading and how old it is; a window whose reset time has passed shows as reset.
Limitations
- CLI only. See Install.
- All open sessions switch together. They share one credentials file, and the panel lists the other open sessions.
/statusin an already-open session may show the previous email until restart. The account actually in use is the one in the footer label.- Windows only for now. The vault is encrypted with DPAPI. On macOS Claude Code keeps its login in the Keychain, which Claude-Hopper doesn't read.
- Usage of accounts you aren't using is the last reading, not live. Usage from elsewhere (claude.ai, another machine) shows up once you switch to that account.
/logoutmay revoke the token server-side. To add an account, use/logindirectly instead of logging out first.
Development
claude plugin validate .
claude plugin test .
| Path | Contents |
|---|---|
| hooks/register.tsx | the mod: /account, the panel, the footer label, usage recording, /login hooks |
| hooks/usage.ts | usage figures: pace delta, reset countdown, bars |
| bin/ch.js | the vault helper the mod runs (Node, no dependencies) |
| types/index.d.ts | the mod's state contract |
| tests/ | tests for the usage math, the panel and the footer label |
License
MIT, see LICENSE.
