If you use Claude Code seriously, you have hit the wall: a usage limit pops up mid-task, and the only "official" way to keep going is to /logout, open a browser, run the OAuth dance again, and pray your session state survives. Do that three times a day and it stops being a minor annoyance — it becomes a tax on your focus.
claude-swap is the open-source CLI that deletes that tax. The short answer is simple: it backs up the OAuth credentials for each of your Claude accounts and swaps them in and out of Claude Code's credential store on demand. Switching accounts goes from a 60-second browser ritual to a single command — cswap --switch.
If you searched for how to switch Claude Code accounts, using multiple Claude accounts, or getting past Claude Code rate limits without logging out, this is the practical teardown: what it is, why it exists, how it actually works under the hood, how to use it, and — just as importantly — where it falls short.
TL;DR
-
claude-swap (CLI:
cswap) lets you keep multiple Claude accounts registered and switch the active one in seconds — no logout, no repeated browser OAuth. - It works by backing up and restoring Claude Code's OAuth tokens plus the
oauthAccountblock in~/.claude/.claude.json, using OS-native secure storage (macOS Keychain, Windows Credential Manager) where available. - The killer use case is dodging usage limits: when one account taps out,
cswap --switchrotates to the next so you keep working. - It is a credential swap, not a live session multiplexer — you must restart Claude Code (or the VS Code extension tab) after switching for it to pick up the new tokens.
- It is unofficial, not an Anthropic product. Treat account-juggling as a personal-productivity tool and stay aware of your plan's terms.
What Is claude-swap?
💡 Key insight: claude-swap doesn't run multiple Claude sessions at once. It stores the credentials for several accounts and hot-swaps which one Claude Code sees as "logged in."
claude-swap is a multi-account switcher for Claude Code. You register each account once, and from then on you can rotate between them with a single command instead of logging out and back in through the browser. It works with both the Claude Code CLI and the official VS Code extension, because both read from the same credential store on your machine.
Under the surface it does exactly one clever thing well: it treats your OAuth tokens as a swappable asset. Claude Code keeps the active account's credentials in one place; claude-swap keeps a backup of every account's credentials in its own vault, and "switching" simply means copying the right backup back into the live store.
The tool installs as a Python package and exposes a cswap command. It's MIT-licensed, actively released (27+ releases by mid-2026), and built by the community — not Anthropic.
Why It Exists: The Problem It Solves
Claude Code's value is its flow. You get into a loop with the agent, it's editing files and running tests, and then — limit reached. On Pro and Max plans there are rolling session and weekly caps, and the moment you hit one, the native fix is brutal to your momentum:
-
/logoutout of the current account. - Re-authenticate the second account through a browser OAuth redirect.
- Re-establish your working context and hope nothing got lost.
People run into this constantly because having more than one Claude account is normal now, not exotic:
- A personal account and a separate work or client-billed account.
- Multiple Max subscriptions specifically to extend daily working hours.
- A team setup where different accounts map to different billing buckets.
claude-swap exists because the credentials for all those accounts are just files and keychain entries. There's no technical reason switching should require a browser round-trip — so the tool removes it. You pay the OAuth cost once per account, and every switch after that is instant.
The other escape hatch when you're genuinely out of cloud capacity is to stop depending on the cloud at all and run a capable coding model locally. But if you're committed to Claude — and most of us are, for good reason — claude-swap is the pragmatic fix that keeps you in the tool you already like.
What this is — and isn't
claude-swap is a convenience layer over accounts you already own. It is not an Anthropic product, and it does not conjure "free" capacity — every account keeps its own limits and billing. It just removes the browser round-trip between accounts that are yours to begin with.
How claude-swap Works (Under the Hood)
This is where it gets interesting, because the design is refreshingly simple. Claude Code reads its credentials from one location at startup. claude-swap intercepts the backup and restore of that location.
Where the credentials live
The live store is platform-specific, and claude-swap respects each platform's conventions:
-
macOS — the system Keychain, under the service name
Claude Code-credentials. -
Linux / WSL — a plaintext file at
~/.claude/.credentials.json. -
Windows — the Credential Manager, plus the
oauthAccountsection of~/.claude/.claude.json.
claude-swap keeps its own backups in a vault directory (~/.local/share/claude-swap/ on Linux, ~/.claude-swap-backup/ elsewhere), with one slot per account.
claude-swap/
├── credentials/
│ ├── .creds-1-you@personal.com.enc
│ └── .creds-2-you@work.com.enc
├── configs/
│ ├── .claude-config-1-you@personal.com.json
│ └── .claude-config-2-you@work.com.json
└── sequence.json # tracks slots + rotation order
The switch lifecycle
That rollback behavior is the part most "swap a config file" hacks get wrong. claude-swap treats the swap as a transaction with recorded steps (credentials_written, config_written, sequence_updated), so a failure halfway through reverts cleanly instead of stranding you.
The one thing it can't avoid: Claude Code only reads credentials at startup. After a switch, you have to restart the CLI or close and reopen the VS Code extension tab. It's the small price for the fact that nothing has to be patched live.
How To Use claude-swap
Installation
The recommended path is uv, but pipx works just as well:
# Recommended
uv tool install claude-swap
# Or with pipx
pipx install claude-swap
# From source
git clone https://github.com/realiti4/claude-swap
cd claude-swap
uv sync
Upgrades are equally boring (the good kind):
uv tool upgrade claude-swap # or: pipx upgrade claude-swap
cswap --upgrade # self-update from PyPI
Register your accounts
You add accounts one at a time. Log into the account you want to capture first (via normal Claude Code login), then register it:
# Log into account A in Claude Code, then:
cswap --add-account
# Switch the Claude Code login to account B, then:
cswap --add-account
Each --add-account captures whoever is currently logged in. When a token later expires, re-run cswap --add-account for that account — it updates the existing slot rather than creating a duplicate.
Switch, list, and check status
cswap --switch # rotate to the next account in sequence
cswap --switch-to 2 # switch to a specific slot number...
cswap --switch-to you@work.com # ...or by email
cswap --list # show accounts, usage metrics, and reset times
cswap --status # show which account is active right now
cswap --tui # interactive menu with keyboard navigation
After any switch, restart Claude Code or reopen the VS Code extension tab. That's the whole loop.
Headless and CI: register by token
On a server with no browser, you can't do interactive OAuth. claude-swap lets you register an account directly from a setup token:
cswap --add-token sk-ant-oat01-... # or pipe via stdin with: --add-token -
Move accounts between machines
Export creates a portable .cswap file; import restores it on another machine:
cswap --export backup.cswap # all accounts
cswap --export backup.cswap --account 2 # just one
cswap --import backup.cswap # restore (use --force to overwrite)
Export files contain live credentials
A.cswapexport holds real OAuth tokens. Treat it like a password file — don't commit it, don't drop it in shared storage, and delete it once the migration is done.
Command reference
When To Use It (and When Not To)
What claude-swap Still Misses
No hype here — this is a small, focused tool, and its gaps are real. If you're deciding whether to adopt it, weigh these honestly.
💡 Key insight: The biggest missing feature is automation. claude-swap makes a switch cheap, but you still have to decide to switch. A future version that watches
--listusage data and rotates on its own would close the loop.
Best Practices
How It Compares To The Alternatives
FAQ
Final Take
claude-swap is the kind of tool that shouldn't need to exist — and that's exactly why it's good. Anthropic gives you a credential store and a login flow; claude-swap notices that "switching accounts" is really just "swap two files and a keychain entry," and turns a 60-second browser ritual into one command.
It's not magic. It won't auto-rotate when you hit a limit, it makes you restart after every swap, and it centralizes real OAuth tokens on your machine — so it's a personal-productivity tool, not an enterprise credential platform. Know those edges and they won't surprise you.
But if you live in Claude Code and bounce between accounts more than once a day, the math is obvious: pay the OAuth cost once per account, then never pay it again. For a free, MIT-licensed CLI, that's a remarkably good trade.
If you found this useful, read how Anthropic Code Review fits into Claude Code next — it's the clearest signal of where the rest of the Claude Code workflow is heading, beyond the account you happen to be logged into.
Sources
- claude-swap on GitHub
- Anthropic: Claude Code
- Claude Code Docs
- uv — Python package and project manager
Written for umesh-malik.com — no-fluff technical writing on AI, Web Dev, and Engineering.
Originally published at umesh-malik.com
Keep reading on umesh-malik.com:


Top comments (0)