[BUG] Session transcripts default to a location outside typical backup coverage, then auto-delete after 30 days — silent, permanent loss of project history
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment
- Claude Code: 2.0.54
- OS: macOS 26.5.1 (build 25F80)
Summary
Session transcripts (~/.claude/projects/<project>/*.jsonl) live under the home directory, not alongside the project/repo they belong to. Combined with the default cleanupPeriodDays: 30 auto-deletion, this results in silent, permanent loss of session history for anyone whose backup strategy doesn't include their full home directory — which is a very common setup (e.g. backing up ~/Documents via Time Machine, but not ~).
For a tool that's increasingly used for substantive engineering work, these transcripts aren't disposable cache — they can be the only record of design decisions, debugging context, and IP-relevant discussion for a project. Deleting them by default after 30 days, with no warning, in a location the user may reasonably not be backing up, is a data-loss footgun.
What happened
Two sub-project directories had all their session .jsonl files deleted automatically (evidenced by both project directories' contents changing at the identical timestamp, consistent with a single cleanup sweep). The sessions were from January/early February 2026, comfortably past the 30-day default. The user had no idea this cleanup was happening, and had no backup of ~/.claude since it's outside their normal backup scope (~/Documents only).
Adding to the confusion: sessions-index.json in each project directory was left behind, still listing the deleted sessions (id, first prompt, message count, timestamps) as if they existed. There's no in-product signal that the underlying transcript was garbage collected — you only discover it when you try to open the session and the referenced file is gone.
Compounding issues discovered while investigating
- No officially supported way to relocate the storage location.
CLAUDE_CONFIG_DIRexists in the codebase but is undocumented, and users report it doesn't fully redirect all state (referenced in #3833, #25762, #28808). cleanupPeriodDays: 0, which per the settings schema should mean "no cleanup," instead disables transcript persistence entirely (#23710) — the opposite of what a user trying to preserve history would expect, and easy to hit by mistake.- No documented/official backup or export mechanism for transcripts.
What Should Happen?
Suggestions
- Document
cleanupPeriodDaysand its default prominently (README, first-run notice, or output when a cleanup actually deletes something) rather than only in the settings schema. - Officially support and document a way to relocate
~/.claude(or at least~/.claude/projects) to a user-chosen path, so it can live inside an already-backed-up directory. - When cleanup deletes a transcript, also remove or mark its
sessions-index.jsonentry so stale references don't linger. - Consider defaulting new installs to a longer retention period, or surfacing an explicit one-time prompt about the retention policy and how to change it, given how consequential silent deletion is for this kind of data.
Error Messages/Logs
Steps to Reproduce
Use Claude Code longer than the auto-cleanup period :-)
Claude Model
Not sure / Multiple models
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.0.54 (Claude Code), on macOS 26.5.1 (build 25F80)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
3 Comments
This is a genuine data-loss bug and you've documented it well. The combination of (a) storing transcripts under home rather than alongside the project and (b) a 30-day silent delete is rough for anyone running Claude Code on substantive engineering work.
A few things that help while this gets addressed:
~/.claude/projects/<hash>/*.jsonlback up fine with a simple cron or launchd job that copies them into your project repo's.claude/directory. Keeps them next to the code they belong to and inside normal git-adjacent backup coverage.--resumeflag on recent Claude Code versions can reattach to a session by ID if the JSONL is still intact. Getting into the habit of noting the session ID at the start of a long session buys you some recovery headroom.cleanupPeriodDayssetting in claude settings is configurable - setting it to 0 disables the auto-delete entirely if you'd rather manage retention yourself.None of these are substitutes for the right fix (project-relative storage with explicit retention controls), but they bridge the gap. The 30-day delete without warning is the part that most needs changing - at minimum it should log to stdout when a cleanup sweep runs.
Those deleted January and February transcript files cannot be reconstructed from
sessions-index.jsonalone. The index keeps identifiers and summaries, not the full conversation history, so with no backup covering~/.claude/projects/the missing content may be gone.For the next cleanup sweep, use
"cleanupPeriodDays": 36500, not0. I builtBasedGPT/claude-code-session-recoverywithbackup_claude_state.pyfor this exact prevention gap: it snapshots both the Desktop metadata and the transcript files into a backup root you choose, with an optional transcript index. Run its--dry-runfirst, point the backup root at storage already covered by Time Machine, then schedule the normal command.Keep the high retention value in place while restoring an archive because restored files retain their old modification times and can otherwise be deleted again on the next launch. Before relying on the schedule, open one generated archive in a scratch location and confirm it contains both the metadata layer and
~/.claude/projects/transcript layer.I'll add to this that 30 days is a really bad default. In countries like Finland, we take month long vacations, so I just came back to all my pre-holiday sessions deleted. Without warning, with no notice that it happened, and no way to recover. I think this is unacceptable user experience. This setting is never even metioned anywhere. This kind of thing should really be called out in the first time setup. "How long should your session logs persist".
IMO the default should be 90 days, and there should be some warning before deletion. Especially when doing mass deletions. I lost hundreds of sessions by just launching Claude Code with no warning, and no notice of any kind.