[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-113403":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":9,"totalLinesOfCode":9,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":9,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":9,"pushedAt":33,"updatedAt":34,"readmeContent":35,"aiSummary":36,"trendingCount":16,"starSnapshotCount":16,"syncStatus":37,"lastSyncTime":38,"discoverSource":39},113403,"claude-swap","realiti4\u002Fclaude-swap","realiti4","Switch between multiple Claude Code accounts, with automatic rate-limit rotation, usage dashboard, and parallel sessions",null,"https:\u002F\u002Fgithub.com\u002Frealiti4\u002Fclaude-swap","Python",4927,532,12,54,0,21,172,195,111,107.18,false,"main",[25,26,27,28,29,30,31,32],"claude","claude-code","account-manager","account-switcher","anthropic","cli","multi-account","tui","2026-11-21 20:55:04","2026-11-23 18:30:05","\u003C!-- README rule: say what the user can do, give a minimal example, and mention only caveats that change their decision.\n     Mechanics go in docs\u002F, rationale in the PR. When behavior changes, edit the existing text instead of appending. -->\n\n# claude-swap\n\nMulti-account switcher for Claude Code. Easily switch between multiple Claude accounts without logging out, or let it switch for you before you hit a rate limit. Track usage for every account in a live dashboard, and run accounts in parallel. Works with both the Claude Code CLI and the VS Code extension.\n\n## Installation\n\n### Using uv (recommended)\n\n```bash\nuv tool install claude-swap\n```\n\n### Using pipx\n\n```bash\npipx install claude-swap\n```\n\n### From source\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Frealiti4\u002Fclaude-swap.git\ncd claude-swap\nuv sync\nuv run cswap help\n```\n\n### Updating\n\n```bash\ncswap upgrade          # uv\u002Fpipx installs on macOS\u002FLinux: auto-detects and upgrades\n# or run your installer directly:\nuv tool upgrade claude-swap\npipx upgrade claude-swap\n```\n\n## Usage\n\n### Add your first account\n\nLog into Claude Code with your first account, then:\n\n```bash\ncswap add\n```\n\n### Add more accounts\n\nLog in with another account, then:\n\n```bash\ncswap add\n```\n\nDo not run `\u002Flogout` first: current Claude Code may revoke the refresh token stored for the account you are leaving.\n\n### Switch accounts\n\nRotate to the next account:\n\n```bash\ncswap switch\n```\n\nOr switch to a specific account:\n\n```bash\ncswap switch 2\ncswap switch user@example.com\ncswap switch dev                # or by alias, once set with `cswap alias 2 dev`\n```\n\nNot sure which one? `cswap list` is the dashboard — every account's plan, 5-hour and 7-day usage and reset times at a glance:\n\n```bash\ncswap list\n```\n\nOr let claude-swap auto-pick by remaining quota — `cswap switch --strategy best` (most quota left) or `--strategy next-available` (skip rate-limited accounts).\n\n**Note:** You usually don't need to restart — on Linux\u002FWindows the new account is picked up automatically, and on macOS after the Keychain cache expires. To apply it instantly, restart Claude Code or reopen the VS Code extension tab. See [Tips](#tips) for the per-platform details.\n\n### Automatic switching\n\nLet claude-swap watch your usage and switch for you. When the active account's 5-hour or 7-day window reaches the threshold (default 90%), it switches to the account with the most quota left — before you hit the limit, and safe to run while Claude Code is working:\n\n```bash\ncswap auto                           # foreground loop, polls every 60s\ncswap auto --threshold 80            # switch earlier\ncswap auto --weekly-threshold 97     # let the weekly window run higher before switching\ncswap auto --model Fable             # also switch when the Fable weekly limit is hit\ncswap auto --strategy weekly-first   # spend the soonest-expiring weekly quota first\ncswap auto --once                    # single check-and-switch, for cron\u002Fscripts\ncswap auto --dry-run                 # log what it would do, never switch\n```\n\n\u003Cdetails>\n\u003Csummary>Strategies, per-account controls & behavior\u003C\u002Fsummary>\n\n**Strategies** (`--strategy`, or `cswap config set autoswitch.strategy`):\n\n| Strategy | Switches | Lands on |\n|---|---|---|\n| `best` (default) | when the active account reaches its threshold | the account with the most quota left |\n| `weekly-first` | same as `best` | the account whose weekly window resets soonest |\n| `consume-first` | at the threshold, and earlier whenever an account that resets sooner has room | the account whose weekly window resets soonest |\n| `priority-consume-first` | whenever a higher-tier account is usable | your highest tier (`cswap priority`), then the soonest weekly reset |\n\nThe weekly ones exist because weekly quota left unused at its reset is lost.\n\n**Per-account controls**\n\n- `cswap disable \u003Cnum|email>` holds an account out of rotation: auto-switch, bare `cswap switch`, and the `best` \u002F `next-available` strategies skip it until `cswap enable` puts it back. It keeps its login and is still a valid explicit `cswap switch \u003Cnum|email>` target.\n- `cswap threshold \u003Cnum|email> \u003Cpct>` gives one account its own switch-away line (50–99.9) in place of the global one.\n- `cswap priority \u003Cnum|email> \u003Ctier>` ranks accounts for `priority-consume-first`: higher tiers (0–1000, default 0) are used first. The other strategies ignore tiers.\n\n**Good to know**\n\n- **Thresholds are switch-away lines, not hard caps.** With nothing under its line, or the active account at its limit, auto-switch still lands somewhere rather than stall. `priority-consume-first` is the exception: it never lands on an account at or over its line, so it holds and keeps polling.\n- A cooldown (default 5 min) and a hysteresis margin stop it flip-flopping between accounts near the threshold.\n- `--weekly-threshold 97` gives the 7-day and per-model windows their own line, so the weekly budget can run higher than the 5-hour window. `--threshold`, and any per-account threshold, then governs the 5-hour window only.\n- `--model Fable` folds that model's weekly limit into the decision, for when you hit a per-model limit before the account-wide ones. Names are the per-model rows in `cswap list` (e.g. `Fable: 100%`), matched case-insensitively.\n- Accounts with no 5-hour window (Ultra) are judged on their 7-day and `--model` windows alone.\n- If a usage check fails it keeps using the last-known numbers for a limited time while it retries, and an expired token on an idle machine makes it hold rather than fail over.\n- An account whose refresh token has died is quarantined and reported until you [re-add it](#refresh-expired-tokens).\n- API-key accounts are never rotated onto unless you pass `--include-api-key-accounts`.\n\nFor cron\u002Fsystemd timers, `--once` reports the outcome in its exit code (`0` switched, `1` error, `2` nothing to do, `3` blocked — no viable target), and `--json` emits one JSON event per line:\n\n```bash\n*\u002F5 * * * * cswap auto --once --json >> ~\u002F.cswap-auto.log 2>&1\n```\n\nDefaults like the threshold and cooldown are configurable with `cswap config set autoswitch.threshold 80` — flags override them (see [Configuration](#configuration)).\n\n\u003C\u002Fdetails>\n\nThe exact rules (margins, landing, polling cadence, tier handling) are in [docs\u002Fauto-switch.md](https:\u002F\u002Fgithub.com\u002Frealiti4\u002Fclaude-swap\u002Fblob\u002Fmain\u002Fdocs\u002Fauto-switch.md).\n\n### Run multiple accounts at the same time (session mode)\n\nLaunch Claude Code as a specific account in the current terminal only — every other terminal and the VS Code extension stay on your default account, so two accounts can work in parallel.\n\n```bash\ncswap run 2                     # launch Claude Code as account 2, here only\ncswap run user@example.com      # by email\ncswap run 2 -- --resume         # everything after '--' is forwarded to claude\ncswap run 2 --no-share-history  # keep this account's chat history to itself\n```\n\nSessions use your normal `~\u002F.claude` setup (settings, CLAUDE.md, skills, MCP servers, etc.) and share its chat history, so a conversation started under one account shows up in `--resume` under the others.\n\n\u003Cdetails>\n\u003Csummary>How it behaves — chat history, MCP servers, tokens\u003C\u002Fsummary>\n\n- **Chat history.** Shared by default: every account reads and writes the history in `~\u002F.claude`. History an account kept on its own before is merged in on its next launch, and nothing already saved is lost (a file that differs on both sides is kept aside in `history-conflicts\u002F` in the backup directory). `cswap config set run.shareHistory false` gives each account its own history; `--no-share-history` does it for one launch.\n- **On Windows**, conversations are shared through a directory junction, which needs no special rights; the prompt-history file (`history.jsonl`) is shared only when Windows lets cswap create a symlink (Developer Mode, or an elevated terminal) and otherwise stays per-account.\n- **MCP servers.** User-scope MCP servers (`claude mcp add -s user`) are mirrored from your default profile on every launch — manage them there; changes made inside a session don't persist. Definitions are copied as-is (including inline `env`\u002F`headers` values), but MCP OAuth logins are not — HTTP servers may ask you to authenticate once per profile via `\u002Fmcp`.\n- `--no-share` stops sharing your `~\u002F.claude` setup (settings, skills, etc.) and removes the mirrored MCP config (profiles that never mirrored are left alone). Chat history is separate: it stays shared unless you also pass `--no-share-history`.\n- **Your default account.** Running the account that is already your default login launches plain `claude` on that login instead of a session (a second copy of the active credential would go stale). Scripts that need the isolation guaranteed can pass `--require-session`, which refuses instead. When that login holds no usable token any more (missing, or emptied by Claude Code after a failed refresh), the account launches in its session profile from its stored login instead, since plain `claude` would only stop at \"Not logged in\".\n- **Tokens.** A session refreshes its own copy of the account's token; once it exits, the credential it rotated is captured back into the account's stored backup before a switch, swap, move, or usage check uses it. While the session is still running, `cswap switch` refuses to move the default login onto its account if the stored backup has already fallen behind (activating it could only fail) — exit the session first, or pick another account.\n- **Usage.** While a session runs, its account's usage is read with the session's own credential, which cswap never refreshes. A read the server refuses shows as token expired, and isn't retried, until the session renews the credential on its next call.\n- **Scripting.** cswap writes its own launch notices to stderr, so stdout carries only what claude prints: `cswap run 2 -- -p \"…\" --output-format json | jq` works.\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>Map accounts to directories — auto-pick per repo\u003C\u002Fsummary>\n\nBind a directory to an account, and a bare `cswap run` there launches that account in session mode — e.g. work account in work repos, personal elsewhere:\n\n```bash\ncswap map 2 ~\u002Fwork\u002Fclient-app   # map a directory to account 2\ncswap map user@example.com      # map the current directory\ncswap map                       # list mappings\ncswap unmap ~\u002Fwork\u002Fclient-app   # remove one (defaults to current directory)\n\ncd ~\u002Fwork\u002Fclient-app\u002Fsrc\ncswap run                       # → account 2, session mode\n```\n\nSubfolders inherit the nearest mapped ancestor. In an unmapped directory, `cswap run` just launches plain `claude` with your default login. Mappings are per-machine (not part of `cswap export`) and are cleaned up when their account is removed.\n\n\u003C\u002Fdetails>\n\n### Interactive dashboard (TUI)\n\nRun `cswap` on its own (or `cswap tui`) for the full-screen dashboard: live usage for every account, switching, and the auto-switcher, all keyboard-driven. `cswap watch` opens it straight to the live monitor. Works on macOS, Linux, and Windows.\n\n\u003Cimg src=\"assets\u002Ftui-watch.png\" width=\"760\" alt=\"cswap watch — live 5h\u002F7d usage bars for every account, with reset times and the active account marked\">\n\n### Refresh expired tokens\n\nIf an account's token expires, log back into Claude Code with that account and re-run:\n\n```bash\ncswap add\n```\n\nThis will update the stored credentials without creating a duplicate.\n\nIf the refresh token itself has died (auto-switch quarantines and reports such an account), log in with it and re-run `cswap add --slot N`, or replace its stored credentials from a known-good export: a plain `cswap import backup.cswap` replaces dead-token slots on its own (a stale export can carry an already-superseded token).\n\n### Other commands\n\n```bash\ncswap run 2                     # Run an account in this terminal only (session mode)\ncswap auto                      # Auto-switch when nearing rate limits (see above)\ncswap config                    # Show or edit settings (see Configuration below)\ncswap list                      # Show all accounts with 5h\u002F7d usage and reset times\ncswap list --token-status       # Add source-labelled OAuth token diagnostics\ncswap status                    # Show current account\ncswap add --slot 3              # Add account to a specific slot (prompts before overwrite)\ncswap add --alias dev           # Add account and give it a short alias\ncswap remove 2                  # Remove an account\ncswap disable 2                 # Hold an account out of auto-rotation (keeps its login)\ncswap enable 2                  # Return a disabled account to rotation\ncswap threshold 2 85            # Switch away from account 2 at 85%, not the global default\ncswap threshold 2 --unset       # Return account 2 to the global default\ncswap threshold                 # Show the global default and every per-account override\ncswap priority 2 100            # Use account 2 before lower tiers (priority-consume-first strategy)\ncswap priority 2 --unset        # Return account 2 to tier 0\ncswap priority                  # Show every account's tier\ncswap alias 2 dev               # Give an account a short alias (usable anywhere NUM|EMAIL is)\ncswap alias 2 --unset           # Remove an account's alias\ncswap alias                     # List all aliases\ncswap move 2 1                  # Assign an account to a slot (relocates to an empty slot, swaps if taken)\ncswap swap 2 3                  # Exchange two accounts' slot numbers\ncswap unclaimed                 # List stashed credential entries (slot + why they were stashed)\ncswap unclaimed --purge ID      # Drop one (deletes its bytes; recover with \u002Flogin + `cswap add`)\ncswap tui                       # Interactive dashboard (also: bare `cswap`)\ncswap watch                     # Dashboard, opened on the live watch page\ncswap upgrade                   # Upgrade claude-swap to the latest version\ncswap purge                     # Remove all claude-swap data\n```\n\nThe original flag spellings (`cswap --switch`, `cswap --list`, ...) keep working.\n\n## Tips\n\n- **Do you need to restart after switching?** Usually not. On **Linux and Windows**, credentials are stored in a file and Claude Code re-reads them whenever that file changes, so the new account takes effect on your next message — no restart needed. On **macOS**, credentials live in the Keychain, which Claude Code caches for about 30 seconds; a running session picks up the switch once that cache expires. Restart Claude Code (or close and reopen the VS Code extension tab) only if you want the change to apply instantly.\n- **Continuing sessions after switching:** You can keep using the same Claude Code session after switching — run `cswap switch` in any terminal and carry on. If you'd prefer a clean start, close and reopen Claude Code (or the VS Code extension tab) and use `--resume` to pick your previous session. Either way, the first message on the new account may use extra usage as its conversation cache rebuilds.\n\n## How it works\n\n- Backs up OAuth tokens and config when you add an account\n- Swaps only the account-specific Claude login when you switch accounts;\n  live account-independent OAuth state (such as MCP server logins) is\n  preserved instead of being overwritten by a slot's older snapshot\n- Account credentials stored securely using platform-appropriate methods\n- Switches (manual and automatic) hold Claude Code's own credential locks while writing, so a swap never interleaves with a token refresh\n- Auto-switch freshens a target's token before activating it, and quarantines accounts whose refresh token has died until you [re-add them](#refresh-expired-tokens)\n- Usage numbers refresh every few minutes — faster for an account being used or close to switching, slower for idle ones — keeping cswap comfortably inside Anthropic's rate limits however many dashboards you keep open on a machine. An age note like `· 6m ago` just means the next scheduled check hasn't come yet, not that something is stuck.\n- The plan shown after each slot (`· Ultra`, `· Pro`, `· Team`) comes from your account profile and refreshes every six hours, independently of usage; a subscription that has lapsed shows as a highlighted `Free`.\n\n## Data locations\n\n| Platform | Credentials | Config backups |\n|----------|-------------|----------------|\n| Windows | File-based (inside the backup directory, under `credentials\u002F`) | `~\u002F.claude-swap-backup\u002F` |\n| macOS | macOS Keychain | `~\u002F.claude-swap-backup\u002F` |\n| Linux \u002F WSL | File-based (inside the backup directory, under `credentials\u002F`) | `${XDG_DATA_HOME:-~\u002F.local\u002Fshare}\u002Fclaude-swap\u002F` |\n\nSession-mode profiles (`cswap run`) live under the backup directory in `sessions\u002F`. Tool preferences (`settings.json`) and auto-switch state (`autoswitch_state.json` — cooldown and quarantined accounts; delete it to reset) live in the backup directory root.\n\nOn Linux\u002FWSL, set `XDG_DATA_HOME` to override the default location.\n\nThe log file, `claude-swap.log`, is in the backup directory too. Add `--debug` to a command (`cswap list --debug`) to record debug detail and print it to the terminal.\n\n## Menu bar (macOS)\n\n\u003Cdetails>\n\u003Csummary>Optional macOS menu bar app — usage at a glance, click to switch\u003C\u002Fsummary>\n\nNeeds the `menubar` extra (macOS only):\n\n```bash\nuv tool install 'claude-swap[menubar]'   # or: pipx install 'claude-swap[menubar]'\ncswap menubar\n```\n\nShows every account's 5h \u002F 7d \u002F spend usage and switches with a click (specific \u002F rotate \u002F best \u002F next-available), plus the TUI's add \u002F disable-enable \u002F remove \u002F refresh actions. `cswap menubar` hands it to launchd and returns: it keeps running after you close the terminal, comes back at login, and is restarted if it crashes. *Quit* in the menu stops it until the next login; *Settings → Start at login* turns the login start off.\n\nAuto-switching is off until you turn it on, with *Settings → Auto-switch accounts* or `cswap menubar --auto-switch`. It runs the same engine as [`cswap auto`](#automatic-switching) with the same `autoswitch.*` settings, so the menu bar and CLI stay in sync, and the menu's first row shows whether it is running, off, or stopped (click to restart) and when usage was last refreshed.\n\n```bash\ncswap menubar --service-status      # running? pid? starts at login? auto-switch on?\ncswap menubar --auto-switch         # turn auto-switch on (--no-auto-switch: off)\ncswap menubar --uninstall-service   # stop it and remove the LaunchAgent\ncswap menubar --foreground          # run attached to this terminal, for debugging\n```\n\n`cswap upgrade` restarts a running menu bar when the build changed. The wrapper app in `\u002FApplications`, file locations, environment handling and the Login Items switch are in [docs\u002Fmenubar.md](https:\u002F\u002Fgithub.com\u002Frealiti4\u002Fclaude-swap\u002Fblob\u002Fmain\u002Fdocs\u002Fmenubar.md).\n\n\u003C\u002Fdetails>\n\n## Advanced\n\n### Configuration\n\nTool preferences live in `settings.json` in the backup root; `cswap config` reads and edits it with validation, so you never have to find the file or guess valid ranges.\n\n\u003Cdetails>\n\u003Csummary>Commands & usage\u003C\u002Fsummary>\n\n```bash\ncswap config                              # list effective settings (\"(default)\" = not set)\ncswap config get autoswitch.threshold\ncswap config set autoswitch.threshold 80  # validated: rejects out-of-range values loudly\ncswap config set autoswitch.weeklyThreshold 97  # own switch line for the 7-day\u002Fper-model windows\ncswap config set autoswitch.model Fable   # per-model switching (see \"auto\"); Fable,Opus for several\ncswap config set run.shareHistory false   # each account keeps its own chat history (see \"run\")\ncswap config set updates.check false      # no daily PyPI lookup for the \"newer version\" hint\ncswap config set usage.headerProbe true   # opt in: setup-token usage via a 1-token request (see \"add-token\")\ncswap config set usage.fableProbe true    # opt in: also their Fable weekly limit, via a 1-token Fable request\ncswap config unset autoswitch.threshold   # back to the default\ncswap config path                         # where settings.json lives\n```\n\n`cswap config --help` lists every key with its valid range and default. Hand-editing the file still works — `cswap config` is just a safer front door, and it points out any key in the file that nothing reads (a typo, say). `list` and `get` take `--json` for scripting.\n\n\u003C\u002Fdetails>\n\n### Backup and migration\n\nMove account data between machines or back it up:\n\n```bash\ncswap export backup.cswap                    # All accounts to a file\ncswap export backup.cswap --account 2        # One account\ncswap export backup.cswap --full             # Include full ~\u002F.claude.json and credential object (same-PC backup)\ncswap import backup.cswap                    # Skips accounts that already exist\ncswap import backup.cswap --force            # Overwrite existing\n```\n\nThe export file is plaintext JSON and, by default, carries only each account's own login — machine-shared MCP\u002Fplugin OAuth tokens and the device token stay on the source machine (`--full` keeps everything, for same-PC backups). If you need encryption, pipe through your tool of choice (e.g. `cswap export - | gpg -c > backup.gpg`).\n\nIf an imported account is the one you're currently logged in as, activate the imported credentials with `cswap switch N --force` (a plain `switch` to the current account is a safe no-op and won't touch the import).\n\n### Share usage readings between machines\n\nMachines that hold the same accounts can end up sharing one usage-endpoint rate limit, so their polling adds up (this is the limit on how often usage can be read, not your subscription quota). `import-usage` lets one machine poll and hand its readings to the others:\n\n```bash\ncswap list --json | ssh laptop cswap import-usage - --hold 600\n```\n\n\u003Cdetails>\n\u003Csummary>How it works — matching, holds & when a hold ends\u003C\u002Fsummary>\n\nMachines share that rate limit when they share a login (moved between them with `export`\u002F`import`, so the same token is live on each), or when the account's usage requests are limited per account rather than per token.\n\nThe input is `cswap list --json` output. Each row with `usageStatus: \"ok\"` is matched to a local account by email and organization, and adopted when it is newer than the reading already stored. Its age comes from `usageAgeSeconds`, so the two machines' clocks never have to agree; a script that delays the hand-over should add the delay to that field. `--hold SECONDS` keeps every collector on the receiving machine (`list`, `status`, `auto`, the dashboard, the menu bar) from fetching those accounts for that long, and the held reading stays trusted for switch decisions meanwhile. A hold never runs past the reading's earliest window reset (per-model windows included), nor past an hour after the reading was taken. Renew it with each hand-over, or lift it early with `--hold 0`; when it lapses, the machine goes back to fetching for itself.\n\n\u003C\u002Fdetails>\n\n### JSON output for scripting\n\nAdd `--json` to `list`, `status`, or `switch` to emit a single machine-readable JSON object on stdout (human-readable notices go to stderr). Useful for scripting auto-swap and quota tracking.\n\n```bash\ncswap list --json                   # all accounts with usage\u002Fquota\ncswap status --json                 # current active account\ncswap switch --strategy best --json # switch, then report the result\ncswap switch 2 --json\n```\n\n\u003Cdetails>\n\u003Csummary>Example output\u003C\u002Fsummary>\n\n```json\n{\n  \"schemaVersion\": 1,\n  \"activeAccountNumber\": 2,\n  \"accounts\": [\n    { \"number\": 2, \"email\": \"you@example.com\", \"active\": true, \"usageStatus\": \"ok\",\n      \"usage\": { \"fiveHour\": { \"pct\": 25.0, \"resetsAt\": \"2026-06-22T23:29:59Z\" },\n                 \"sevenDay\": { \"pct\": 16.0, \"resetsAt\": \"2026-06-26T17:59:59Z\" } } }\n  ]\n}\n```\n\nEvery payload carries a `schemaVersion` (currently `1`); on a handled error stdout is `{\"schemaVersion\":1,\"error\":{...}}` with a non-zero exit code. `--switch`\u002F`--switch-to` report `{\"switched\": true|false, \"from\": …, \"to\": …, \"reason\": …}`.\n\n\u003C\u002Fdetails>\n\n`cswap auto --json` emits an event *stream* instead — one JSON object per line (`{\"schemaVersion\":1,\"event\":\"switch\",\"ts\":…, …}` with kinds like `poll`, `switch`, `no-switch`, `account-quarantined`, `all-exhausted`, `error`). The contract is additive: new kinds and fields may appear, so scripts should ignore unknown ones.\n\nEvery optional field (usage age, last-known usage, fetch errors, pace, login expiry, …) is listed in [docs\u002Fjson-output.md](https:\u002F\u002Fgithub.com\u002Frealiti4\u002Fclaude-swap\u002Fblob\u002Fmain\u002Fdocs\u002Fjson-output.md).\n\n### Add an account from a raw token or API key\n\nRegister a long-lived setup-token (from `claude setup-token`) or a Console API key (`sk-ant-api03-...` workspace key, `sk-ant-usr-...` personal key, or a service-account key) directly, without the browser login — useful on headless servers or when receiving a token from another machine. The token type is auto-detected:\n\n```bash\ncswap add-token sk-ant-oat01-...             # OAuth setup-token\ncswap add-token sk-ant-api03-...             # API key (any Console key family)\ncswap add-token sk-ant-oat01-... --slot 3\ncswap add-token - --slot 3                   # read token from stdin\ncswap add-token --email user@example.com     # optional label override\n```\n\n`--email` is optional; omitted values use `setup-token-{slot}@token.local` (or `api-key-{slot}@token.local` for API keys). No Anthropic API calls are made.\n\n\u003Cdetails>\n\u003Csummary>Limits — setup-token usage & API-key accounts\u003C\u002Fsummary>\n\n- **Setup-tokens show `usage unavailable` by default**, because the usage endpoint does not answer them (their scope is inference-only). With `cswap config set usage.headerProbe true`, cswap reads their 5h\u002F7d utilization from the rate-limit headers of a 1-output-token Haiku request instead, sent at the normal poll cadence. `cswap config set usage.fableProbe true` adds Fable's weekly window from a second 1-output-token Fable request per poll (the headers report a model's own weekly limit only on that model's responses; an account without Fable access just shows no Fable row). Once that window is used up, cswap keeps the row and sends no Fable request until it resets, so it does not keep asking a model that would refuse or bill usage credits. Each probe is a real (tiny) request on that account's subscription, which is why both are off by default.\n- **What the probe can't do.** Other per-model windows and extra-usage spend are not in those headers. A reading missing the 5h or 7d window (or a window `autoswitch.model` names; Fable's needs `usage.fableProbe`) is shown but not used for auto-switching. An account the server rejects for quota is marked as at its limit, with no further probe, until the refusal's `Retry-After` passes.\n- **API-key accounts.** Any bare `sk-ant-...` value that is not an OAuth token (`sk-ant-oat...`) registers a managed API-key account (the kind Claude Code uses after `\u002Flogin` with a key). It switches like any other account, but API keys have no subscription quota, so they show no usage and the usage-aware `switch` strategies never skip them as rate-limited. Use keys scoped to a single workspace: a multi-workspace key needs an `anthropic-workspace-id` header on every request, which Claude Code does not add for a stored key.\n\n\u003C\u002Fdetails>\n\n**Note:** Third-party providers configured through `ANTHROPIC_BASE_URL`, `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN` are not managed or switched; those exported variables stay in effect after a switch, so unset them to use the swapped account.\n\n## Documentation\n\n- [docs\u002Fauto-switch.md](https:\u002F\u002Fgithub.com\u002Frealiti4\u002Fclaude-swap\u002Fblob\u002Fmain\u002Fdocs\u002Fauto-switch.md) — the exact auto-switch rules: hysteresis margins, landing rules, per-account thresholds and tiers, polling cadence. Read it to find out why it did or didn't switch.\n- [docs\u002Fjson-output.md](https:\u002F\u002Fgithub.com\u002Frealiti4\u002Fclaude-swap\u002Fblob\u002Fmain\u002Fdocs\u002Fjson-output.md) — every field in `--json` output, including the optional ones. Read it before writing a script against `cswap list --json` or `cswap auto --json`.\n- [docs\u002Fmenubar.md](https:\u002F\u002Fgithub.com\u002Frealiti4\u002Fclaude-swap\u002Fblob\u002Fmain\u002Fdocs\u002Fmenubar.md) — how the macOS menu bar runs under launchd: start at login, the wrapper app in `\u002FApplications`, file locations, upgrades, the Login Items switch. Read it when the icon is missing or the service misbehaves.\n\n`cswap --help` and `cswap \u003Ccommand> --help` document every flag.\n\n## Uninstall\n\nRemove all data:\n\n```bash\ncswap purge\n```\n\nThen uninstall the tool:\n\n```bash\nuv tool uninstall claude-swap\n# or\npipx uninstall claude-swap\n```\n\n## Requirements\n\n- Python 3.12+\n- Claude Code installed and logged in\n\n## License\n\nMIT\n","claude-swap 是一个专为 Claude Code 设计的多账号管理工具，支持在多个 Anthropic 账户间快速切换、自动规避速率限制、实时监控各账号用量，并允许并行会话。其核心功能包括 CLI\u002FTUI 交互式账号添加与切换、基于剩余配额（5小时\u002F7天）的智能自动轮转策略、用量仪表盘及对 VS Code 插件和命令行工具的无缝兼容。适用于需要高频调用 Claude Code API 的开发者、团队协作者或拥有多个 Anthropic 订阅（如 Pro\u002FTeam）的用户，以提升连续编码与调试效率。",2,"2026-11-24 04:45:47","trending"]