<h1 align="center">
<a href="https://prompts.chat">
**Sync your Claude Code conversations across all your machines**
Sign in to like and favorite skills
Sync your Claude Code conversations across all your machines
Never lose your Claude Code conversation history again.
Switch between your laptop, desktop, and work computer seamlessly.
When you use Claude Code (the CLI tool from Anthropic), all your conversations are saved locally on your computer in a hidden folder called
~/.claude/projects/.
The Problem: If you switch to a different computer, all those conversations are gone. You can't continue where you left off.
The Solution: This guide shows you how to sync your Claude Code history to GitHub (or your own server) so you can access it from any machine.
| Benefit | Description |
|---|---|
| Continue Anywhere | Start a conversation on your laptop, continue on your desktop |
| Automatic Backup | Never lose your valuable AI coding sessions |
| Version History | Git tracks every change, so you can go back in time |
| Your Data, Your Control | Uses your private GitHub repo - nobody else can see it |
| Simple Commands | Just two commands: and |
Your Computer GitHub (Private Repo) | | | ~/claude-sync.sh push --------> | | | | <-------- ~/claude-sync.sh pull | | |
That's it! Two commands to stay in sync.
You need these things set up first:
| Requirement | How to Check | What It Is |
|---|---|---|
| Git | Type | A tool for tracking file changes |
| SSH Key | Type | A secure way to connect to GitHub |
| GitHub Account | Go to github.com | Where your history will be stored |
Don't have these? No problem! Follow the setup guide below for your operating system.
Open Terminal (press
Cmd + Space, type "Terminal", press Enter).
Install Git:
# Check if you have Git git --version # If you see "command not found", install it: xcode-select --install
Create SSH Key:
# Check if you already have an SSH key ls ~/.ssh/id_ed25519.pub # If you see "No such file", create one: ssh-keygen -t ed25519 -C "[email protected]" # Press Enter 3 times to accept defaults (no passphrase is fine) # Copy your SSH key to clipboard pbcopy < ~/.ssh/id_ed25519.pub
Add SSH Key to GitHub:
Cmd + V to pasteTest it works:
ssh -T [email protected] # You should see: "Hi username! You've successfully authenticated"
Open Terminal (press
Ctrl + Alt + T).
Install Git:
# Check if you have Git git --version # If you see "command not found", install it: sudo apt update sudo apt install git -y
Create SSH Key:
# Check if you already have an SSH key ls ~/.ssh/id_ed25519.pub # If you see "No such file", create one: ssh-keygen -t ed25519 -C "[email protected]" # Press Enter 3 times to accept defaults (no passphrase is fine) # View your SSH key (you'll need to copy this) cat ~/.ssh/id_ed25519.pub
Add SSH Key to GitHub:
cat command aboveTest it works:
ssh -T [email protected] # You should see: "Hi username! You've successfully authenticated"
Install Git for Windows:
Create SSH Key:
# Check if you already have an SSH key ls ~/.ssh/id_ed25519.pub # If you see "No such file", create one: ssh-keygen -t ed25519 -C "[email protected]" # Press Enter 3 times to accept defaults (no passphrase is fine) # Copy your SSH key to clipboard clip < ~/.ssh/id_ed25519.pub
Add SSH Key to GitHub:
Ctrl + V to pasteTest it works:
ssh -T [email protected] # You should see: "Hi username! You've successfully authenticated"
You need a private place on GitHub to store your history. Here's how:
Go to this link: https://github.com/new
Fill in the form:
claude-historyMy Claude Code conversation historyClick "Create repository"
Copy the SSH URL (looks like:
[email protected]:YOUR_USERNAME/claude-history.git)
Open Terminal (or Git Bash on Windows) and run these commands one at a time:
# Go to your home folder cd ~ # Download the sync script curl -O https://raw.githubusercontent.com/bokiko/claude-history-sync-guide/main/claude-sync.sh # Make it executable chmod +x ~/claude-sync.sh
Open the script in a text editor:
On macOS:
nano ~/claude-sync.sh
On Linux:
nano ~/claude-sync.sh
On Windows (Git Bash):
notepad ~/claude-sync.sh
Find these two lines near the top (around line 20):
REPO_URL="[email protected]:YOUR_USERNAME/claude-history.git" MACHINE="my-machine"
Change them to:
REPO_URL="[email protected]:YOUR_ACTUAL_USERNAME/claude-history.git" MACHINE="my-laptop" # Or whatever name you want for this computer
Save and exit:
nano: Press Ctrl + X, then Y, then Enternotepad: Click File > Save, then closeFirst, pull (download) any existing history:
~/claude-sync.sh pull
You should see:
Cloning repository... Pulling latest history... Done! Available machines:
If you've used Claude Code, push (upload) your history:
~/claude-sync.sh push
You should see:
Syncing Claude history from my-laptop... Successfully pushed from my-laptop!
Congratulations! You're all set up!
Using this is simple. Just remember two commands:
~/claude-sync.sh pull
This downloads the latest history from all your machines.
~/claude-sync.sh push
This uploads your new conversations to GitHub.
Want to sync another computer? Follow these steps:
Complete Step 1 (Git and SSH setup) if not already done
Download the sync script:
cd ~ curl -O https://raw.githubusercontent.com/bokiko/claude-history-sync-guide/main/claude-sync.sh chmod +x ~/claude-sync.sh
Edit the script (same as Step 4), but use a different machine name:
REPO_URL="[email protected]:YOUR_USERNAME/claude-history.git" # Same URL MACHINE="my-desktop" # DIFFERENT name for this machine!
Pull existing history:
~/claude-sync.sh pull
Now both machines are syncing to the same repo!
Your GitHub repo will look like this:
claude-history/ ├── my-laptop/ │ ├── project-website/ │ │ └── conversations.jsonl │ └── project-api/ │ └── conversations.jsonl ├── my-desktop/ │ └── project-website/ │ └── conversations.jsonl └── README.md
Each machine gets its own folder, so there are no conflicts.
| Command | What It Does |
|---|---|
| Download history from GitHub |
| Upload your history to GitHub |
| Show sync info and machine list |
Add this to your shell config so it automatically pulls when you open a new terminal:
macOS (zsh):
echo 'if [ -f ~/claude-sync.sh ]; then ~/claude-sync.sh pull 2>/dev/null; fi' >> ~/.zshrc
Linux (bash):
echo 'if [ -f ~/claude-sync.sh ]; then ~/claude-sync.sh pull 2>/dev/null; fi' >> ~/.bashrc
Windows (Git Bash):
echo 'if [ -f ~/claude-sync.sh ]; then ~/claude-sync.sh pull 2>/dev/null; fi' >> ~/.bashrc
macOS/Linux (using cron):
# Open cron editor crontab -e # Add this line at the bottom 0 * * * * ~/claude-sync.sh push 2>/dev/null
Problem: Git can't connect to GitHub.
Solution:
# Start the SSH agent eval "$(ssh-agent -s)" # Add your key ssh-add ~/.ssh/id_ed25519 # Test the connection ssh -T [email protected]
If it still doesn't work, make sure your SSH key is added to GitHub (see Step 1).
This is normal! It means there are no new conversations to sync.
Problem: You haven't used Claude Code yet, so there's nothing to sync.
Solution: Use Claude Code at least once, then try again.
Problem: You edited the same file on two machines.
Solution:
cd ~/claude-history-sync git stash git pull git stash pop
If that doesn't work:
cd ~/claude-history-sync git reset --hard origin/main
This will lose local changes, so push from your other machine first.
Problem: The repo URL is wrong or doesn't exist.
Solution:
~/claude-sync.sh is correctDon't want to use GitHub? You can use your own server instead.
If you have a self-hosted Git server:
claude-history on your server~/claude-sync.sh and change REPO_URL:
REPO_URL="[email protected]:username/claude-history.git"
Most NAS systems support Git:
ssh://user@nas-ip/volume1/git/claude-history.gitUse rsync for simple file sync:
# Push to server rsync -avz ~/.claude/projects/ user@server:/backup/claude-history/ # Pull from server rsync -avz user@server:/backup/claude-history/ ~/claude-backup/
Important things to know:
.gitignore file excludes common sensitive files (.env, .pem, etc.)No. The sync script only runs when you manually run it. It doesn't affect Claude Code's performance at all.
Not with this script. It syncs everything in
~/.claude/projects/. If you need selective sync, you'd need to modify the script.
The deleted conversation will still exist in your Git history. If you push after deleting, the file will be removed from the latest version but can still be recovered from Git history.
No. This is a community solution. Claude Code may change how it stores data in the future, which could break this script.
Found a bug? Have an idea for improvement?
All contributions are welcome.
MIT License - Use however you like. See LICENSE for details.
Made for the Claude Code community
Star this repo if you found it useful!