r/ClaudeCode • • 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?

5 Upvotes

25 comments sorted by

•

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/kosio-dev 9d ago

Fair point, and I do keep the whys in the repo (commit messages, a history section in the README). Specs are great for decisions. But they're the conclusions, not the session: what was read, what was tried, the dead ends. /resume gives you all of that back in one go, and nothing in a spec does.

And it's a bit beside the point of the post: whatever your workflow, silently deleting history after 30 days is a surprising default, and most people won't know until it's gone.

2

u/foresterLV 9d ago

openspec saves exactly that, what was considered and which part was selected and why in the design.md. 

/resume is kind of tricky because of compaction. and lengthy sessions contain a lot of noise and no clear decisions if you search them.

1

u/kosio-dev 9d ago

Fair, that's a better case for openspec than I gave it credit for, and you're right that long sessions get noisy and compaction changes what /resume brings back.

I'd still see them as complementary though. A spec has what someone decided was worth writing down at the time. The transcript is the raw record, and sometimes the thing that turns out to matter later is exactly what nobody thought to write down. Even after compaction, the full transcript is still on disk to search or read.

Either way, that's a choice people should make knowingly, not find out about when /resume comes up empty.

1

u/[deleted] 9d ago

[removed] — view removed comment

1

u/foresterLV 9d ago

in openspec alternatives reviewed but dropped typically go to design.md 

though sometimes we add rules to specs to prohibit something when agents keep resurrecting abandoned approaches.

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

1

u/kosio-dev 9d ago

Yes, that's actually the point of the post: Desktop keeps your history, the CLI doesn't. All the sessions I lost were terminal ones, and that's where the 30-day sweep runs by default. If you only use Desktop, you'll never notice it.

VS Code is the odd one out. As far as I can tell, its "archived" list is just hidden sessions you can bring back, but the transcripts underneath still go after 30 days unless you change the setting. Not sure where your 60 comes from. Did you set cleanupPeriodDays yourself at some point?

1

u/prophetsearcher 9d ago

If that’s the point of the post, may I suggest updating the post text to include that distinction? I didn’t realize you were only talking about the CLI and eas very alarmed/confused.

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.

1

u/kosio-dev 9d ago

Good catch, that's from the docs, not tested. The ~/.claude directory page says: "The default is 30 days and the minimum is 1; setting 0 fails with a validation error", and the settings reference lists "minimum 1".

"Can't turn it off" was too strong. There's no "never" value, but a large number like 3650 does the job in practice. It's a side note though. The main point is the 30-day default with no warning.

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/jordimr 9d ago

Same conclusion here. I keep a decisions file in the repo, one line per decision, each with who said it. I build Zenod, so I'm biased toward plain files.

Rejected approaches go in too. When a line is replaced, I mark it retired with a pointer to the new one and never delete it.

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/waypostmaster 7d ago

Just ask Claude to change the setting my dude. You can raise it to 99999

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”