cdswap
cdswap lets several Claude Desktop accounts share the same Code sessions, archives and local routines, and switches the account the desktop app is signed in to without signing in again each time. It is a Python command-line tool with a full-screen terminal UI built on claude-swap (cswap), and its account numbers match cswap list. Works on macOS and Windows.
⚠️ Unofficial tool. cdswap is not affiliated with, endorsed by, or supported by Anthropic. "Claude" is a trademark of Anthropic. It relies on undocumented internal files of Claude Desktop that can change in any release. When a file does not look the way cdswap expects, it stops without writing anything instead of guessing. It backs up every file it is about to change before writing. Use it only with accounts you own and within Anthropic's terms of service. Use at your own risk.
Why
Claude Desktop stores the Code sidebar list and the local routine schedule per account. After switching accounts the sidebar looks empty, even though the conversations themselves (~/.claude/projects) are shared by every account. Once the sidebar index is filled in, any account can open and continue the same session. Switching accounts inside the app also means signing in again every time.
~/Library/Application Support/Claude/ (Windows: %APPDATA%\Claude\)
claude-code-sessions/<account>/<org>/
local_<id>.json session index entry (title, cwd, model, last activity…)
deleted_<id> the app's own deletion marker (content = deletion time in ms)
archived-sessions.idx archive list
scheduled-tasks.json local routine schedule
config.json app state, including the encrypted login cache
Local Storage/ the app's embedded web storage: sidebar groups, new-session presets
Features
- Two-way sync of Code sessions, archives, pins, titles and local routines across any number of accounts, using a three-way merge against the last synced state.
- Respects the app's own deletion markers: a session deleted in one account is deleted in all of them.
- Switches the account Claude Desktop is signed in to by swapping saved login snapshots (no re-login after the first time).
- Optional: the terminal
cswapaccount follows the app (link-cli). - Records the current account's sidebar groups and pins as a template; the
/cdswap-groupsslash command applies them in another account through the app's own sidebar tools. - Backs up before every write; any sync, switch or restore can be undone with
cdswap restore. - Full-screen UI with the same look as cswap.
- English UI by default, Traditional Chinese when the system locale is Chinese.
Requirements
- Claude Desktop on macOS or Windows. Linux is not supported (there is no Claude Desktop for Linux).
- Python 3.12 or newer.
uvandpipxfetch a suitable Python automatically. - Dependency: claude-swap (MIT), which provides the full-screen UI components. It is installed with cdswap.
- Optional: the
cswapcommand-line tool (uv tool install claude-swap). Without it cdswap still works, but accounts have no numbers andlink-clihas nothing to drive; you switch by account UUID prefix instead.
Install
uv tool install cdswap # or: pipx install cdswap
cdswap install-command # once: installs /cdswap-groups into ~/.claude/commands
From a checkout: uv tool install .
install-command honours CLAUDE_CONFIG_DIR if you set it.
Quick start
Run these in your own terminal (macOS Terminal, Windows PowerShell), not through Claude: switch, sync, restore and add quit Claude Desktop, which would also stop a Claude session that ran the command. cdswap refuses to run them against real data from inside Claude Code.
cdswap list # accounts known to the app, with cswap numbers and session counts
cdswap sync --dry-run # preview what a sync would change (the app can stay open)
cdswap sync # preview → confirm → quit app → sync → reopen app
cdswap switch 2 # switch the app to account 2
After switching, type /cdswap-groups in any Claude session in the app to apply the sidebar groups and pins.
Commands
| Command | What it does |
|---|---|
cdswap |
Full-screen UI when run in an interactive terminal; otherwise the same as cdswap list |
cdswap tui |
Open the full-screen UI explicitly |
cdswap help, -h, --help |
Show help |
cdswap --version |
Show the version |
cdswap list |
List the app's accounts: cswap number, email, account UUID prefix, session count, (current), [saved] |
cdswap status |
Show only the account the app is signed in to |
cdswap switch <number|email|uuid-prefix> |
Switch the app's signed-in account (quit app → save current login → sync → put target login in place → reopen). A UUID prefix needs at least 6 characters |
cdswap add |
Save a login snapshot of the account the app is signed in to (like cswap add) |
cdswap add --new |
Add a new account: save the current login, sign the app out locally, reopen at the sign-in screen |
cdswap sync |
Sync sessions, archives and routines; record the current account's sidebar groups as the template |
cdswap sync --dry-run |
Preview only; nothing is written and the app can stay open |
cdswap groups [--json] |
Show the group and pin template as it applies to the current account (/cdswap-groups uses --json) |
cdswap groups --applied |
Record that the current account's pins now match the template (run by /cdswap-groups) |
cdswap link-cli [on|off] |
Make the terminal cswap follow app switches; no argument shows the setting (default off) |
cdswap restore [backup-id] |
Roll back a sync or switch (default: the latest). Restore backs up first, so it can be undone too |
cdswap backups |
List backups |
cdswap install-command |
Install the /cdswap-groups slash command for Claude Code |
Options:
| Option | Meaning |
|---|---|
-y, --yes |
Do not ask for confirmation |
--no-app |
Do not quit or reopen the app; it must already be closed |
--root <dir> |
Use another claude-code-sessions directory (for testing on a copy) |
--state <dir> |
Use another state directory (default ~/.local/state/cdswap) |
Exit codes: 0 success; 1 cancelled, another cdswap is running, or a usage problem such as an unknown account or not enough disk space; 2 a file format did not match (nothing written); 3 stopped for safety (app state unknown, app could not be closed, app still open with --no-app, or run from inside Claude Code; nothing written).
Switching accounts
cdswap switch <target> quits the app, saves the current account's login snapshot, syncs, puts the target account's snapshot in place, and reopens the app.
- Login snapshot = the encrypted login entries in
config.json,cowork-enabled-cli-ops.json, the Cookies database and the claude.ai IndexedDB. cdswap only copies these files. It never decrypts them, prints them or uploads them. Snapshots live in~/.local/state/cdswap/logins/<account>/with0700permissions. - Accounts with a saved snapshot (
[saved]in the list,savedin the UI) switch without signing in. Leaving an account saves its snapshot automatically;cdswap addsaves it at any time. - First switch to an account: there is no snapshot yet, so cdswap saves the current account, signs the app out locally and reopens it at the sign-in screen. Sign in to that account once; from then on switching is direct.
- cswap's saved logins are for the terminal CLI and cannot be used by the desktop app, which uses its own OAuth token and claude.ai cookies encrypted with the app's own key. Each account has to be signed in to the app once.
- Adding a new account:
cdswap add --new(UI: Add account… → Sign in a new account…). After signing in, open the Code tab once in that account so the app records it. The next sync fills in all sessions. Also runcswap addfor it in the terminal so the numbers match; otherwise switch to it by UUID prefix, for examplecdswap switch 1a2b3c4d. - Do not use the app's own "Sign out": it tells the server to invalidate that login, so the saved snapshot stops working and you will have to sign in again (observed 2026-10-15). cdswap signs out locally by removing files, which does not invalidate the login on the server.
- Before saving a snapshot cdswap checks that the two places where the app records the current account agree; if they don't, it stops instead of saving the wrong snapshot.
- If a snapshot has expired, the app asks you to sign in again. Nothing breaks.
- Switching accounts inside the app yourself is fine; the full-screen UI re-reads the signed-in account on every poll.
Sidebar groups and pins (/cdswap-groups)
Sidebar groups and new-session presets live in the app's embedded web storage, which outside programs cannot change safely. The copy in claude_desktop_config.json is written by the app and is overwritten when the app starts (observed 2026-10-15). So:
cdswap switchandcdswap syncrecord the currently signed-in account's groups as the template.- After switching, type
/cdswap-groupsin any Claude session in the app. Claude uses the app's own sidebar tools to create missing groups and move sessions into them (archived sessions and sessions nested under a parent are skipped). Extra groups are listed and only deleted if you agree. - It also applies pins. Pins also live in the app's web layer and follow the account: after a switch the app pushes that account's old pins back into the session files. Moving a pinned session into a group also unpins it, so
/cdswap-groupsrecords the current pins first, groups the sessions, then pins the template pins plus the recorded ones. Extra pins in this account are listed and only removed if you agree. - Until
/cdswap-groupshas run in an account after a switch, that account's pin changes are not synced to other accounts (the sync report says so), so stale pins don't spread. Afterwards, pin changes in that account sync normally. - New-session presets have no app tool, so they cannot be synced; set them up in each account.
/cdswap-groups runs cdswap groups --json and cdswap groups --applied through Claude Code's Bash tool, so cdswap must be on the PATH that Claude Code sees.
Terminal follows the app (link-cli)
- Off by default. With
cdswap link-cli on(UI menu: Terminal follows app), aftercdswap switchhas switched the app it runscswap switch <same number>, as if you had run it in the terminal. If the app is already on the target account, it still aligns the terminal once. - If the target has no cswap number (not yet
cswap add-ed), it is skipped with a notice. Ifcswapfails, you get a notice; the app switch is not affected. - One direction only: the app drives the terminal. Switching the app quits it and stops every session in it, so a terminal switch must not trigger that.
- Terminal conversations are already shared with the app (
~/.claude/projects): any signed-in account can continue an app session withclaude --resume. No sync needed.
Terminal sessions in the sidebar
Claude Desktop has a built-in import: menu Troubleshooting › Import Claude Code CLI Sessions… (on macOS, if you can't find it, type "Import" in the Help menu search box). It scans ~/.claude/projects and adds terminal conversations that are not in any account's sidebar to the current account. Conversations already shown in another account, deleted ones, and ones in folders not yet trusted are skipped. After importing, the next cdswap sync or switch copies them to the other accounts.
cdswap does not import sessions itself. It reads the count the app reports in its own log ([CCD-SessionRecovery] Probe: N importable CLI transcript(s)) and reminds you in list, the sync report and the full-screen UI. Non-interactive runs such as claude -p are not covered by the app's import.
How sync works
cdswap remembers what everything looked like after the last sync (~/.local/state/cdswap/state.json) and, for each item, takes the copy that was actually changed since then.
| Item | Merge rule |
|---|---|
| Session conversation progress | Union across all accounts; the copy with the latest last-activity time wins, so an old copy never overwrites newer progress |
| Archived, pinned, title | The copy changed since the last sync (if several changed, the latest change wins); each account's archive list is rebuilt from isArchived. Pin (isStarred) changes are only trusted from an account that has run /cdswap-groups since it was switched to |
| Connector settings | remoteMcpServersConfig and enabledMcpTools belong to each account; when a copy is overwritten, the target account keeps its own values |
| Deletions | A session deleted in any account is deleted in the others and gets a deletion marker there. If it received new conversation after the deletion, cdswap leaves it alone and lists it for you to decide |
| Local routines | Merged per routine and per field; lastRunAt takes the latest value so routines don't re-run after a switch. A routine deleted in one account is deleted everywhere, but a completely emptied table is treated as an app reset and restored from the last synced version |
An account that had no sessions at the last sync cannot express deletions. Routines run in whichever account is signed in, and use that account's usage.
Safety design
- Writes only after the app has quit, and re-scans after quitting before applying.
- Before writing, every file that will be overwritten or deleted is copied to
~/.local/state/cdswap/backups/<id>/(0700). App files are touched only after the backup is complete. The latest 10 backups are kept. - Every file is written via temp file + fsync + rename. Temp files left by an interrupted run are cleaned up next time.
- If any file format does not match expectations (for example after an app update), cdswap stops and writes nothing (exit 2). If it cannot tell whether the app is running, it also stops (exit 3).
- Each account's home org is remembered after it is first determined.
- Free disk space is checked before writing.
- Refuses switch, sync, restore and add against real data when run from inside Claude Code.
- A lock prevents two cdswap processes from running at once.
Limitations
- Cloud routines and claude.ai web sessions are stored on Anthropic's servers per account; a local tool cannot sync them.
- New-session presets have no app tool and cannot be synced.
- claude.ai connectors (Gmail, Drive, Calendar…) are authorised per account on the server; connect them once in each account. Local MCP servers (user-level
~/.claude.json, a folder's.mcp.jsonor local scope, plugins) live on the machine and are already shared by every account. - Cowork (local-agent-mode) sessions are out of scope.
- Each computer syncs its own accounts only; nothing is synced between computers.
- Do not run several app instances signed in to different accounts at once; routines would run twice.
- Organization (Team/Enterprise) accounts also see your personal sessions after a sync. Continuing a conversation there uses the organization's plan; mind your company's policy.
- cdswap depends on undocumented app file formats. An app update may stop it working; it will stop rather than write something wrong.
Windows notes
The same code switches to Windows locations and behaviour automatically (based on a hardware probe, 2026-10-20):
- Locations: the app is a Squirrel install under
%LOCALAPPDATA%\AnthropicClaude; data is in%APPDATA%\Claude(sessions in%APPDATA%\Claude\claude-code-sessions); the import reminder reads%LOCALAPPDATA%\Claude\logs\main.log. - Login snapshot: Cookies are under
Network\and encrypted with the DPAPI key inLocal State.Local Stateis shared by the same Windows user on the same computer and is not swapped. - Quitting the app: cdswap sends a normal close (no force) to the app's main process only. With no session running it exits within about a second. With a Code session running the app asks for confirmation and does not exit by itself: confirm the dialog, or right-click the Claude icon in the system tray and choose Quit. cdswap waits up to 5 minutes and writes only after the app has exited. It reopens the app through its Start-menu AppID.
- Only
claude.exeunder theAnthropicClaudeinstall folder counts as the app. The terminal Claude Codeclaude.exeis never matched, so it is never closed.
Full-screen UI
cdswap in an interactive terminal opens a full-screen UI that reuses cswap's own UI code: theme, stylesheet, account cards, usage bars, account-switch screen, confirmation dialogs and usage polling. cdswap replaces the menu (Switch, Sync, Restore, Add account…, Terminal follows app, Theme, Quit), makes "● active" mark the account the app is signed in to, adds session counts, a sync-status line under the panel and a window that shows live progress while an action runs.
Keys: s switch, y sync, r restore, q quit, Ctrl+T theme.
Because it builds on claude-swap's internal components (tested with claude-swap 0.24.1 and Textual 8.2.8), a claude-swap update may change them. If the UI cannot load, cdswap falls back to the text list.
Language
The UI is English by default and Traditional Chinese when the system locale is Chinese (LC_ALL, LC_MESSAGES or LANG starting with zh; on Windows, the user's UI language). Force a language with CDSWAP_LANG=en or CDSWAP_LANG=zh-TW.
Development
python tests/test_cdswap.py # core self-test (stdlib only, temp dirs, never touches real data)
python tests/test_cdswap_tui.py # UI self-test (headless, fake data, no network); needs claude-swap installed
A test run counts only if it ends with cdswap self-test: all passed / cdswap UI self-test: all passed; exit code 0 alone is not proof.
Layout:
cdswap/cli.py core: scan, plan, apply, backups, login snapshots, commands (stdlib only)
cdswap/tui.py full-screen UI, subclassing claude-swap's Textual app
cdswap/commands/cdswap-groups.md the /cdswap-groups Claude Code slash command
tests/test_cdswap.py core self-test (stdlib)
tests/test_cdswap_tui.py UI self-test (needs claude-swap)
tools/probe_windows.py diagnostic for Windows: reports where the app keeps its data and how it runs
tools/probe_windows.py does not modify any app file and does not print credentials. It writes its report to probe-out/ next to the script. The optional --quit-test closes the app (it asks first) to check how it quits and reopens. Run on macOS, it acts as its own self-test.
Contributor and agent rules are in CLAUDE.md.
Credits
- claude-swap by realiti4 (MIT): cdswap's commands, account numbering and full-screen UI follow cswap, and the UI is built directly on its components.
- Prior art evaluated in October 2026: jeremy9682/ccd-session-sync and ANGELBERRIOS23/claude-session-sync. Neither covered two-way updates across more than two accounts, the app's own deletion markers, local routines, or account switching, so cdswap was written from scratch.
License
GPL-3.0-or-later. See LICENSE.
Project: https://github.com/HPoyisis/cdswap
Metadata
Release files for cdswap 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cdswap-0.1.0.tar.gz | 76.6 kB | With provenance | Details for cdswap-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cdswap-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cdswap-0.1.0-py3-none-any.whl |
Total release size: 128.5 kB
Release files / cdswap-0.1.0.tar.gz
| Download URL | cdswap-0.1.0.tar.gz |
|---|---|
| Size | 76.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e98c54bfd9c10a1c6c55c5602411ece3c1df4dba1a3feb13448c5a3e786adaa0
|
|
BLAKE2b-256 checksum How to use checksums |
794bcc22218ff2d10b63929ac33cb6967aaacf66ff95b2d07d0c87dbd85dd63b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / cdswap-0.1.0-py3-none-any.whl
| Download URL | cdswap-0.1.0-py3-none-any.whl |
|---|---|
| Size | 51.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d7c443e432d26577df7dc18ad8eec151fd113d29bdb14b552dd6610521e1d99
|
|
BLAKE2b-256 checksum How to use checksums |
d26ccd7ab430cb7bf7f93e1dce63531a3829011929a1074256233e8556f5d4a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for cdswap 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cdswap-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.