Adds 'ccswitch seed [dir]' to copy CLAUDE.md, history.jsonl and projects/ (transcripts + memory) into the shared isolate dir on demand. Keeps isolate itself starting fresh; seeding stays opt-in. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ccswitch
A tiny fish plugin to switch between multiple Claude Code accounts — personal, work, different orgs — and jump straight into a session.
ccswitch work # switch to the "work" account and start claude
ccswitch personal -c # switch to "personal", launch claude with -c
ccswitch use work # just switch, don't launch
ccswitch list # see every saved profile (* = active)
How it works
An account is two things that must travel together:
- OAuth tokens — the real credential. On macOS these live in the login
Keychain (
Claude Code-credentials); on Linux/others in~/.claude/.credentials.json.ccswitchpicks the right backend per platform. - Identity — the
oauthAccountobject anduserIDinside~/.claude.json, which Claude Code validates the token against.
ccswitch save <name> snapshots both into a plain profile directory. Switching
restores the credential into the platform store and splices only oauthAccount
and userID back into ~/.claude.json (backing it up first — the rest of that
file is shared and left untouched). Because a profile is just two JSON files, it
is portable across machines and operating systems.
Install
With fisher:
fisher install mysqto/ccswitch
Requires jq.
Usage
| Command | Action |
|---|---|
ccswitch <name> [args...] |
Switch to <name>, then start claude (extra args passed through) |
ccswitch use <name> |
Switch without launching |
ccswitch add <name> |
Sign in to a new account (claude auth login) and save it as <name> |
ccswitch isolate <name> [args...] |
Run a concurrent session isolated to <name> (own credential) with memory/history shared across profiles |
ccswitch save <name> |
Save the current account as <name> |
ccswitch list / ls |
List profiles (* marks the active one) |
ccswitch current / whoami |
Show the active account |
ccswitch rm <name> |
Delete a profile |
Typical first run:
claude # log in as your first account
ccswitch save personal
claude /logout # or log out via the app, then log in as the other account
ccswitch save work
ccswitch work # from now on, switch freely
Same login, multiple orgs
If one login (e.g. a Claude Team account) belongs to several organizations,
each org is a separate profile — Claude Code issues a distinct org-scoped token
per org. Save one after switching org inside Claude Code (/login):
ccswitch save org-a # while the first org is active
# switch org in Claude Code, then:
ccswitch save org-b
ccswitch list distinguishes them by account and organization, so the same
email can appear more than once with only the active org starred.
Concurrent sessions (shared memory, separate accounts)
ccswitch <name> swaps a single machine-global account, so it is sequential —
one active account at a time. To run two accounts at once (two terminals),
use ccswitch isolate, which gives each profile its own
CLAUDE_CONFIG_DIR:
ccswitch isolate work # terminal 1 — signs in once, then reuses
ccswitch isolate personal # terminal 2 — a different account, at the same time
Each profile keeps its own credential and identity, but memory and history
are shared — isolate symlinks projects/ (session transcripts + the
memory/ files), history.jsonl, and CLAUDE.md from each profile to a common
shared/ directory. So both accounts see the same project memory and past
sessions while staying logged in as different users.
Layout (centralized under ~/.claude, override with $CCSWITCH_ISOLATE_HOME):
~/.claude/profiles/
├── shared/ # one real copy of the shared memory/history
│ ├── projects/
│ ├── history.jsonl
│ └── CLAUDE.md
├── work/ # CLAUDE_CONFIG_DIR for "work"
│ ├── projects -> ../shared/projects
│ ├── history.jsonl -> ../shared/history.jsonl
│ ├── CLAUDE.md -> ../shared/CLAUDE.md
│ ├── .claude.json # own account identity (NOT shared)
│ └── settings.json # own settings
└── personal/ # CLAUDE_CONFIG_DIR for "personal" (same shared links)
ccswitch isolate with no name lists existing isolated profiles. Existing
non-symlink files in a profile dir are left untouched (never clobbered).
shared/ starts empty — isolated profiles begin with fresh memory. To carry
your existing memory/history over, seed it once from your default ~/.claude:
ccswitch seed # copies CLAUDE.md, history.jsonl and projects/ from ~/.claude
ccswitch seed <dir> # ... or from another config dir
Re-run ccswitch seed anytime to re-sync from the source (source wins on
same-named files).
Note: this pattern relies on
CLAUDE_CONFIG_DIR(supported) plus symlinking of account-agnostic paths (a community pattern, not officially documented). Auth stays isolated; only memory/history is shared. Two sessions writing the same project's memory simultaneously can race — low risk in practice.
Profile storage
Profiles live in $CCSWITCH_HOME (default ~/.claude/accounts), one directory
per profile:
~/.claude/accounts/work/
├── credentials.json # OAuth blob
└── account.json # oauthAccount + userID
Point $CCSWITCH_HOME at a synced folder or repo to move profiles between
machines:
set -Ux CCSWITCH_HOME ~/vault/claude-accounts
⚠️ These files are secrets
credentials.json holds a live bearer token. If you sync $CCSWITCH_HOME with
git or a cloud folder, encrypt it — use a private repo with
git-crypt / age /
SOPS, or a real secret manager. Never commit
plaintext tokens to a shared or public repo.
Notes
- Quit any running
claudesession before switching — an open session can rewrite~/.claude.jsonon exit and clobber the swap.ccswitchwarns when it detects one. - Access tokens expire, but the refresh token is restored too, so Claude Code re-refreshes automatically after a switch.
- OAuth refresh tokens rotate on every use. To keep snapshots valid,
ccswitchre-captures the outgoing account into its matching profile automatically on every switch — so an account you actively use won't go stale.
License
MIT