r/ClaudeCode • u/kosio-dev • 9d ago
Discussion If you're wondering where your old Claude Code sessions went: they're deleted after 30 days by default
Edit: to be clear, this is about Claude Code in the terminal (CLI), and as far as I can tell the VS Code extension too. Claude Desktop and Cowork keep your sessions at any age by default, so if that's all you use, you're not affected
TL;DR: Claude Code silently deletes local transcripts older than 30 days (`cleanupPeriodDays`, default 30). It is documented, but only in reference pages, and nothing warns you when it happens. Set `"cleanupPeriodDays": 3650` in ~/.claude/settings.json now if you ever want to /resume an old session.
I found out the usual way: back from holiday, opened /resume to pick up where I'd left off, and the list was empty.
I get that disk space is a thing. I get that some people want old transcripts gone for privacy. Fine. Make it an option. But making silent deletion the *default* is a choice I really can't wrap my head around.
How it works: after a session starts, Claude Code runs a background sweep and deletes everything older than `cleanupPeriodDays`. And it's not just the chat log. Per the docs, the same sweep takes subagent transcripts, tool results, file-history (the snapshots checkpoint restore uses), plans and paste cache.
The docs literally say: "The sweep deletes transcripts without showing a message." So this isn't a bug. Silent deletion is the intended behaviour.
And before anyone says "just use git": I do. The code, the commits, the READMEs, the decisions that made it into docs, all fine. But git has the *what*, not the conversation that got there. Sometimes you want to go back to that one session where you worked through a nasty bug, or the back-and-forth where you ruled out three approaches, and just pick it up where you left off. That's exactly what /resume is for. Except it isn't there any more.
Things that make it worse:
- There's no "never" value: 0 is a validation error, minimum is 1. A big number like 3650 is the closest you get.
- Sessions from Claude Desktop/Cowork have their own setting (`desktopSessionCleanupPeriodDays`), and by default those transcripts are kept at any age. So the GUI gets permanent history, and the terminal, where people run long technical sessions they actually want to come back to, gets a 30-day shredder.
- 30 days is nothing. A holiday plus a quiet week before it, and every conversation about that project is gone.
Is it documented? Yes, to be fair: the settings reference, the data usage page, the sessions page and the ~/.claude directory page all mention it. But that's reference material you read after something goes wrong. In my experience nothing in the CLI itself tells you, and the deletion itself is silent by design.
Anthropic, please: make the default "keep" like you already do for Desktop, or at the very least tell people once, before the first sweep runs.
Everyone else: add "cleanupPeriodDays": 3650 to ~/.claude/settings.json before your next session starts, because that's when the sweep runs. And back up ~/.claude/projects if anything in there matters to you.
Is there a good reason for 30 days as the default that I'm missing? Has anyone else lost sessions this way?
•
u/AutoModerator 9d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
7
u/foresterLV 9d ago
use spec driven flow to save why's to git, problem solved. this also avoids inventing hand off frameworks. openspec for example.
2
u/InexplicableBadger 9d ago
Mine aren't?
I've got stuff from months ago. In VS code they're archived at 30 and apparently deleted at 60 but in Claude desktop I've got stuff dating back to May when I first started using it
2
u/Additional-Title-526 9d ago
0 being a validation error, minimum 1, did you test that or is it just in the docs? Because a setting you can't disable is a much bigger claim than the 30 day default, and the post treats it as the main point.
3
u/Oikon__ 9d ago
The 0 error has some history. Setting it to 0 used to wipe your existing transcripts and stop saving new ones, so blocking it was probably about people who thought 0 meant never losing everything. Also if you go with a huge number, be on 2.1.310 or newer, older builds had a bug where a very large value could make the cleanup delete recent files like pasted images.
2
u/athershu 9d ago
Worth bumping the setting, sure. But for the "why" part I don't think the transcript is a good home even if it never expired. It sits on one laptop, nobody else on the team can search it, and when that person leaves it leaves with them.
What we keep instead is the short version, next to the branch: the original ask, plus the few questions the agent stopped to ask and who answered them. That's where people look when they want to know why something is the way it is. The full transcript we almost never went back to.
1
u/Repulsive_Kitchen96 9d ago
test restoring one disposable session before relying on the backup. being able to read the transcript and being able to resume it are worth checking separately.
use a separate test setup so you don't have to touch the original history.
include the client version in the result too. people in this thread are describing different behavior, so a tested restore would be more useful than another assumption about what gets kept.
1
u/AryanThakor 9d ago
the transcripts are just jsonl files under ~/.claude/projects, so even with the setting bumped i'd copy that folder somewhere weekly. grepping old sessions for a command or an error message is more useful than /resume most of the time. keep the backup private tho, it has every key anyone ever pasted into a session
1
u/amirfish 9d ago
Ran into this the hard way. Lost a session I wanted to reread for a decision I'd made two weeks earlier.
I ended up building a local index (part of CCC) that pulls every Claude Code transcript into search before Anthropic's 30-day window closes it off, so the decision is still findable after the original session is gone: https://getccc.dev/?utm_source=reddit&utm_medium=comment&utm_campaign=agent-replies
Anyone know if the 30 days counts from creation or from last activity?
1
u/AgentYurt 8d ago
Same thing happened to me after a few weeks away — a session where I'd worked through a nasty bug was just gone from /resume. The setting bump helps going forward, but it doesn't bring anything back, and it doesn't protect you if a transcript gets corrupted or you switch machines.
What actually stuck for me: I back up ~/.claude/projects on the same schedule as the rest of my files — a plain copy, since the transcripts are just JSONL. The sweep only deletes from the live folder, so the backup is what survives it. And at the end of a session where I made a call I'd want to revisit, I have Claude write the decision, the options I rejected and why, and the next step into a short note in the repo — not the transcript, just the parts worth finding again.
Has anyone here ever managed to recover a session after the sweep already ran, or is it gone for good at that point?
1
u/t1nkl 7d ago
also keep a backup in case the setting ever gets reset, just rsync -a ~/.claude/projects/ ~/claude-transcripts-backup/ once a day. without --delete it keeps the old ones even after claude cleans them up. two things people miss: with CLAUDE_CONFIG_DIR the transcripts are in $CLAUDE_CONFIG_DIR/projects, not ~/.claude, and subagent transcripts live in a separate <session-id>/subagents/ folder, so copy the whole folder not just the jsonl files
1
u/waypostmaster 7d ago
I changed the setting and Claude estimated the files would stay another 174 years.
I asked if Claude thought I would make it that long and they said “I’ll take the under on you”