AI-assistedI directed the piece and edited every line; AI helped draft it.

Text is cheap, so keep your Claude sessions

claudefiles-are-king

A couple of months ago I went looking for the session where I’d solved a specific problem. I knew I’d worked it out with Claude Code. I just needed to find HOW I did it.

It was gone.

Claude Code keeps your session transcripts on your computer, but only for 30 days by default. Anything older gets swept away the next time it starts up. The session I wanted had aged out and taken the answer with it.

This breaks files are king

Files are king. I keep almost everything as plain files on my machine: notes, runbooks, code, half-finished ideas. The reason is simple. A file is something I can search, grep, diff, and still open in five years. It doesn’t live behind someone else’s product decision.

My Claude sessions are files too. They sit in ~/.claude/projects/ as plain JSONL, one JSON object per line. Every problem I’ve reasoned through with Claude is in there: the dead ends, the fix that finally worked, the exact command that did it. That’s a searchable record of how I actually solve things.

And by default, the machine was throwing it out after a month.

The one setting

There is a single setting for this. It’s called cleanupPeriodDays and it lives in ~/.claude/settings.json.

~/.claude/settings.json
{
"cleanupPeriodDays": 365
}

The default is 30. When I first hit this I bumped it to 90. Today I’m taking it to 365.

There’s no “keep forever” toggle, and the minimum is 1 (setting it to 0 just errors out). So a year is my pragmatic version of forever. When these age out next year, I’ll bump it again.

Why not just store it

Because text is cheap, and I can measure it. Right now I have about 900 sessions sitting in ~/.claude/projects/, and all of them together come to under a gigabyte. Count every subagent transcript those sessions spawned and it’s roughly 5,000 files, about 1.5 GB. My disk is a terabyte. What they hold, a record of every problem I’ve worked through, is worth far more than that. The trade isn’t close.

Here’s the part that made the point for me. The oldest session still on my machine is from late April, about ten weeks back. Everything before that is already gone, swept by the old limit before I thought to change it. The numbers don’t just say storage is cheap. They show me exactly what the default was quietly deleting.

The reverse knob exists too. If you WANT the history gone, CLAUDE_CODE_SKIP_PROMPT_HISTORY turns transcript writes off entirely. I want the opposite. I want more of it, kept longer, sitting in files I control.

The full setting reference is in the docs.