ccode-sync
v0.4.1
Published
Sync Claude Code sessions between machines
Maintainers
Readme
ccode-sync
Sync Claude Code sessions between machines.
Claude Code stores sessions in ~/.claude/projects/ using encoded paths as folder names (/Users/me/code/app becomes -Users-me-code-app). When you switch machines, those paths don't match and sessions become orphaned.
ccode-sync exports your Claude data, rewrites all path references, and imports them on the destination machine — preserving original timestamps and merging history without duplicates.
Install
npm install -g ccode-syncUsage
Export (on source machine)
ccode-sync export
# Creates ccode-sync-<hostname>-<date>.tar.gz
ccode-sync export my-backup.tar.gz
# Custom output filenameImport (on destination machine)
ccode-sync import backup.tar.gz
# Automatically rewrites paths if home directories differ
ccode-sync import --dry-run backup.tar.gz
# Preview what would be imported without making changes
ccode-sync import --merge-settings backup.tar.gz
# Also merge settings.json (skipped by default)Path mapping
If a project lives in a different directory on each machine, use --map to remap it:
ccode-sync import backup.tar.gz --map "Projects/app:Code/app"You can pass multiple --map flags for different projects:
ccode-sync import backup.tar.gz \
--map "Projects/app:Code/app" \
--map "Sites/web:Herd/web"Paths are relative to the home directory by default. Use absolute paths if needed:
ccode-sync import backup.tar.gz --map "/opt/app:/home/me/app"What gets synced
| Data | Synced | Notes |
|------|--------|-------|
| ~/.claude/projects/ | Yes | Session conversations per project |
| ~/.claude/history.jsonl | Yes | Merged — new entries appended, no duplicates |
| ~/.claude/settings.json | Opt-in | Use --merge-settings (local values take precedence) |
| ~/.claude/sessions/ | No | Ephemeral process metadata, regenerated by Claude Code |
How path rewriting works
The export creates a manifest.json with the source machine's home directory. On import:
- Folder names are rewritten:
-Users-me-Projects-app->-Users-me-Code-app - History entries (
projectfield) are rewritten to the destination path - Session logs get a global find-replace for all mapped paths
- Timestamps are preserved from the original files
- Existing files are never overwritten — only new data is imported
Roadmap
- [x] Phase 1: Manual export/import via
.tar.gzwith path rewriting - [ ] Phase 2: Cloud sync via S3/Cloudflare R2 (
ccode-sync push/ccode-sync pull) - [ ] Phase 3: Menubar app with one-click sync
