anthropics / anthropics/claude-code

Session .jsonl transcript silently deleted while session folder remains — deletion pattern doesn't match simple age-based retention

Open
#95,403 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:core bug data-loss platform:linux
Dominant language
TypeScript
Stars
147k
Forks
24k
PR merge metrics
PR metrics pending

Description

Summary

Session transcripts (~/.claude/projects/<project>/<uuid>.jsonl) disappear from disk while the session's auxiliary directory (~/.claude/projects/<project>/<uuid>/tool-results/, which caches SessionStart hook output) remains intact. This affects real, substantial interactive conversations — not just short/automated sessions — and the temporal pattern does not match a simple age-based retention sweep.

Environment

  • Claude Code CLI: 2.1.272 (native binary, /joao/.local/bin/claude)
  • Claude Code VS Code extension (code-server): 2.1.276
  • OS: Ubuntu 24.04.4 LTS, self-hosted VPS
  • cleanupPeriodDays is not set in either ~/.claude/settings.json or ~/.claude.json
  • fileCheckpointingEnabled: true (used only for /rewind, per docs — confirmed not related)

Observed behavior (measured directly on disk)

Across multiple project directories under ~/.claude/projects/, most session folders (identified by a valid UUID) no longer have their companion .jsonl transcript, while the folder itself — and its tool-results/ cache from the SessionStart hook — still exists:

Project Session folders Live .jsonl Folders without .jsonl
Project A 75 16 65
Project B 199 57 152
Project C 118 80 41

I cross-referenced this against a separate local database (a memory plugin that records content_session_id + started_at + first user prompt for every session that ever ran) to distinguish two very different situations:

  1. Automated/non-interactive sessions (skill runs triggered by cron, autonomous sub-agent task executions, git-worktree sessions) — most of the missing-transcript count falls here (e.g. 163 of 218 in one project). This may be expected/acceptable.
  2. Real interactive human conversations with substantial content — a smaller but recurring subset. Example: a session that ran for ~8 minutes, produced 11 distinct pieces of work (document analysis, calendar events created, files edited), and both its .jsonl and its folder are now completely gone — no trace at all on disk, not even the tool-results/ cache. This is a different, more severe symptom than "folder survives, only .jsonl is missing."

What I ruled out

  • No cron/systemd timer or user script touches ~/.claude/projects/ on this machine (verified: crontab, systemd timers, grep -r across all local scripts).
  • Not the documented /compact behavior: found a live isCompactSummary: true entry inside a transcript that survived — it uses the same sessionId, appended within the same .jsonl file. Compaction does not create a new file or delete the old one.
  • Not a VM reboot: last reboot shows uptime since 2026-08-20, no reboot around the dates the deletions occurred.
  • Not a simple age-based sweep relative to "today": in one project, a session from yesterday has already lost its .jsonl, while a session from 29 days ago still has its .jsonl intact. This directly contradicts "delete anything older than N days, checked against today's date."

What's unclear from the docs

settings.json reference documents cleanupPeriodDays only as "control how many days Claude Code retains transcripts before automatic deletion" — it doesn't state the default value when the key is absent, nor how to disable the sweep entirely, nor whether the sweep trigger is time-based (a periodic check) or event-based (e.g. only evaluated when a new session starts in that same project directory — which would better explain why deletions cluster in bursts rather than following a smooth daily pattern).

Question

  1. What is the actual default retention period when cleanupPeriodDays is unset?
  2. Is there a way to fully disable transcript deletion (not just increase the number of days)?
  3. Why would a session's .jsonl be deleted while its tool-results/ folder (or, in the more severe case, the entire session folder) is not touched by the same sweep — and in the severe case, why would a real, substantial, non-trivial interactive session be eligible for deletion at all after only ~6 weeks?

Happy to provide more specific session IDs/timestamps privately if useful for debugging — omitted here since this repo is public and some of that data touches personal projects.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by checking ~/.claude/settings.json and ~/.claude.json, then reproduce transcript cleanup while comparing .jsonl files, session folders, and tool-results/ directories under ~/.claude/projects/. Determine the unset cleanupPeriodDays behavior, whether deletion can be disabled, and why transcripts or complete session folders are selected; done means documenting or fixing each observed case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.