[BUG] Automatic cleanup silently deletes session transcripts, leaving orphaned sidebar entries
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?
Claude Code's automatic cleanup routine silently deleted nearly all session transcript files (~/.claude/projects/<project>/*.jsonl) for one of my projects. The session index (the list shown in the sidebar) was preserved, so the UI still shows dozens of past sessions by name — but clicking any of them produces "Session not found on disk" because the corresponding .jsonl file no longer exists.
There was no warning, confirmation, or notification before the deletion. Past conversation context (decisions, reasoning, trade-offs from long-running project work) is permanently unrecoverable. Backups in ~/.claude/backups/ only cover .claude.json (the index), not transcript content — so there is no recovery path.
What Should Happen?
One of the following:
- Don't auto-delete transcripts at all, or
- Expose a user-configurable retention policy and warn before first deletion, or
- At minimum, when transcripts are deleted, also remove their index entries so the sidebar doesn't show broken sessions.
Error Messages/Logs
Session not found on disk
Send a message to start fresh in this directory.
[Archive] [Delete]
Steps to Reproduce
- Use Claude Code on a project over an extended period, accumulating multiple session transcripts in ~/.claude/projects/<project>/.
- Wait for the internal cleanup trigger to fire (timing/conditions are undocumented).
- Check ~/.claude/.last-cleanup — it now has an updated timestamp.
- Open the Claude Code sidebar — session names are still listed.
- Click any older session — the "Session not found on disk" error appears.
- Confirm with ls ~/.claude/projects/<project>/ that the older .jsonl files are gone, while the sidebar still references them.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.23 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
Evidence pointing to Claude Code's own cleanup (not user action or third-party tools):
~/.claude/.last-cleanup timestamp matches exactly when the transcripts disappeared.
No cleanup utilities (CleanMyMac, etc.) are installed; no manual rm was run.
Only sessions created on the same day as the cleanup survived — every older session in the affected project is gone.
~/.claude/backups/ contains only .claude.json.backup.* files (the session index), not transcript backups.
I'm using the Claude Code desktop app on macOS 26.5.1 (build 25F80), not a terminal session.
Suggested fixes:
- Document the cleanup behavior and its triggers (age threshold? disk size? session count?).
- Add a setting to disable or configure retention.
- Surface a warning before the first cleanup runs on a machine.
- Reconcile the session index with on-disk transcripts so orphaned entries don't appear.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗