Auto-update deletes session .jsonl files, wiping token usage history and conversation data
Summary
Claude Code auto-updates are silently deleting session .jsonl files from ~/.claude/projects/ directories, resulting in permanent loss of conversation history and token usage data. The /stats dashboard shows drastically reduced totals because it can only read surviving files.
Evidence
Environment: macOS, Claude Code 2.1.87, upgraded through multiple auto-updates since Jan 2, 2026.
Two batch deletion events observed
Event 1 — Mar 25, 10:43:20
All .jsonl session files deleted from older project dirs (-Users-andrew-Documents-Coram-repos-*). Every directory under these paths received the exact same mtime, indicating a single batch operation.
Event 2 — Mar 30, 10:51:58
Same pattern on newer project dirs (-Users-andrew-Documents-work-coram-code-*). This occurred exactly 10 minutes after Claude Code 2.1.87 auto-installed at 10:41:29.
What was lost
- 520 out of 520 sessions referenced in
sessions-index.jsonfiles have their.jsonlfiles missing - 282 session directories exist with only
subagents/data inside — the main conversation.jsonlis gone - Session dates span Jan 2 – ~Mar 1, 2026 — roughly 2 months of daily heavy usage
/statsshows 13.7m tokens (from ~1 month of surviving data); actual usage was likely 30m+
What survived
- Session directories with subagent
.jsonlfiles (11,207 files containing real token usage data) sessions-index.jsonfiles — still reference the deleted.jsonlpaths with metadata (session summaries, message counts, dates, branches) but no token countshistory.jsonl— prompt history going back to Jan 2- Session
.jsonlfiles dated Mar 2+ — these were apparently written by a newer storage format or path and were not targeted by the cleanup
Proof the files existed
The sessions-index.json entries contain fileMtime values corresponding to dates when the .jsonl files were last written (Jan–Feb 2026). These are not stale references from a format migration — the files were actively maintained and then deleted.
Example from sessions-index.json:
{
"sessionId": "7ae2c6c3-acd8-4f61-baec-d467a21cbd9e",
"fullPath": "~/.claude/projects/-Users-andrew-Documents-Coram-repos-logistics-app/7ae2c6c3-....jsonl",
"fileMtime": 1769033018707,
"messageCount": 57,
"created": "2026-01-08T23:10:07.576Z",
"summary": "LLM config Langfuse logging EDGE-898"
}
The fullPath .jsonl file no longer exists. The directory for this session ID also no longer exists. But the index proves the file was there.
Root cause (likely)
The session listing function (visible in the binary as Y79) scans for .jsonl files:
if(!O.endsWith(".jsonl"))return null
A cleanup or migration step during auto-update appears to delete .jsonl files from project directories it considers stale — possibly based on project path changes (the working directory path changed over time as repos moved). The cleanup does not update or remove the corresponding sessions-index.json entries, leaving orphaned references.
Impact
- Permanent, unrecoverable loss of conversation history
/statstoken counts are wrong (showing ~45% of actual usage)sessions-index.jsonfiles are orphaned tombstones- No warning, no backup, no opt-out
Expected behavior
- Auto-updates should never delete session data without explicit user consent
- If a storage format migration is needed, old data should be migrated, not deleted
- At minimum, if cleanup is intentional,
sessions-index.jsonshould be updated to reflect the deletion
Versions affected
Cannot confirm exact version that introduced the cleanup, as older binaries are removed during auto-update. Observed across the upgrade path leading to 2.1.86 → 2.1.87 → 2.1.88.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗