Skip to main content

Manually switch between multiple Claude Code accounts by swapping local credentials.

Project description

claude-account

PyPI Python versions CI License: MIT

Manually switch between multiple Claude Code accounts (e.g. a personal and a work subscription) from the terminal — without signing out and back in.

It swaps only the subscription token and account identity, leaving your MCP server auth and all project state untouched:

  • claudeAiOauth in ~/.claude/.credentials.json — the subscription token
  • oauthAccount in ~/.claude.json — the account identity

Everything else — mcpOAuth, project history, settings — is preserved. Each switch backs up your host files first.

Disclaimer. This is an unofficial, community tool. It is not affiliated with, endorsed by, or sponsored by Anthropic. "Claude" and "Anthropic" are trademarks of Anthropic, PBC. It only shuffles credential files that already live on your own machine; it talks to no Anthropic service itself. Use it to switch between accounts you personally own, manually. Don't use it to automate around usage limits.

Install

# run without installing
uvx claude-account status

# or install as a persistent tool
uv tool install claude-account
# or
pipx install claude-account

Requires the claude CLI on your PATH (only for capture) and Python 3.9+.

Quick start

Two accounts, called primary and backup:

claude-account snapshot primary   # store the account you're already on
claude-account capture  backup    # opens an isolated login for the 2nd account
claude-account swap               # flip between them

Handy shell aliases:

alias cas='claude-account swap'
alias cass='claude-account status'

Commands

Command What it does
snapshot <slot> Store the account you are already logged into (no re-login).
capture <slot> Open an isolated login booth and store another account.
status Show the active account and stored slots.
swap Toggle between the two stored slots.
use <slot> Activate a specific slot.

Slots live in ~/.claude-accounts/; host backups in ~/.claude-accounts/backups/. Paths can be overridden with CLAUDE_CRED_FILE, CLAUDE_CONFIG_FILE, and CLAUDE_ACCOUNTS_DIR.

How it works

capture logs in inside a throwaway CLAUDE_CONFIG_DIR, so your host login is never touched, then copies out just that account's claudeAiOauth + oauthAccount. swap/use do the reverse surgically: they write the target slot's claudeAiOauth into .credentials.json and its oauthAccount into .claude.json, preserving every other key. Before switching away, the current account's live tokens are saved back into its slot (Claude Code rotates refresh tokens, so stale copies would eventually stop working).

Do a switch between claude sessions — a running session holds its token in memory. Slot files contain refresh tokens; treat them as secrets (they are written 0600 and ~/.claude-accounts/ is 0700).

Development

uv run --group dev pytest -q
uv build

Releasing

Tag a version and push; CI builds and publishes to PyPI via Trusted Publishing (OIDC, no tokens):

git tag v0.1.0
git push origin v0.1.0

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_account-0.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_account-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file claude_account-0.1.0.tar.gz.

File metadata

  • Download URL: claude_account-0.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for claude_account-0.1.0.tar.gz
Algorithm Hash digest
SHA256 38f11445cd4fd3c1660dba819557f49b7edefcf9decc57e9eae0fd96e9d176b0
MD5 47d4bb35c964aaa80512be3aef12bc0e
BLAKE2b-256 618f169b4e437918302f6784e991e5b2d62390b129bccabf8befec000fc58f63

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_account-0.1.0.tar.gz:

Publisher: publish-pypi.yml on Barsoomx/claude-account

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claude_account-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: claude_account-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for claude_account-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 134c0d7a0d3d1bea9784261b7bf11a8d079886fdfdec8270142a11206c802f70
MD5 d848ea5e1601f0c58325a8d88bb48380
BLAKE2b-256 9234fd9042f0d556d07a9845fd3dbb366306e9a64c55c42df08aaf793cb29d4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_account-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on Barsoomx/claude-account

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page