ClaudeHack
0.000

Raise cleanupPeriodDays so /resume can still find last month's session

Terminal / Productivity / Cost Optimization·15 hours ago·verified 15 hours ago·easy·~1 min setup·verified

Claude Code deletes session files older than 30 days at startup. If you have ever gone looking for a session you know you had, this setting is why it was gone.

The problem

The default retention is 30 days, so the useful session from six weeks ago — the one where you worked out a tricky migration — is deleted before you think to resume it.

The hack

Set `cleanupPeriodDays` in `settings.json` to something like `365`. Claude Code keeps session files and other application data for that many days instead of 30.

Why it works

Old transcripts are the cheapest form of project memory you have: they hold the reasoning behind decisions that never made it into a commit message. Retention is a one-line setting and disk cost for transcripts is trivial.

Setup

1. Open `~/.claude/settings.json` (create it if it does not exist). 2. Add `"cleanupPeriodDays": 365`. 3. Restart Claude Code — cleanup runs at startup. 4. Confirm older sessions now appear when you resume. 5. Note the same cutoff also governs automatic removal of orphaned worktrees.

Code

{
  "cleanupPeriodDays": 365
}

Additional details

The minimum is `1`. Setting `0` does not disable cleanup — it fails with a validation error. If you want to stop transcripts being written at all, that is a different control: the `CLAUDE_CODE_SKIP_PROMPT_HISTORY` environment variable. One edge case to be aware of: if Claude Code cannot read or parse a settings file, it pauses the retention sweep and warns in `/status` until you fix it. Before v2.1.203 it instead fell back to the 30-day default in that state, which could delete transcripts a longer `cleanupPeriodDays` was meant to keep.

Source

youtube·View original →·by Simon Scrapes

Does this still work?

0 said it works · 0 said it's broken

Related

Discussion

No comments yet. Be the first to say whether this worked for you.