Synchronize your Claude Code conversations across multiple computers using git, with optional encryption.
Claude Code stores conversations locally in ~/.claude/, which means:
- ❌ Conversations are machine-locked
- ❌ No sync between computers
- ❌ Risk of losing conversations if machine fails
- ❌ Can't easily share with team members
This tool fixes that:
- ✅ Sync conversations across all your machines
- ✅ Git-based version control
- ✅ Optional transparent encryption (git-crypt)
- ✅ Local backups with auto-cleanup
- ✅ Works with any git provider (GitHub, Bitbucket, GitLab, etc.)
git clone https://github.com/porkchop/claude-code-sync.git
cd claude-code-sync
chmod +x claude-*Add to your PATH (add this to ~/.bashrc or ~/.zshrc):
export PATH="$HOME/claude-code-sync:$PATH"-
Create a private git repository for your conversations:
GitHub:
- Go to https://github.com/new
- Name it something like
claude-conversations - Select Private
- Leave "Initialize with README" unchecked (empty repo)
- Click "Create repository"
- Copy the SSH URL:
git@github.com:username/claude-conversations.git
Bitbucket:
- Go to https://bitbucket.org/repo/create
- Name it something like
claude-conversations - Set Access level to Private
- Click "Create repository"
- Copy the SSH URL:
git@bitbucket.org:username/claude-conversations.git
GitLab:
- Go to https://gitlab.com/projects/new
- Name it something like
claude-conversations - Set Visibility to Private
- Uncheck "Initialize repository with a README"
- Click "Create project"
- Copy the SSH URL:
git@gitlab.com:username/claude-conversations.git
Note: Make sure you have SSH keys set up for your git provider. If
git clone git@github.com:...works for your other repos, you're all set. Otherwise, see your provider's SSH key documentation. -
Configure sync settings:
claude-config
-
Create your first backup (safety first!):
claude-backup
-
Initialize the repository:
claude-sync-init
-
(Optional) Enable encryption:
claude-enable-encryption
Save the encryption key to your password manager (KeePass, 1Password, etc.)
-
Exit Claude Code, then push your conversations:
claude-sync-push
⚠️ Important: Claude Code only writes conversations to disk when you exit. Always exit Claude Code before runningclaude-sync-pushto ensure you're syncing the latest state.
-
Clone this tool:
git clone https://github.com/porkchop/claude-code-sync.git cd claude-code-sync chmod +x claude-*
-
Add to PATH (same as above)
-
Configure with same remote URL:
claude-config
-
Create a backup of this machine's existing conversations:
claude-backup
-
Initialize and clone the repository:
claude-sync-init
-
If the repository is encrypted, restore your key and unlock:
claude-restore-encryption-key
This will restore your key from your password manager and unlock the repository.
-
Sync conversations to your local Claude:
claude-sync-pull
-
Exit Claude Code (if running), then add this machine's conversations:
claude-sync-push
⚠️ Important: Always exit Claude Code beforeclaude-sync-pushto capture the latest conversation state. -
Restart Claude Code to see all synced conversations
claude-sync-pull
# Then start Claude Code# Exit Claude Code first (important!)
claude-sync-push
⚠️ Critical: Claude Code only writes conversations to disk when you exit. Always:
- Exit Claude Code completely
- Run
claude-sync-push- Then switch machines or close your terminal
If you run
claude-sync-pushwhile Claude Code is still running, you won't sync your latest work!
claude-sync-status # Shows config, sync state, conversation countsclaude-config # Edit settings interactivelyConversations accumulate across all machines:
- Machine A has conversations 1, 2, 3
- Machine B has conversations 3, 4, 5 (conversation 3 updated more recently)
- After syncing: Both machines have 1, 2, 3 (B's version), 4, 5
/home/alice/projects/myapp on one machine, use the same path on others.
If you need to move a project, use claude-migrate-project to update the conversation paths (see Utilities below).
Enable transparent encryption with git-crypt. See Requirements section for installation on your platform.
First machine (enable encryption):
claude-sync-init # Initialize repo first
claude-enable-encryption # Set up encryption, generates key
claude-sync-push # Push encrypted conversationsThe script will generate an encryption key and display it in base64 format. Save this key to your password manager immediately!
On other machines:
claude-restore-encryption-key # Restore key from password manager
claude-sync-init # Clone and unlock repository
claude-sync-pull # Sync conversationsCreate backups:
claude-backup # Creates timestamped backupList backups:
claude-backup-listRestore from backup:
claude-restore <backup-name>Backups are:
- Compressed (tar.gz)
- Timestamped with machine name
- Stored locally (not synced)
- Auto-cleaned based on retention policy (default: 30 days)
Configuration uses three layers (priority: highest to lowest):
- Environment variables -
CLAUDE_SYNC_* - Local config -
.claude-sync-config.local(machine-specific, gitignored) - Shared config -
.claude-sync-config(defaults, version controlled)
CLAUDE_SYNC_REMOTE- Git remote URL (required)CLAUDE_SYNC_BRANCH- Git branch (default:main)CLAUDE_SYNC_ENCRYPTION- Enable encryption (default:false)CLAUDE_BACKUP_RETENTION_DAYS- Backup retention (default:30)CLAUDE_DATA_DIR- Claude data directory (default:~/.claude)CLAUDE_SYNC_VERBOSE- Verbose output (default:false)
See CONFIGURATION.md for detailed configuration guide.
Init (claude-sync-init):
- Clones conversations repository from remote (or initializes fresh if empty)
- Detects encryption and prompts for unlock if needed
- Prepares repository for push/pull operations
Push (claude-sync-push):
- Pulls latest from remote (avoid conflicts)
- Merges local conversations using
rsync --update - Commits and pushes to remote
Pull (claude-sync-pull):
- Pulls from remote
- Merges into
~/.claude/(preserves newer files)
Conflict Resolution:
- Same conversation UUID: Newer file wins (based on modification time)
- Different UUIDs: All conversations kept (merged)
- History: Deduplicated and merged
~/.claude/
├── projects/ → Conversation files (.jsonl)
├── file-history/ → File edit history
├── todos/ → Todo lists
└── history.jsonl → Command history
.credentials.json(never synced)- Debug files
- Local backups
- Full text of all messages
- All code discussed or generated
- File paths and project structure
- System information
Recommendations:
- ✅ Use private git repository
- ✅ Enable encryption for sensitive work
- ✅ Store encryption key in password manager (KeePass, 1Password, etc.)
- ✅ Never commit real API keys or secrets in conversations
See SECURITY.md for full security analysis and encryption guide.
All commands support --version or -v to display version information.
claude-config- Interactive configuration wizardclaude-sync-init- Initialize/clone the conversations repository
claude-sync-push- Sync local → remote (pull, merge, push)claude-sync-pull- Sync remote → localclaude-sync-status- Show status and configuration
claude-backup- Create timestamped backupclaude-backup-list- List available backupsclaude-restore <name>- Restore from backup
claude-enable-encryption- Enable git-crypt encryptionclaude-restore-encryption-key- Restore encryption key from password manager
claude-migrate-project <old-path> <new-path>- Migrate conversations when renaming/moving a project
Example: If you move a project from /home/user/old-name to /home/user/new-name:
claude-migrate-project /home/user/old-name /home/user/new-name
mv /home/user/old-name /home/user/new-nameProblem: You ran claude-sync-push but your latest conversation changes aren't showing up on other machines.
Solution: Claude Code only writes conversations to disk when you exit. Always:
- Type
/exitin Claude Code - Wait for it to fully close
- Then run
claude-sync-push
- Run
claude-sync-initbefore usingclaude-sync-pushorclaude-sync-pull
- Restore your encryption key:
claude-restore-encryption-key - Then re-run
claude-sync-initto unlock
- Restart Claude Code after
claude-sync-pull - Check permissions:
ls -la ~/.claude/projects
- Verify remote configured:
git remote -v - Check git credentials
- Ensure you have write access to repository
- Ensure you're using the correct key from your password manager
- If key was lost, you'll need to start fresh with a new encrypted repo
- Run
claude-sync-statusto see current config - Run
claude-configto reconfigure - Check
.claude-sync-config.localexists
- Bash 4.0+
- Git
- rsync
- tar, gzip
- git-crypt (optional, for encryption)
✅ Linux (Tested & Recommended)
- Ubuntu/Debian - Fully tested and working
- Fedora/RHEL/CentOS - Should work (standard bash/git/rsync)
- Arch Linux - Should work
- Pop!_OS - Should work (Ubuntu-based)
All standard Linux distributions with bash 4.0+ should work out of the box.
✅ macOS (Should Work)
- macOS 10.14+ - Should work
- Comes with bash, git, rsync by default
- May need to install git-crypt via Homebrew
- Note: Default shell is zsh, but bash scripts run fine
✅ Windows WSL (Should Work)
- WSL 1 or WSL 2 with Ubuntu/Debian - Should work
- Treats WSL as a Linux environment
- All Linux instructions apply
❌ Windows Native (Not Supported)
- Git Bash - Limited support, not recommended
- PowerShell - Not compatible (bash scripts only)
- Native Windows - Not supported
Ubuntu/Debian/Pop!_OS:
sudo apt update
sudo apt install git-cryptFedora/RHEL/CentOS:
sudo dnf install git-crypt # Fedora/RHEL 8+
# OR
sudo yum install git-crypt # CentOS/RHEL 7Arch Linux:
sudo pacman -S git-cryptmacOS:
brew install git-cryptWindows WSL:
Use the Linux distribution's package manager (usually apt for Ubuntu):
sudo apt update
sudo apt install git-cryptThis project uses Semantic Versioning. Check the version of any command:
claude-sync-push --version
claude-backup --version
# etc.See CHANGELOG.md for release history.
Contributions welcome! See CONTRIBUTING.md for detailed guidelines.
Quick summary:
- Follow existing code style
- Add
--versionsupport to new commands - Update documentation
- Test on fresh install
- Ensure scripts return to original directory
Release process:
./claude-release patch # or minor, major
# Edit CHANGELOG.md with release notes
# Push: git push origin master --tagsSee CONTRIBUTING.md for full release documentation.
MIT License - see LICENSE file
Built for the Claude Code community. Inspired by the need to work seamlessly across multiple development machines.