Claude Code Deletes Your History After 30 Days
The retention default is 30 days and the setting that controls it is absent from a normal install. Here is how to check your own machine, how to stop the deletion, and why stopping it is not the same as solving it for a team.
Open a terminal and count the AI coding sessions on your machine. If you use Claude Code, run: ls ~/.claude/projects/*/*.jsonl | wc -l — then check the age of the oldest one. On the machine this article was written on, the answer was 56 sessions, 972 MB, and the oldest was exactly 30 days old. Nothing older. Not one file.
That machine has been in daily use for months. The absence of anything past the 30-day mark is not a coincidence and not a coding style. It is a retention policy doing its job quietly in the background.
What the setting actually does
Claude Code stores each conversation as a JSONL file under ~/.claude/projects/, in a directory named after the project path. Every prompt, every response, and the tool calls in between are in those files. They are plain text on your own disk, which is exactly what you want.
Retention is governed by cleanupPeriodDays in ~/.claude/settings.json. When that key is absent — which is the case on a normal install, because nothing prompts you to set it — the default applies and transcripts older than 30 days are removed. You can confirm the state of your own machine in one command: cat ~/.claude/settings.json. If cleanupPeriodDays is not in the output, the default is what you are running.
The deletion is not a bug and it is not hidden. It is simply a default that nobody is shown, governing data that nobody thinks of as temporary.
This is worth being precise about, because the reflex is to be indignant and the indignation is misplaced. Local cleanup of a growing cache is a reasonable default for a CLI tool. A gigabyte per developer per month is real disk. The problem is not that the policy exists. The problem is the gap between what the policy treats the files as — a cache — and what they have quietly become, which is the record of how a large share of your codebase came to exist.
How to check your own machine
Three commands tell you where you stand. The count, the oldest file, and the setting:
# how many sessions are on disk
ls ~/.claude/projects/*/*.jsonl | wc -l
# how old is the oldest one (days)
find ~/.claude/projects -name '*.jsonl' -mtime +30 | wc -l
# is retention configured, or are you on the default?
cat ~/.claude/settings.jsonIf the second command returns 0 while you have been using Claude Code for longer than a month, deletion has already run. What is gone is gone; the files are not in a trash folder and there is no undo.
If you would rather see it summarised across every AI tool on the machine, promptwake doctor does the same scan for Claude Code, Codex, Gemini CLI, OpenCode and Aider and reports how many sessions fall inside the deletion window this week. It runs with npx, needs no account, writes nothing and sends nothing anywhere — it reads file dates and prints a table.
How to stop the deletion without any tool
This part is short and you should do it whether or not you ever install anything else. Set the retention period explicitly:
// ~/.claude/settings.json
{
"cleanupPeriodDays": 3650
}That is ten years, which for practical purposes means off. Add a backup of ~/.claude/projects/ to whatever already backs up your home directory and an individual developer's problem is solved. No product required. If that is all you needed, you can stop reading here — and it is worth saying plainly, because an article that manufactures a need it then sells you the answer to is not worth trusting on anything else.
Why that is not the same as solving it for a team
Everything above is a per-machine fix applied by a person who happened to read about it. Scale that to an engineering organisation and each assumption breaks in a different place.
- It has to be set on every machine, by every developer, before the thirty-first day. Anyone who joins next month starts the clock over.
- The files stay on the laptop they were written on. A failed disk, a wiped machine, or a developer leaving takes the record with them — the offboarding checklist that covers repository access does not cover ~/.claude.
- There is no shared view. A tech lead cannot read what the team asked the model to build; every history is private to one machine and one shell.
- It only covers Claude Code. Cursor, Copilot and the rest keep their own history in their own formats and locations, with their own rules.
- Nothing about it is auditable. A retention setting on a personal laptop is not evidence of anything, and cannot be shown to anyone who asks.
The pattern here is familiar. It is the same one that made teams stop keeping code on individual machines: the artefact was never the problem, the distribution of the artefact was. Git did not win because diffs are interesting. It won because the history became something the team held rather than something each person held separately.
What the record is worth on the day you need it
AI now writes a substantial share of shipped code. That makes the prompt-and-response chain behind a change the closest thing to design rationale that exists for it, and there are four moments when its absence is expensive.
In review, the reviewer sees a diff with no statement of intent. They can tell what changed and not what the author was trying to do or what the model was told to avoid — so review degrades into reading the code and guessing at the goal.
In an incident, the question is which change introduced the failure and why it looked correct at the time. Git answers the first half. The conversation that produced it — including the constraint the developer explicitly gave and the model quietly worked around — answers the second, and it is the half that stops the same failure recurring.
In onboarding, a new engineer inherits a codebase whose reasoning lives in transcripts that have already been deleted, on machines they do not have.
In an audit, someone asks how a particular piece of code came to exist. Increasingly that someone is a customer's security questionnaire or a regulator working from the EU AI Act, and increasingly the honest answer is that nobody knows.
Version control records what changed. With AI in the loop, what changed and why it changed are now stored in two different places — and only one of them is backed up.
What to do this week
Set cleanupPeriodDays on your own machine today; it costs one line and removes the deadline. Then find out how large the gap is across the team — how many people are on the default, and how much of the last year is already unrecoverable. That number is usually the argument, and you do not need to buy anything to get it.
If the answer is that the record matters and it should not live on individual laptops, that is the problem PromptWake exists for: it captures the prompt, the response and the resulting diff from the tools your team already uses, keeps them locally by default, and — on the paid tiers — syncs them into one timeline the team can search and audit. But do the first step regardless. The deletion runs whether or not anyone is paying attention to it.
