Skip to main content

claude-swap: Switch Between Multiple Claude Code Accounts Without Logging Out (2026 Guide)

claude-swap is an open-source CLI that switches Claude Code accounts in seconds — no browser re-login. How it works, how to use it, and what it misses.

12 min read
claude-swap cover showing the four-step flow of switching Claude Code accounts: add account, switch, restore credentials, restart

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.

CLAUDE-SWAP AT A GLANCE

Python 3.12+

Runtime

install via uv or pipx

CLI + VS Code

Works with

Claude Code, both surfaces

OS-native

Credential storage

Keychain / Cred Manager

MIT

License

community project

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 oauthAccount block 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 --switch rotates 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:

  1. /logout out of the current account.
  2. Re-authenticate the second account through a browser OAuth redirect.
  3. 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.

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.

Diagram showing claude-swap's switch flow: add account, back up tokens to a vault, run cswap switch, restore credentials and config to the live store, then restart Claude Code

Where the credentials live

The live store is platform-specific, and claude-swap respects each platform’s conventions:

Diagram showing where Claude Code credentials live per platform — macOS Keychain, Linux/WSL plaintext file, Windows Credential Manager — and the claude-swap backup vault holding per-account slots

  • 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 oauthAccount section 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.

~/.local/share/claude-swap/ (backup vault)

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

WHAT HAPPENS ON cswap --switch

A switch is a transactional credential swap, not a session change. That transactional design is what keeps a half-finished switch from leaving you logged into nobody.

  1. STEP 01

    Back up the current account

    Before touching anything, it snapshots the live credentials and config of whoever is active right now into that account’s slot.

  2. STEP 02

    Load the target account

    It reads the target slot’s stored tokens and the saved oauthAccount block for that account.

  3. STEP 03

    Write into the live store

    It writes the target credentials back to the Keychain / Credential Manager / .credentials.json and patches the oauth section of ~/.claude/.claude.json.

  4. STEP 04

    Commit or roll back

    A SwitchTransaction records each completed step. If anything fails mid-swap, it restores the original credentials so you are never left in a broken state.

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)

Command reference

CommandWhat it does
--add-accountRegister the currently logged-in account into a slot
--switchRotate to the next account in sequence
--switch-to N|emailActivate a specific account by slot number or email
--listList accounts with usage metrics and reset times
--statusShow the active account
--remove-account N|emailUnregister an account
--add-token TOKEN|-Register via raw OAuth setup token (headless)
--export / --import PATHBack up or migrate accounts as a .cswap file
--tuiInteractive keyboard-driven menu
--purgeErase all claude-swap data

When To Use It (and When Not To)

DOES CLAUDE-SWAP FIT YOUR WORKFLOW?

The tool is a great fit for a specific kind of pain. Match your situation to one of these before you install it.

Use this to skip to what matters

POWER USERS

You hit limits mid-session, daily

You run long Claude Code sessions and routinely tap out one account before the work is done.

Focus on

Instant cswap --switchNo browser re-loginKeep your flow

OutcomeYou rotate accounts in seconds instead of losing minutes to OAuth.

CONSULTANTS + TEAMS

You juggle personal vs client billing

Different accounts map to different billing buckets and you switch contexts often.

Focus on

Per-account slotsSwitch by emailClean separation

OutcomeYou stop mixing up which account is billing which project.

PLATFORM + CI

You provision headless machines

You set up Claude Code on servers or fresh laptops without a browser handy.

Focus on

--add-tokenexport / importReproducible setup

OutcomeYou script account setup instead of doing it by hand each time.

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.

THE GAPS WORTH KNOWING

NO AUTO-ROTATION

It won’t switch for you when a limit hits

There is no daemon watching usage that flips accounts automatically. You notice the limit, then run --switch yourself.

RESTART REQUIRED

No live, in-session swap

Because Claude Code reads credentials at startup, every switch needs a CLI restart or a VS Code tab reload. There is no hot-swap mid-prompt.

MANUAL TOKEN REFRESH

Expired accounts need a re-add

When a slot’s token expires you re-run --add-account for it. There is no fully automatic background refresh of every stored account.

SINGLE-USER SCOPE

Not a team credential manager

It manages your accounts on your machine. It is not a shared vault, SSO bridge, or org-wide seat manager.

COUPLED TO INTERNALS

Tied to Claude Code’s storage format

It depends on where and how Claude Code stores credentials today. An Anthropic change to that layout could break swaps until the tool catches up.

SECURITY SURFACE

It centralizes your tokens

On Linux/WSL the live store is plaintext, and exports carry real tokens. Convenience comes with a bigger blast radius if your machine is compromised.

💡 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 --list usage data and rotates on its own would close the loop.

Best Practices

GET THE MOST OUT OF CLAUDE-SWAP

Track progress as you work through the list

0%

0/7 done

How It Compares To The Alternatives

ApproachSwitch speedKeeps you logged in?Best for
Native /logout + re-loginSlow (browser OAuth)No — full re-authOccasional switches
claude-swapSeconds (one command)Yes — all accounts stay registeredFrequent switching
Separate OS users / profilesSlow (context switch)Yes, but isolatedHard separation, rare switching

FAQ

Questions readers usually have

The recurring questions are about what it actually does, whether it's safe, and how it differs from just logging out.

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


Written for umesh-malik.com — no-fluff technical writing on AI, Web Dev, and Engineering.

Share this article:
X LinkedIn

Written by Umesh Malik

AI Engineer & Software Developer. Building GenAI applications, LLM-powered products, and scalable systems.