-
Notifications
You must be signed in to change notification settings - Fork 21
Multi Account Rotator
v2.11.5 — Multi-account Claude Max rotator with launchd/systemd daemon + AI-brain heuristics, so you never blow a weekly cap during long autonomous runs. Now includes private-first account selection (v2.11.4) and Linux headless browser-auth (v2.11.5).
If you run Claude Code at scale (long-running orchestrations, autonomous overnight runs, multiple parallel sessions), you can blow your Claude Max weekly quota. The rotator:
- Stores credentials for multiple Claude Max accounts in macOS keychain.
- Polls each account's remaining quota every N minutes.
-
Before any single account hits its cap, swaps the active
Claude Code-credentialskeychain entry to the next available account. - Refuses to rotate to an account with overage billing enabled (so you don't accidentally rack up credit-card charges).
| Path | Role |
|---|---|
scripts/account-rotation/rotate.mjs |
Swaps the Claude Code-credentials keychain entry. |
scripts/account-rotation/daemon.mjs |
launchd-managed; polls usage, rotates ahead of cap. |
scripts/account-rotation/ai-brain.mjs |
Haiku-powered heuristic — picks next account based on remaining quota + usage trajectory. |
scripts/account-rotation/setup-account.mjs |
OAuth init for one account. |
scripts/account-rotation/force-rotate.sh |
Manual override. |
templates/com.claude-ops.account-rotation.plist |
launchd unit. |
skills/ops-rotate/SKILL.md |
/ops:rotate — manual rotate. |
skills/ops-rotate-setup/SKILL.md |
/ops:rotate-setup — multi-account onboarding. |
/ops:rotate-setup # interactive multi-account onboarding /ops:setup # step 3o walks through OAuth init for each account
account_rotation_enabled is opt-in (default false) — you must explicitly turn it on in /plugins settings.
The rotator refuses any account that has overage billing enabled, unless you pass --allow-extra-usage. This is intentional — accidentally rotating to an account with overage on means real credit-card charges when usage exceeds the included monthly quota.
After a swap, running Claude sessions are re-pointed at the fresh account — detached bg agents via claude respawn, live TTY sessions via a /login re-inject. Both paths run sequentially with a base gap plus random jitter so N sessions don't re-read the keychain and fire their first request onto the just-rotated account in lockstep (which would spike that account from second one). Tunables (all env-overridable; set a jitter to 0 to restore the legacy fixed cadence):
| Env | Default | Effect |
|---|---|---|
CLAUDE_RESPAWN_JITTER_MS |
5000 |
Random jitter added to the fixed 15s gap between bg-agent respawns. |
CLAUDE_SESSION_INJECT_MS |
500 |
Base gap between /login injects into reachable sessions. |
CLAUDE_SESSION_INJECT_JITTER_MS |
1000 |
Random jitter added to that base gap. |
Respawns are also hard-capped (default 4 per invocation) and skip the orchestrator, bare spares, and the rotation initiator.
| Key | Type | Default | Purpose |
|---|---|---|---|
account_rotation_enabled |
boolean | false |
Master switch (opt-in). |
account_rotation_setup_oauth_each |
boolean | true |
During /ops:setup, walk through OAuth init for every configured account that lacks a keychain token. |
When multiple accounts are eligible, rotate.mjs prefers personal/private accounts over TEAMS/org accounts (those with orgName or orgUuid set in config.json). Org accounts trigger claude.ai's organisation chooser page and may require Google Workspace push-2FA that headless browser auth cannot clear.
To use an org account despite this preference, add "preferEvenIfOrg": true to its config entry.
The browser-auth fallback now works on aarch64 and x86-64 Linux without a desktop environment:
| macOS | Linux | |
|---|---|---|
| Browser | Chrome (headed) | Brave (Tier-2; no ARM Chrome builds exist) |
| Display | native | Xvnc virtual — DISPLAY=:1, ×ばつ800 minimum |
| Auth | magic-link or Google OAuth | magic-link only |
| Inbox reads | default Gmail account |
gog --account <email> per-account |
Minimum Linux setup:
# 1. Install Brave sudo apt-get install -y brave-browser # Debian/Ubuntu # 2. Start a virtual display (1280x800 — narrower viewports break claude.ai) Xvnc :1 -geometry 1280x800 -depth 24 & export DISPLAY=:1 # 3. Register each rotation email with gog gog auth add you@example.com --services gmail
Full steps: scripts/account-rotation/README.md §Linux setup.
- Configuration — all userConfig toggles.
- Setup Wizard — step 3o (OAuth init) and 6.5d (rotator toggle).
- Notifications — push alerts via Telegram bot, ntfy, Pushover, Discord.
- OS Compatibility — Linux headless browser-auth matrix.