[BUG] CLI silently deletes session .jsonl files created on v2.1.37–v2.1.39 during later auto-updates
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?
Session .jsonl files created by CLI versions 2.1.37–2.1.39 have been silently deleted from ~/.claude/projects/. The subagent directories (<sessionId>/subagents/) survived — only the parent conversation files were removed. These sessions are invisible to /resume and unrecoverable without a filesystem backup.
This is not the Desktop migration issue (#29373) or the index staleness issue (#24729) — the actual conversation data files were deleted from disk.
What Should Happen?
- Session data files should never be silently deleted
- If a storage format migration occurs, old files should be preserved or migrated — not removed
- At minimum, a warning/log should be emitted before any session cleanup
Error Messages/Logs
Steps to Reproduce
- Have sessions created on CLI v2.1.37–v2.1.39
- Auto-update through v2.1.40–v2.1.56+
- Run
/resume— old sessions are gone - Check
~/.claude/projects/<project>/— subagent directories exist but.jsonlfiles are missing
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.39 (sessions were actively used and resumable at that version)
Claude Code Version
2.1.79 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Cursor
Additional Information
Evidence
Version-correlated pattern across 4 independent projects:
| Session version | .jsonl present? | Subagent dir present? | Count |
|---|---|---|---|
| v2.1.37–v2.1.39 | No (deleted) | Yes (orphaned) | 101 sessions |
| v2.1.56+ | Yes | Yes | All intact |
| v2.1.40–v2.1.55 | No sessions exist on this machine to test | — | — |
Confirmed via backup: A backup of ~/.claude/ from Feb 24 contains all 70 .jsonl files for one affected project. On the live filesystem (March 19), only 2 .jsonl files remain — both from today's sessions. The files existed and were deleted sometime between Feb 24 and March 19 as the CLI auto-updated through the v2.1.40–v2.1.56 range.
Recovery: Copying the .jsonl files from the backup restores all sessions. They load and display correctly in v2.1.79 via /resume.
Suspected Cause
Something in the v2.1.40–v2.1.55 range appears to have treated .jsonl files without corresponding session index entries as garbage and cleaned them up. This aligns with the v2.1.30 changelog ("replacing the session index with lightweight stat-based loading") — the transition from index-based to stat-based session discovery may have included cleanup logic that removed files not tracked by the old index.
The subagent directories survived because they live in a subdirectory structure that the cleanup logic didn't target.
Related Issues
- #24729 — sessions-index.json not updated since v2.1.31 (index staleness, same version era)
- #9581 — all session data in ~/.claude lost after logout/login
- #12114 — session history lost after auto-update from 2.0.44 to 2.0.49
- #29373 — Desktop migration from local-agent-mode-sessions (different product, similar pattern)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗