Session transcripts silently deleted: retention sweep has no warning/trash/log, leaves orphaned side-dirs; recent (3-9 day old) sessions also deleted

Status Open
Reported on v2.1.211
Maintainer reply None cached
Activity 0 comments · opened Jul 21, 2026

Session transcripts silently deleted: retention sweep has no warning/trash/log and leaves orphaned side-dirs; recent (3–9 day old) sessions also deleted

Environment: Claude Code 2.1.x (losses observed under ~2.1.17x–2.1.20x, deterministic repro on 2.1.211), macOS 15, default settings (cleanupPeriodDays unset).

Part 1 — deterministic repro of the silent sweep (2.1.211)

  1. In an existing project dir (~/.claude/projects/<slug>/), place a valid session .jsonl and backdate it: touch -t <35 days ago> <uuid>.jsonl. Add two controls at 20 and 2 days.
  2. Start an interactive claude in that project and leave it idle.
  3. ~16 minutes later the 35-day file is unlinked. Controls survive.

Observed problems, independent of whether 30-day retention itself is desired:

  • Silent: no console output, no log entry, nothing in Trash — file is hard-unlinked.
  • Inconsistent cleanup: the session's sibling data survives forever — <uuid>/tool-results/, <uuid>/subagents/, ~/.claude/session-env/<uuid>/ all remain orphaned (this machine: 61 orphaned session dirs, 100+ session-env leftovers).
  • Related prior reports: #59248, #62959, #62272.

Part 2 — recent sessions deleted (not explainable by 30-day retention)

Between 2026-06-17 and 2026-07-12, ~250 of 265 sessions in one project dir lost their transcripts while 3–9 days old with fresh mtimes (creation dates verified via session-env dir birthtimes; last activity via tool-results/ mtimes; deletion window bounded via APFS snapshots). Meanwhile older sessions (created Jun 16, mtime Jun 19) in the same dir survived.

Common profile of the deleted sessions: long-lived interactive TUI sessions spawned bare by an external terminal manager (cwd = home project), later context-cleared via /clear and their processes killed without clean shutdown (SIGKILL). Cleanly-exited sessions and never-indexed stub sessions survived. This matches the reconciliation/orphan-GC deletion family previously reported in #39667, #63082, #63904 and the 2.1.177 mass-deletion regression #69140 — sessions that fail index validation appear to get their .jsonl unlinked on a later startup.

Verified NOT the cause on 2.1.211 (each tested live): /clear, /exit, killing a bg job, deleting a bg job — none remove transcripts.

Asks

  • Move expired/orphaned transcripts to a trash/archive dir (or OS trash) instead of hard unlink; a transcript is the only copy of a conversation.
  • Log every deletion (path + reason) somewhere durable.
  • Delete (or deliberately retain) the sibling tool-results//subagents//session-env data together with the transcript.
  • Never GC a transcript merely because its process exited uncleanly / it is missing from an index — killed TUI processes are routine for terminal managers and multiplexers.

View original on GitHub ↗