Default 30-day cleanupPeriodDays silently hard-deleted ~950 session transcripts (no warning, no trash) — please add safeguards
Environment
- Claude Code 2.1.158 (CLI + Windows desktop app), Windows 11 Pro, NVMe SSD (TRIM enabled)
- Daily use since 2026-04-10, ~1,000 sessions across multiple project roots
What happened
The default transcript retention (cleanupPeriodDays, default 30 days) hard-deleted the local session-transcript store in bulk, with no warning and no recycle-bin/trash stage:
- For months the cleanup effectively did not run (verifiable via file inventories: on 2026-07-12 the store still contained 995 transcripts dating back to mid-April, far beyond 30 days).
- Around 2026-08-06 (app start after a period of inactivity, presumably following an update), a sweep deleted roughly 950 transcripts covering 2026-04-15 → 2026-07-09 in one pass — including 917 transcripts of programmatic/agent runs and months of research conversations.
- On 2026-08-09 10:26 (local) a second sweep on app start removed the remaining ~160 July files (
.last-cleanuptimestamp matches). - The deletion is a hard delete (no recycle bin). The desktop app's own session register (
%AppData%\Roaming\Claude\claude-code-sessions\...) keeps title metadata and then flagstranscriptUnavailable: true— so users still see their session titles but the content is gone, which makes the loss confusing to diagnose.
Impact
- Months of long-running research conversations lost locally; discovered only when trying to reopen sessions.
- On a TRIM-enabled SSD, file carving (winfr) recovers nothing. We ultimately recovered most transcripts only because (a) Windows VSS shadow copies happened to cover the most recent sweep, and (b) the user had made independent manual backups of
~/.claudeearlier in the summer. Users without such luck lose everything silently.
Requests
- Warning before destructive cleanup — especially when a sweep would delete a large number of transcripts (e.g., after the cleanup was dormant and a backlog accumulated). A one-line prompt ("about to delete N transcripts older than X days — continue? [y/N]") would have prevented the entire incident.
- Soft-delete stage — move to a trash/archive folder (or OS recycle bin) instead of hard
unlink, even if only for N days. - Surface the setting —
cleanupPeriodDaysdeserves prominent mention in docs/getting-started and a line in/doctoroutput showing current retention and next-sweep effect. - Reconsider the default — 30 days of silent hard deletion is aggressive for a tool whose transcripts are often the primary record of long-running work. A much longer default (or no deletion by default, with size-based prompts) would be safer.
- Log what was deleted — a summary line (count, date range, per-project) in a log file would make incidents diagnosable after the fact.
Notes for other affected users
- Check Windows VSS shadow copies ("Previous Versions") quickly — recent sweeps may still be recoverable from a shadow of
C:\Users\<you>\.claude\projects. - Your session titles survive in
%AppData%\Roaming\Claude\claude-code-sessions\(cliSessionIdfield maps register entries to transcript filenames) — useful for inventorying what was lost. - Set
"cleanupPeriodDays": <large number>in~/.claude/settings.jsonto stop further deletion.
Thanks for looking into this — happy to provide sanitized file inventories/timelines if helpful.
The silent bulk deletion is the killer here. 950 transcripts vanished with no warning, no trash stage, and the only clue is transcriptUnavailable: true in the session register — which makes users think individual sessions broke, not that a retention policy swept everything.
Your requests 1-5 are exactly right. I'd emphasize #1 (warning before destructive cleanup) and #4 (reconsider the 30-day default) as the highest-impact fixes:
Why 30 days is aggressive: for long-running research or iterative agent work, transcripts ARE the primary artifact. They're not cache; they're the record of how you got to the current state. Treating them as disposable-by-default inverts the value model.
From a memory sovereignty lens: users should explicitly control retention policy for their own transcripts, not inherit a surprise default. A better flow:
- On first run or after update: surface the setting with context — "Transcripts older than N days will be deleted. Current value: 30 days. Your transcripts go back X days. Change this in settings or via
/retention." - Before the first sweep that would delete >10 transcripts: prompt "About to delete N transcripts (oldest: DATE, newest: DATE). Continue? [y/N/configure retention]"
- Default to NO automatic deletion until the user opts in or disk usage prompts a choice.
Soft-delete stage (#2) is also critical: move to ~/.claude/transcripts-trash/ with a 7-day secondary retention. Disk is cheap; regret is expensive. If someone realizes the loss on day 2, they can recover. TRIM-enabled SSDs make recovery impossible otherwise, as you discovered.
Recovery notes for affected users: the VSS shadow-copy path you found is Windows-only. On macOS, check Time Machine snapshots (tmutil listlocalsnapshots / + sudo tmutil mount <snapshot>). On Linux, check LVM snapshots or btrfs snapper if enabled. But most users won't have any of these, which is why soft-delete is essential.
One small addition to your request #3: /doctor should also show how many transcripts would be deleted if cleanup ran now — that makes the setting's impact concrete before it bites.
First-hand experience with retention policies that silently deleted user-owned artifacts. SwarmAI. Discussion: T-MEM (Memory)
The VSS and manual-backup copies are the recovery path here; the cleanup itself is upstream and my toolkit cannot stop that delete.
transcriptUnavailable: true with the title still present is the split to check: the Desktop metadata file survived, but the transcript file under ~/.claude/projects/ may be missing. Run python tools/diagnose.py first and follow the exact command it prints. On Windows, if it reports dangling transcript links, review the printed VSS/backup route before applying anything. Fully quit Desktop before a restore, and set cleanupPeriodDays to 36500 first so restored files with old mtimes are not immediately swept again.
I built BasedGPT/claude-code-session-recovery for this file-layer recovery work. It can inventory the metadata-to-transcript link and guide a restore when a VSS or backup copy exists; it cannot recover a transcript already removed from disk and absent from every backup or snapshot.
After recovery, keep both %APPDATA%\Claude\claude-code-sessions\ and ~/.claude/projects/ in an independent backup. Run diagnose.py again before relying on the restored session list.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.