Stop losing your Claude sessions when you switch accounts.
Merge Claude Code & Cowork local history across subscription and API-routing logins — your sessions, all in one place.
简体中文 · Quick Start · How It Works · Scripts · Warning
If you switch between Claude's official subscription and third-party API routing (e.g. via ccswitch / CC Switch), you may notice that your local agent-mode sessions (Cowork) and Code-mode sessions (Claude Code) are isolated per account. Each provider login creates a different account ID under ~/Library/Application Support/Claude/, so the app only shows sessions belonging to the currently logged-in account. Your other sessions appear to "vanish" — but they are still on disk, just in a different directory.
This toolkit solves that problem by:
- Step 1 (Verify) — Safely copy one session across accounts to confirm cross-account loading works.
- Step 2 (Bidirectional Sync) — One-time sync of all historical sessions in both directions.
- Real-time Sync (Symlink) — Permanently link the session directories so new sessions automatically appear on both sides.
Scope limit: This only handles local sessions (Cowork local-agent-mode and Claude Code CLI sessions). Cloud-based web chats are stored server-side and cannot be merged locally.
- macOS (tested on macOS 14+)
- Claude Desktop app installed
bash4+ and standard Unix utilities (cp,mv,ln,find,pgrep)- You already use ccswitch or manually switch between subscription and third-party routing
- Both provider modes have generated at least one local session each (so the directory structure exists)
Claude stores local sessions at:
~/Library/Application Support/Claude/
├── local-agent-mode-sessions/
│ ├── <SUBSCRIPTION_ACCOUNT_UUID>/
│ │ └── <ORG_ID>/
│ │ └── local_xxxxxx.json
│ └── <ROUTE_ACCOUNT_UUID>/
│ └── <ORG_ID>/
│ └── local_xxxxxx.json
└── claude-code-sessions/
├── <SUBSCRIPTION_ACCOUNT_UUID>/
│ └── <ORG_ID>/
│ └── local_xxxxxx.json
└── <ROUTE_ACCOUNT_UUID>/
└── <ORG_ID>/
└── local_xxxxxx.json
To find your UUIDs, run:
ls ~/Library/Application\ Support/Claude/local-agent-mode-sessions/
ls ~/Library/Application\ Support/Claude/claude-code-sessions/You will see one or more UUID directories. The one that appears when you are on subscription mode is your subscription account; the one that appears on routing mode is your route account.
All scripts read variables from the top of each file. Open the scripts and replace the placeholder UUIDs with your actual values:
# In scripts/step1-verify.sh, scripts/step2-bidirectional.sh, scripts/realtime-symlink.sh
SUB_ACCOUNT="<YOUR_SUBSCRIPTION_ACCOUNT_UUID>"
SUB_ORG="<YOUR_SUBSCRIPTION_ORG_ID>"
RT_ACCOUNT="<YOUR_ROUTE_ACCOUNT_UUID>"
RT_ORG="<YOUR_ROUTE_ORG_ID>"Before running: Fully quit Claude Desktop (Cmd+Q). The app must not be running.
bash scripts/step1-verify.shThis will:
- Back up your entire
local-agent-mode-sessionsdirectory - Copy one session from your route account to your subscription account
- Print instructions to reopen Claude and check if the copied session appears
If the session appears and opens correctly, the sync approach works on your setup.
After confirming Step 1 works:
bash scripts/step2-bidirectional.shThis copies all historical sessions from both accounts into each other. After running, both provider modes will see the full session history.
Note: This is a one-time sync. New sessions created after this point will still be isolated to the account that created them.
For a permanent solution where new sessions are automatically shared:
bash scripts/realtime-symlink.shThis replaces the route-account's org directories with symbolic links pointing to the subscription account's directories. From then on, both accounts read and write the same session data.
Claude Desktop isolates sessions by account UUID:
local-agent-mode-sessions/<ACCOUNT_UUID>/<ORG_ID>/local_*.json
When you log in with different providers, the account UUID changes, so the app looks in a different subdirectory and your previous sessions are "invisible."
Local session files (local_*.json) do not contain cryptographic ownership checks. The account UUID only appears inside path snapshots (e.g. cwd). This means a session file moved from one account directory to another will generally load correctly, because the app relies on directory structure for ownership, not file contents.
| Strategy | Persistence | Safety | Use Case |
|---|---|---|---|
| Step 1 Verify | One-time copy | Safest (1 file, full backup) | Confirm feasibility |
| Step 2 Bidirectional | One-time copy | Safe (full backup) | Migrate history |
| Real-time Symlink | Permanent | Medium (backup + symlink) | Ongoing dual-mode use |
Minimum viable test. Copies a single session from route → subscription. Includes full backup and printed rollback command.
Requires editing: SUB_ACCOUNT, SUB_ORG, RT_ACCOUNT, RT_ORG at the top of the file.
One-time bidirectional sync of all existing sessions. Copies route → subscription and subscription → route. Safe, non-destructive (skips existing files).
Requires editing: Same UUIDs as Step 1.
Permanent solution using symbolic links. Merges existing files first, then replaces route-account directories with symlinks to subscription-account directories.
Requires editing:
CODE_TRUTH— path to your subscription account's Code sessionsWORK_TRUTH— path to your subscription account's Cowork sessionsCODE_LINKS— array of route-account Code session paths to replace with symlinksWORK_LINKS— array of route-account Cowork session paths to replace with symlinks
An earlier attempt that assumed routing mode used a separate Claude-3p data directory. This premise was incorrect for modern ccswitch. Kept for reference only.
Every script prints an exact rollback command at the end. General pattern:
# If you used step1 or step2
rm -rf "$HOME/Library/Application Support/Claude/local-agent-mode-sessions"
mv "$HOME/Library/Application Support/Claude/local-agent-mode-sessions.backup-<TIMESTAMP>" \
"$HOME/Library/Application Support/Claude/local-agent-mode-sessions"
# If you used realtime symlink
rm -rf "$HOME/Library/Application Support/Claude/claude-code-sessions"
mv "$HOME/Library/Application Support/Claude/claude-code-sessions.bak-<TIMESTAMP>" \
"$HOME/Library/Application Support/Claude/claude-code-sessions"Always fully quit Claude Desktop before rolling back.
- Quit Claude first. All scripts check for
Claude.appand refuse to run if it is active. Concurrent reads/writes may corrupt session data. - Backups are automatic. Each script creates a timestamped backup, but if you have gigabytes of session data, backups will take time and disk space.
- Symlinks are permanent. The real-time symlink script modifies your Claude data directory structure. If you later uninstall ccswitch or change provider configurations, you may need to manually rebuild the directory tree.
- Session metadata is not sanitized. When you open a cross-account session, the
cwdandusernamefields inside the JSON still reflect the original account. In practice this does not prevent loading, but be aware the metadata is not "translated." - No warranty. These scripts operate on your personal application data. Review the code before running. The authors are not responsible for lost sessions.
Q: Will this sync my cloud chat history? A: No. Only local agent-mode (Cowork) and Claude Code sessions are stored locally. Regular web chats live on Anthropic's servers.
Q: Can I use this on Windows?
A: Not directly. The scripts use macOS-specific paths (~/Library/Application Support). Windows stores Claude data in %APPDATA%\Claude. You could port the logic but the paths and symlink behavior differ.
Q: What happens if Anthropic changes the directory structure? A: These scripts target the current structure as of mid-2026. If Claude Desktop changes its on-disk layout, the scripts may need updates.
Q: I see claude-code-sessions and local-agent-mode-sessions. Which is which?
A: claude-code-sessions = Code tab (terminal agent, workspace-enabled). local-agent-mode-sessions = Cowork tab (local agent with chat UI).
MIT