claude-code - 💡(How to fix) Fix Bug: automatic cleanup deleted 6 active sessions without warning — token loss

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Claude Code's automatic cleanup routine deleted 6 active session files on 2026-05-31 without any warning or user consent. The sessions were not archived — they were permanently destroyed. This caused loss of conversation transcripts and wasted tokens.

Error Message

  • OR at minimum warn the user before running

Root Cause

Claude Code's automatic cleanup routine deleted 6 active session files on 2026-05-31 without any warning or user consent. The sessions were not archived — they were permanently destroyed. This caused loss of conversation transcripts and wasted tokens.

Code Example

# Proof of cleanup timestamp
$ cat ~/.claude/.last-cleanup
2026-05-31T08:00:25.755Z

# Only 1 session remains in the project directory (the current one)
$ ls ~/.claude/projects/-Users-rachidhamrarras-Desktop/
dedb0464-050c-4bd3-abca-8ce27e203e5f.jsonl
RAW_BUFFERClick to expand / collapse

Summary

Claude Code's automatic cleanup routine deleted 6 active session files on 2026-05-31 without any warning or user consent. The sessions were not archived — they were permanently destroyed. This caused loss of conversation transcripts and wasted tokens.

Environment

  • Platform: macOS Darwin 25.5.0
  • Claude Code version: 2.1.121 (from session JSONL metadata)
  • Date of incident: 2026-05-31T08:00:25.755Z (confirmed from ~/.claude/.last-cleanup)

What happened

At 2026-05-31T08:00:25.755Z, the automatic cleanup routine ran and deleted all session JSONL files in ~/.claude/projects/-Users-rachidhamrarras-Desktop/ except the currently active one.

The 6 deleted sessions were:

  1. Set up agent shop website
  2. Audit Monster
  3. Analyze files for revolutionary architecture
  4. Birth Certificate Contract Setup
  5. Complete App Factory Ecosystem project
  6. Site InnovAct

These sessions were not old/abandoned — they were recent working sessions that the user planned to resume.

Evidence

# Proof of cleanup timestamp
$ cat ~/.claude/.last-cleanup
2026-05-31T08:00:25.755Z

# Only 1 session remains in the project directory (the current one)
$ ls ~/.claude/projects/-Users-rachidhamrarras-Desktop/
dedb0464-050c-4bd3-abca-8ce27e203e5f.jsonl

The UI shows "Session introuvable sur le disque" for all 6 sessions, confirming the JSONL files were deleted while their references still existed in the session list.

Impact

  1. Permanent loss of 6 conversation transcripts
  2. Token waste — tokens paid for those sessions, work irretrievably lost
  3. No warning — no UI prompt, no "are you sure?", no archive before delete
  4. No recovery path — backups in ~/.claude/backups/ contain .claude.json config but NOT session JSONL files

Expected behavior

The cleanup routine should:

  • Never delete sessions without explicit user confirmation
  • OR archive sessions before deletion
  • OR provide a configurable retention policy (e.g. "cleanupEnabled": false)
  • OR at minimum warn the user before running

Requested action

  1. Fix the cleanup to not silently delete sessions
  2. Provide a way to configure/disable the cleanup: "cleanupEnabled": false in settings.json
  3. Reimburse the tokens lost due to this system-side bug

User: rachidHamrarras — [email protected]

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The cleanup routine should:

  • Never delete sessions without explicit user confirmation
  • OR archive sessions before deletion
  • OR provide a configurable retention policy (e.g. "cleanupEnabled": false)
  • OR at minimum warn the user before running

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Bug: automatic cleanup deleted 6 active sessions without warning — token loss