- Claude Code auto-deletes conversations after 30 days and stores everything in one local copy. Full guide: where files live, how to back up with GitHub and Git LFS, and how to resume sessions on any machine.
Claude Code automatically deletes old conversations after 30 days, by default, without asking. The cleanupPeriodDays setting in settings.json controls this, and a single line extends retention to ten years.
On my machine, I have 1,388 conversations with Claude Code stored locally, nearly a full gigabyte of work spanning forty projects. Until this week, all of it existed in exactly one copy. And that is not even the alarming part.
The alarming part is written in the official documentation: Claude Code deletes old conversations automatically after 30 days, by default, without asking. In this guide we close both gaps: we disable the automatic deletion, and we set up a cloud backup that lets you pick up any conversation exactly where you left off, from any machine.
In short Claude Code conversations are saved only locally, in
~/.claude/projects, and are deleted automatically after 30 days (thecleanupPeriodDayssetting). The solution: extend the retention period, turn that folder into a private GitHub repo with Git LFS (because GitHub blocks files over 100MB), and sync everything with a single command calledclaude-sync. On a new machine, clone the repo and keep working as usual.
Where does Claude Code store conversations?
All conversations are saved locally only, in ~/.claude/projects. There is no cloud copy, and there is no "export everything" button.
Inside that folder, each working directory gets its own subfolder, and each conversation is a separate .jsonl file. On my machine the numbers came out to: 1,388 conversation files, totaling 968MB, across roughly 40 projects.
What is a Claude Code jsonl file? A text log of a single conversation: each line is an event (a message, a tool call, a result). When you run
claude --resume, the tool reads the file and reconstructs the conversation. If the file exists, the conversation can be continued. If it does not, it is gone.
Does Claude Code delete conversations? (Yes, and that needs to be fixed first)
Yes. According to Anthropic's official documentation, the cleanupPeriodDays setting deletes old conversation files at startup, and the default is 30 days.
In plain terms: the conversation where you debugged that tricky issue two months ago no longer exists, unless you changed the setting. The fix is one line in ~/.claude/settings.json:
{
"cleanupPeriodDays": 3650
}
From this point on, your history is preserved for ten years. Now we can talk about backups.
How to back up conversations to the cloud: the full recipe
The principle: turn ~/.claude/projects into a Git repo that pushes to a private GitHub repository. There is exactly one obstacle in the way, and it goes by the name 100 megabytes.
What is Git LFS? Git Large File Storage: a Git extension that stores large files on a separate server and keeps only a small pointer in the repo. GitHub blocks individual files over 100MB (and warns starting at 50MB, according to GitHub Docs), and long Claude Code conversations cross that limit easily. On my machine, two conversations reached 240MB and 154MB respectively.
Step 1: Setup (once, on your primary machine)
brew install git-lfs
cd ~/.claude/projects
git lfs install --local
git init
git lfs track "*.jsonl"
git add -A
git commit -m "backup: initial snapshot"
gh repo create claude-history --private --source=. --remote=origin
git branch -M main
git push -u origin main
The first push uploads everything and can take a few minutes. For me: 985MB across 1,388 files.
Security, no compromises: Conversation files contain everything that passed through the terminal, including code, file paths, and sometimes secrets that were mentioned by mistake. The repo must be Private. Never push it to a public repository.
Step 2: One sync command, claude-sync
Instead of remembering a sequence of commands, create a short script that runs from any machine and handles everything: saves new conversations, pulls changes from other machines, and pushes to the cloud.
#!/usr/bin/env bash
set -euo pipefail
cd ~/.claude/projects
git add -A
if ! git diff --cached --quiet; then
git commit -qm "backup: sync $(date '+%Y-%m-%d %H:%M')"
fi
git pull --rebase --autostash --no-edit origin main
git lfs pull
git push -q origin main
echo "Conversations synced."
Save it as claude-sync in a directory on your PATH (for example /opt/homebrew/bin) and run chmod +x on it.
The moment it almost broke on me
On the first automated run, the script crashed with the error cannot pull with rebase: You have unstaged changes. The reason is a bit surprising: an active Claude Code conversation writes to its own file during the sync, so between the commit and the pull the file had "changed" again.
The fix is the --autostash flag already included in the script above: it stashes the in-progress change, executes the pull, and restores it. Without it, the sync will fail every time you run it while you are actively working.
Step 3: Automatic daily sync (macOS)
To avoid forgetting, schedule a daily run through launchd, macOS's built-in mechanism. Create a file called ~/Library/LaunchAgents/me.tzedek.claude-sync.plist that runs claude-sync every evening at a fixed time, then load it with launchctl bootstrap. If the machine is asleep at the scheduled time, launchd runs it the moment it wakes up.
How to continue conversations on another machine?
Three one-time steps, and after that you work normally: install git-lfs, clone the repo to the same path, and pull the LFS files.
brew install git-lfs
git clone https://github.com/<user>/claude-history.git ~/.claude/projects
cd ~/.claude/projects
git lfs pull
From there, open claude in a project directory, run claude --resume, and you will see all the conversations for that project, exactly as they appeared on the original machine.
The trap everyone falls into: Claude Code links a conversation to a project by its full path. If on the old machine the project lived at
/Users/dana/myappand on the new one it is at/Users/dan/myapp, the conversations will not appear. Usernames and project paths must be identical on both machines.
The workflow between two machines
The rule is simple: one machine at a time.
- Finish working on machine A: run
claude-sync. - Switch to machine B: run
claude-syncbefore you start. - Work, and run
claude-syncagain when you are done.
Working on both simultaneously creates file conflicts, and the daily automation should be configured only on the primary machine.
What does it cost?
The private repo is free. Git LFS's free tier is roughly 1GB of storage and 1GB of bandwidth per month (source: GitHub Docs), and that gets used up quickly: LFS re-uploads every changed file in full, with no delta, so daily syncing of active conversations consumes meaningful bandwidth. If you exceed the quota, a GitHub data pack costs $5 per month and bumps you to 50GB.
What this means for your business
Conversations with a coding agent are not chat, they are a record of decisions: why we chose a particular architecture, how we solved that specific bug, what was agreed with the client. An organization that loses those conversations after 30 days loses real institutional knowledge.
The investment here is half an hour of one-time setup and $5 a month, against the ability to reconstruct any technical decision, continue work from any workstation, and onboard a new team member with the full historical context already in hand. It is one of the best cost-to-benefit ratios I have seen in development infrastructure.
Frequently asked questions
Where does Claude Code store conversations?
In ~/.claude/projects, locally only, as jsonl files organized by working directory. There is no cloud copy by default.
Does Claude Code delete old conversations?
Yes. The cleanupPeriodDays setting deletes old files at startup, and the default is 30 days. Extend it in settings.json.
Why not back up with iCloud or Dropbox?
You can, and it is transparent. But automatic file sync on a folder that a live tool is actively writing to invites conflicts, especially with two machines. With Git you control when you sync, and you also get a full version history.
Is this related to Claude Code in the browser?
No. This guide syncs your local terminal history. Sessions at claude.ai/code live in Anthropic's cloud already, but they do not import your existing local history.
What else is worth backing up beyond conversations?
Your configuration files: the global CLAUDE.md, settings.json, and the sync script itself. On my machine they sit in a _config folder inside the same repo, so a new machine is fully up and running from a single clone.
The bottom line
Claude Code's default is a single local copy that gets deleted after 30 days. Three changes turn that into a durable asset: extending cleanupPeriodDays, a private GitHub repo with Git LFS, and a claude-sync command that runs automatically every evening. Half an hour of setup, and your history goes from a fragile artifact to infrastructure you can build on.
Yaakov Tzedek is an AI lecturer, consultant, and organizational AI implementer, and runs his own daily AI tips group. The commands in this guide were tested on macOS with Homebrew, Git, and GitHub CLI, and the numbers were measured on my own setup.

