Run any number of Claude Code subscription logins side by side, switch between them, and auto-rotate to a healthy account when one hits its usage cap. Plus a one-line terminal statusline that shows which account you're on.
Files in this gist:
β the CLI: hold N subscription logins, switch/rotate between them.claude-account
β cron probe that auto-switches when the active account is capped.claude-limit-watchdog
β bash/zsh tab-completion for the CLI.claude-account.completion.sh
- Companion statusline (separate gist): https://gist.github.com/kwadwoadu/c8278b2dc005797af6034343c1b2afa5
Claude Code (Linux) stores its login as a single plaintext OAuth file at
~/.claude/.credentials.json
, and there's no built-in multi-account support.
- Conversations are
not in that file. They live locally in
~/.claude/projects/<cwd>/*.jsonl
, independent of the account. Switching accounts leaves every conversation in place β there is nothing to "port" on one machine. - So multi-account = keep named copies of the credentials file and swap which one is live.
claude-account status # or: list -- shows active slot + [capped Nm ago] marks
claude-account save <Name> # store the current live login into a named slot
claude-account switch <Name> # or: use -- make that slot live
claude-account next # rotate to the next slot (works for any number of slots)
claude-account pin # auto-switch: hold the current account
claude-account unpin # resume auto-switch
claude-account --help | --version
First-time setup (repeat save
for each account):
install -m 755 claude-account ~/.claude/bin/claude-account # ~/.claude/bin on PATH
Tab-completion (subcommands + your account names):
install -m 644 claude-account.completion.sh ~/.claude/bin/claude-account.completion.sh
echo '[ -f ~/.claude/bin/claude-account.completion.sh ] && source ~/.claude/bin/claude-account.completion.sh' >> ~/.bashrc # and/or ~/.zshrc
install -m 755 claude-limit-watchdog ~/.claude/bin/claude-limit-watchdog
crontab -e # add:
*/10 * * * * ~/.claude/bin/claude-limit-watchdog
Every 10 minutes it probes the active account with a tiny Fable call (caps are
per-model, so a cheaper model would falsely read "healthy"). On a cap it marks that
slot and rotates to the next non-capped one; it only declares all accounts capped
(the both-hot
flag) when every slot carries a fresh cap mark β never guessed from a timer. The mark clears the instant an account probes healthy again.
every 10 min ββΆ probe ACTIVE account
β
βββββββββββββΌββββββββββββββ
healthy capped error
β β β
clear marks mark it, log, wait
clear both-hot rotate ββΆ next NON-capped slot βββΆ switch (verify next tick)
β
none left? ββΆ raise both-hot flag (all subs exhausted)
Test it without burning quota: WATCHDOG_FAKE_PROBE=ok|capped|error claude-limit-watchdog
.
Pinning (manual hold). claude-account pin
s the watchdog on the current account
so it won't rotate you off, even if that account is capped; claude-account unpin
resumes.
The pin follows your deliberate switch
/use
/next
moves so it never points at the wrong account. While pinned the watchdog does nothing at all (no probe, no rotation).
- A
running session keeps its OAuth token in memory, so a switch only helpsnew or restarted sessions.
claude --resume
after a cap picks up the switched account with context intact. - After any manual
/login
, runclaude-account save <Name>
or the slot drifts stale. - Slot files are
chmod 600
, the slots dir ischmod 700
β these are live credentials. The scripts copy credential files; they never print secrets. - Paths are overridable:
CLAUDE_ACCOUNTS_DIR
,CLAUDE_CREDENTIALS
,CLAUDE_ACCOUNT_BIN
.