cd /news/ai-tools/claude-code-quietly-deletes-your-ses… · home › topics › ai-tools › article
[ARTICLE · art-155366] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↓ negative

Claude Code quietly deletes your session history after 30 days. I noticed three and a half months in

A developer discovered that Claude Code silently deletes session transcripts after 30 days, having found that their oldest surviving transcript dated from September 11 while their first prompt dated from May 26. The retention window is documented but controlled by the cleanupPeriodDays setting, which defaults to 30 days and can be raised in ~/.claude/settings.json, though transcripts are stored as unencrypted plain text that can capture credentials. The developer recommends a 365-day retention period alongside permission rules denying reads of credential files.

by read3 min views4 publishedOct 22, 2026

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.

── more in #ai-tools 4 stories · sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/claude-code-quietly-…] indexed:0 read:3min 2026-10-22 · —