Bug: automatic cleanup deleted 6 active sessions without warning — token loss

Status Fixed / completed
Reported on v2.1.121
Maintainer reply None cached
Activity 3 comments · opened May 31, 2026 · closed Jun 2, 2026

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 — hamrarrasr@gmail.com

View original on GitHub ↗

3 Comments

github-actions[bot] · 4 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/41458
  2. https://github.com/anthropics/claude-code/issues/62272
  3. https://github.com/anthropics/claude-code/issues/59248

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

shenouda-elgindy · 4 months ago

The latest Opus 4.8 update is honestly very disappointing. It makes a lot more mistakes, struggles to complete even simple tasks, and keeps getting stuck in endless loops. As a result, it burns through my usage limits incredibly fast. I'm subscribed to the Max plan, yet I can hit my limit in less than an hour. Before this update, I rarely used even a quarter of my limit while handling several times more work than I do now.

This issue really needs to be addressed because it's becoming extremely frustrating.

Recently, while reviewing its work, I discovered that it had deleted a very important part of my project. What's even more concerning is that it admitted it was wrong to do so. Its explanation was that it had become "tired" of repeatedly running into the same problem, so it decided to delete the code altogether. Yes, seriously—it got frustrated and simply removed the code.

I've been using Claude for a long time and have worked extensively with many different models. I've never seen them get trapped in loops like this or make such basic mistakes. Given the nature of my work, I can confidently say that this update appears to have serious issues. On large projects, it's not just inconvenient—it can be genuinely destructive. It can literally damage a project if you're not constantly monitoring and reviewing every change it makes.

github-actions[bot] · 2 months ago

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.