I found this the annoying way.
I was looking for a conversation from about six weeks earlier. Something about a Postgres index that had taken most of an afternoon to get right. I knew the project. I knew roughly when. I went to find the transcript and it was not there.
Not moved. Not renamed. Gone.
Claude Code cleans up after itself, and unless you have changed a setting you have probably never seen, it does that after 30 days.
What actually happens
There is a value in Claude Code's settings called cleanupPeriodDays. It defaults to 30. Anthropic's own documentation describes it plainly:
"Claude Code deletes session files and other application data older than this period at startup."
Two things in that sentence are easy to read past.
The first is at startup. The cleanup runs when you launch Claude Code. There is no scheduled job you might catch, no notification, no confirmation step. You open the tool to start working and the deletion has already happened.
The second is session files. That means your transcripts, the JSONL files under ~/.claude/projects/. Those files are the actual record of what you and the model worked out together, including the reasoning that got you to an answer rather than just the answer.
None of this is a bug, and I do not think it is a bad default. Transcripts accumulate fast and most of them are worth nothing a month later. It is just that the ones that are worth something look exactly like the ones that are not, right up until you go looking.
Check what yours is set to
The setting lives in ~/.claude/settings.json. If the file does not mention cleanupPeriodDays at all, you are on the 30 day default.
cat ~/.claude/settings.json
And to see what you still have on disk right now, by project:
ls -lt ~/.claude/projects/
Each directory in there is one project, and the JSONL files inside it are the sessions. If you want the naming scheme, or the equivalent paths for Cursor, Codex, Zed, Kiro and Antigravity, I wrote those up separately in where AI coding tools store your chat history. This post is only about the deleting part.
Change it
Set it to whatever you actually want. The minimum is 1 day. Setting it to 0 fails validation rather than disabling cleanup, which is worth knowing before you try it.
{
"cleanupPeriodDays": 365
}If you would rather Claude Code never wrote transcripts in the first place, there is an environment variable for that: CLAUDE_CODE_SKIP_PROMPT_HISTORY. That is the opposite trade, and worth making deliberately. No transcripts means nothing to lose and nothing to search.
One bug worth knowing about
Anthropic's docs mention something else, and it is the part I would check first:
"Before v2.1.203, cleanup ran at the 30-day default in that state and could delete transcripts a longer
cleanupPeriodDayswas meant to keep; files newer than 30 days were never removed."
So if you raised the setting a while ago and assumed you had a year of history sitting there, you might not. Anything newer than 30 days was always safe, but the older material the longer setting was supposed to protect may have gone anyway. Check your version before you trust the number in your config.
What I would actually do
Raising cleanupPeriodDays is the obvious move and it is a real fix. It also has a ceiling. Those JSONL files keep growing, they are only ever readable by grep, and they only cover one tool. If you use Claude Code alongside Cursor or Codex or Zed, raising one retention setting solves a sixth of the problem.
The thing I would not do is assume the default is fine because nothing has gone wrong yet. The failure here is quiet. You do not find out at deletion time, you find out six weeks later when you go looking for something specific and it is not there, which is exactly when the information was worth the most to you.
Where this leaves you
Three options, roughly in order of effort. Raise the setting and move on. Copy ~/.claude/projects/ somewhere on a schedule, which works and costs you a cron job. Or index the transcripts somewhere that outlives them.
That last one is what I ended up building, so treat this paragraph accordingly: Inventory reads these files and keeps its own searchable index, so a cleanup pass removing the original does not remove your ability to find what was in it. It cannot recover a transcript that is already gone, and no tool can. It only helps from the point you start indexing.
Either way, go and look at your settings.json. It takes ten seconds and the default is probably not what you assumed it was.
If you want the equivalent detail for the other tools, I wrote up where each AI coding tool stores its chat history, with exact paths and the quirks in each format.