Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

claude-code-switch

Hop between your own Claude desktop accounts on macOS — and keep your whole session list. 🪄

Switching accounts in the Claude desktop app wipes the sidebar, so it looks like every conversation just disappeared. Good news: they're all still there. This little script brings the list right back.

🙅 Unofficial — not affiliated with or endorsed by Anthropic. It's a community workaround that simply relinks the desktop app's local session-index files. Please use it only with your own, legitimate account(s) and within Anthropic's Terms of Service and Usage Policies. How you use it is on you. 🙂

What's going on?

Log out of the Claude desktop app and... your whole sidebar of sessions vanishes. Scary — but your conversations are safe and sound. Here's the trick: the actual transcripts live on disk and don't care which account you're on. The sidebar only reads tiny "pointer" files from a folder named after your account. So after you switch accounts, you just point the new account's folder at the old one (a symlink) and — poof — your list is back.

And it's not just us noticing: this was reported upstream and closed as not planned (see Sources below).

Theo warning that desktop multi-account is not viable today, with an Anthropic engineer replying that a fix is planned

Why this exists: @theo flagged that desktop multi-account just isn't workable today — you have to hard-log-out and lose your session list — and an Anthropic engineer chimed in that a fix is on the way. Until then, this script gets your list back. 🙂

Where things stand (June 2026)

Treat this as a friendly, temporary patch. Anthropic folks have publicly acknowledged that desktop multi-account is frustrating right now and hinted that a fix may land soon — so after a Claude Desktop update, re-test this, and once the app handles it natively, you can happily retire the script.

How the app stores your sessions (macOS)

A quick map, in case you're curious how the magic works:

What Where Tied to your account?
Your conversations (JSONL transcripts) ~/.claude/projects/<project>/<session-uuid>.jsonl ❌ shared across accounts
Sidebar entries (title, cwd, model, pointer) …/Application Support/Claude/claude-code-sessions/<ACCOUNT_UUID>/<ORG_UUID>/local_*.json ✅ one folder per account
Agent-mode sessions …/Application Support/Claude/local-agent-mode-sessions/<ACCOUNT_UUID>/<ORG_UUID>/
Pin order / UI state Electron localStorage (cleared on logout) ✅ lost on logout (just cosmetic)

Since each pointer file links to a transcript in ~/.claude/projects/, relinking that one folder is all it takes for the old list to show up again once you log in.

What you'll need

  • A Mac with the Claude desktop app. The script leans on macOS-only bits (stock /bin/bash 3.2, lsappinfo, BSD stat), so it's not meant for Linux or Windows.
  • python3 — used only to read/write Claude's JSON settings (like the retention option). Most Macs already have it; if yours doesn't, grab Apple's Command Line Tools or any Python.

How to use it

Open Terminal (not the Claude app — the script closes it for you) and run:

chmod +x claude-code-switch.sh
./claude-code-switch.sh

You'll get a friendly menu (arrow keys / j·k / numbers, q to quit):

  • Transfer — backs everything up, walks you through the log out / log in, finds the new account on its own, and wires up the symlinks.
  • Retention (cleanupPeriodDays) — by default the app deletes sessions older than 30 days; bump this up so your history sticks around.
  • Rollback — put your session indexes back from a backup.
  • Language — English or Polish (it guesses from LANG; force it with CCSWITCH_LANG=pl).

Something feels off? Roll back any time:

./claude-code-switch.sh rollback ~/claude-backup-<date>

Coming back, and adding more accounts

After the first switch, both accounts share one real session-list folder (the old account is the "home base"; the others point to it with a symlink). Coming back to the old account? Just log in — nothing else to do. Adding a third (or fourth...) account? Run the script again — it follows symlinks down to the real folder, so you never end up with messy chains. And if an account already has its own sessions, the script offers to merge them instead of sharing.

Is it safe?

Short answer: yes, and it's careful about it.

  • 💾 It backs up first, every single time (~/claude-backup-<timestamp>: the session dirs + ~/.claude + ~/.claude.json). If the backup fails, it stops before touching anything.
  • 🛟 Your conversations are never on the line — they live in ~/.claude/projects/. Worst case the sidebar looks empty, and a rollback fixes it.
  • 🔐 One heads-up: backups contain credentials (~/.claude.json holds OAuth tokens). They're saved in your home folder and git-ignored here — never commit a backup.
  • ✋ It doesn't automate Claude, scrape anything, bypass login, share credentials, or dodge limits. It only edits local file pointers after you log in to your own account.

Good to know

  • 🧪 It's an unofficial hack. The app's file layout could shift in a future update; if it does, the worst case is an empty sidebar (your data stays put). Tested against desktop-app core 2.1.17x.
  • Picking up a long old session on a freshly-logged-in account resends the whole context uncached on the first turn — slower and pricier. For long chats, /export and start fresh from a checkpoint.
  • ☁️ Cloud sessions (Cowork / claude.ai) live on Anthropic's servers, so this only touches local Code-mode sessions.
  • 📜 Terms of Service. This is a convenience for your own legitimate account(s). Please don't use it to share accounts, reach data that isn't yours, or get around subscription/usage limits. Whether you may run multiple accounts — and any usage limits — are governed by Anthropic's terms, so check and follow them.

Prefer not to touch the desktop app?

Totally fair — here are some alternatives:

  • CLAUDE_CONFIG_DIR — a fully separate CLI account: alias claude2='CLAUDE_CONFIG_DIR="$HOME/.claude-acct2" claude'
  • claude-swap — swaps CLI OAuth tokens
  • Just open a second claude.ai in another browser or incognito window

Knobs (environment variables)

CCSWITCH_SUPPORT_DIR, CCSWITCH_CLAUDE_DIR, CCSWITCH_CLAUDE_JSON, CCSWITCH_BACKUP_ROOT, CCSWITCH_LANG, CCSWITCH_UI (auto/arrows/plain), CCSWITCH_TEST_MODE.

License

MIT — see LICENSE. Use it, fork it, make it better. 🙌

Credits & sources

Discussion under the thread: someone asks whether you could swap the keychain token; Theo replies the threads are served over API, so that alone would not work

Why relink instead of swapping tokens? Someone suggested a keychain-token swapper, but as Theo pointed out, the threads ride partly over the API — so a token swap alone wouldn't bring them back. Relinking the local index is what actually does the trick for Code-mode sessions.

About

Keep your Claude desktop session list when switching accounts on macOS (unofficial)

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages