Multi-account switcher for Claude Code
Project description
claude-swap
Multi-account switcher for Claude Code. Easily switch between multiple Claude accounts without logging out. Works with both the Claude Code CLI and the VS Code extension.
Installation
Using uv (recommended)
uv tool install claude-swap
Using pipx
pipx install claude-swap
From source
git clone https://github.com/realiti4/claude-swap.git
cd claude-swap
uv sync
uv run cswap --help
Updating
cswap --upgrade # uv/pipx installs on macOS/Linux: auto-detects and upgrades
# or run your installer directly:
uv tool upgrade claude-swap
pipx upgrade claude-swap
Usage
Add your first account
Log into Claude Code with your first account, then:
cswap --add-account
Add more accounts
Log in with another account, then:
cswap --add-account
Switch accounts
Rotate to the next account:
cswap --switch
Or switch to a specific account:
cswap --switch-to 2
cswap --switch-to user@example.com
Note: You usually don't need to restart — on Linux/Windows 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 for the per-platform details.
Refresh expired tokens
If an account's token expires, log back into Claude Code with that account and re-run:
cswap --add-account
This will update the stored credentials without creating a duplicate.
Other commands
cswap --list # Show all accounts with 5h/7d usage and reset times
cswap --status # Show current account
cswap --add-account --slot 3 # Add account to a specific slot (prompts before overwrite)
cswap --remove-account 2 # Remove an account
cswap --tui # Launch the interactive arrow-key menu
cswap --upgrade # Upgrade claude-swap to the latest version
cswap --purge # Remove all claude-swap data
Tips
- 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.
- Continuing sessions after switching: You can keep using the same Claude Code session after switching — run
cswap --switchin 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--resumeto pick your previous session. Either way, the first message on the new account may use extra usage as its conversation cache rebuilds.
How it works
- Backs up OAuth tokens and config when you add an account
- Swaps credentials when you switch accounts
- Account credentials stored securely using platform-appropriate methods
Data locations
| Platform | Credentials | Config backups |
|---|---|---|
| Windows | File-based (inside the backup directory, under credentials/) |
~/.claude-swap-backup/ |
| macOS | macOS Keychain | ~/.claude-swap-backup/ |
| Linux / WSL | File-based (inside the backup directory, under credentials/) |
${XDG_DATA_HOME:-~/.local/share}/claude-swap/ |
On Linux/WSL, set XDG_DATA_HOME to override the default location. Data from older installs under ~/.claude-swap-backup/ is migrated automatically on first run.
Advanced
Backup and migration
Move account data between machines or back it up:
cswap --export backup.cswap # All accounts to a file
cswap --export backup.cswap --account 2 # One account
cswap --export backup.cswap --full # Include full local ~/.claude.json (same-PC backup)
cswap --import backup.cswap # Skips accounts that already exist
cswap --import backup.cswap --force # Overwrite existing
The export file is plaintext JSON. If you need encryption, pipe through your tool of choice (e.g. cswap --export - | gpg -c > backup.gpg).
Add an account from a raw OAuth token
If you only have a long-lived setup-token (e.g., produced by claude setup-token)
and you don't want to log in via the browser flow first — useful on headless
servers or when receiving a token from another machine — register it directly:
cswap --add-token sk-ant-oat01-...
cswap --add-token sk-ant-oat01-... --slot 3
cswap --add-token - --slot 3 # read token from stdin
cswap --add-token --email user@example.com # optional label override
--email is optional; omitted values use setup-token-{slot}@token.local.
No Anthropic API calls are made.
Uninstall
Remove all data:
cswap --purge
Then uninstall the tool:
uv tool uninstall claude-swap
# or
pipx uninstall claude-swap
Requirements
- Python 3.12+
- Claude Code installed and logged in
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_swap-0.12.0.tar.gz.
File metadata
- Download URL: claude_swap-0.12.0.tar.gz
- Upload date:
- Size: 113.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97992f290081ede117906bfad530dda27c1e201364de7513c7405b70acf56a4c
|
|
| MD5 |
2ba8db1c1493208cc399deb6912fd4b8
|
|
| BLAKE2b-256 |
c419c1e0d9cbec4b22456fd897f0a38e9cda4c55470dd30866a63df88f980b57
|
Provenance
The following attestation bundles were made for claude_swap-0.12.0.tar.gz:
Publisher:
publish.yml on realiti4/claude-swap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_swap-0.12.0.tar.gz -
Subject digest:
97992f290081ede117906bfad530dda27c1e201364de7513c7405b70acf56a4c - Sigstore transparency entry: 1800719786
- Sigstore integration time:
-
Permalink:
realiti4/claude-swap@b5aeaad2fd63ae2a23b1a533e6b512261aad503c -
Branch / Tag:
refs/tags/v0.12.0 - Owner: https://github.com/realiti4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b5aeaad2fd63ae2a23b1a533e6b512261aad503c -
Trigger Event:
release
-
Statement type:
File details
Details for the file claude_swap-0.12.0-py3-none-any.whl.
File metadata
- Download URL: claude_swap-0.12.0-py3-none-any.whl
- Upload date:
- Size: 58.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbb57afbfa9d1b71317dc9f570c1b12cc287e41d4815cb383a973af576d40984
|
|
| MD5 |
ccaffd6614e7b7a2892168af1d5e8ef7
|
|
| BLAKE2b-256 |
8259335c48d69d4de9478c50fdbda416d5ff3a4ce53ea8d0c8d83b8de467971a
|
Provenance
The following attestation bundles were made for claude_swap-0.12.0-py3-none-any.whl:
Publisher:
publish.yml on realiti4/claude-swap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_swap-0.12.0-py3-none-any.whl -
Subject digest:
cbb57afbfa9d1b71317dc9f570c1b12cc287e41d4815cb383a973af576d40984 - Sigstore transparency entry: 1800719938
- Sigstore integration time:
-
Permalink:
realiti4/claude-swap@b5aeaad2fd63ae2a23b1a533e6b512261aad503c -
Branch / Tag:
refs/tags/v0.12.0 - Owner: https://github.com/realiti4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b5aeaad2fd63ae2a23b1a533e6b512261aad503c -
Trigger Event:
release
-
Statement type: