This article was created with the help of AI. The numbers come from my own server.
My first prompt to Claude Code on my work server is dated May 26. The oldest session transcript still on disk is from September 11. Everything in between is gone, and I never saw a warning.
It isn't a bug. Claude Code keeps session transcripts for 30 days and then deletes them. The docs say so, on a page few people open. One line in the settings changes that, but only going forward.
Every Claude Code session is written to a file under ~/.claude/projects/. It holds the whole conversation: your messages, the model's replies, every tool call and its result. /resume reads these files to take you back into an old session.
After 30 days the file is deleted. Nothing tells you. The session simply stops showing up in /resume, and its subagent transcripts and any orphaned git worktrees from parallel tasks go with it.
Some things survive:
history.jsonl keeps what you typed, unless HIPAA settings apply to your account. So my May questions are still there. The answers are not.desktopSessionCleanupPeriodDays.
On October 11 I had 724 transcript files taking 861 MB. By age: 181 from the last week, 62 from the week before, 338 from the third week and 143 older than that. Not one older than 30 days.
I can't check what was in the deleted ones. Probably bug hunts and notes on why something was built a certain way. Exactly what you open an old session for.
Three commands:
grep cleanupPeriodDays ~/.claude/settings.json
find ~/.claude/projects -name '*.jsonl' | wc -l
find ~/.claude/projects -name '*.jsonl' -mtime +30 | wc -l
The first shows whether you set a retention period. If it prints nothing, you're on the 30-day default. The second counts all transcripts, the third only those older than 30 days. If the third prints zero and you've used Claude Code for more than a month, the sweep has already run.
Add the key to ~/.claude/settings.json:
{
"cleanupPeriodDays": 3650
}
That's about ten years. Three things to watch:
0 fails validation, and the minimum is 1. To keep things long, pick a big number.
Transcripts are plain text, unencrypted. The docs are blunt about it: if a tool reads a .env file or a command prints a credential, that value lands in the session file. That is why the default is short.
The longer you keep history, the more secrets pile up on disk. If you raise the limit, deny reads of credential files with permission rules, and keep ~/.claude/projects/ out of unencrypted backups.
And if you'd rather keep nothing, CLAUDE_CODE_SKIP_PROMPT_HISTORY stops writing transcripts and prompt history, --no-session-persistence does the same for a single -p run, and claude purge wipes what is stored for one project.
365 days. A year covers nearly every time I go back to an old decision, and the disk use and the secrets stay manageable.
Funny that a tool which holds your whole project in its head forgets its own history after a month.
The details are in the Claude Code docs. I collect findings like this on Promtime, the news site I edit.