claude-code - 💡(How to fix) Fix [BUG] Chat JSONLs deleted from ~/.claude/projects/ despite cleanupPeriodDays set high — appears triggered by updates/restarts

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  1. Warn before deletion. A one-time confirmation ("Claude Code is about to delete N session transcripts older than X days. Continue?") would have prevented every loss in the linked issues.

Root Cause

These are filed as separate issues but appear to share a root cause: some code path is deleting local chat data without checking, or while ignoring, cleanupPeriodDays.

RAW_BUFFERClick to expand / collapse

What's Wrong?

Local Claude Code chat transcripts (JSONL files under ~/.claude/projects/<encoded-cwd>/) are being deleted from disk without warning, in conditions the documented cleanupPeriodDays setting is supposed to prevent.

I have cleanupPeriodDays: 36500 (~100 years) set in ~/.claude/settings.json. The deletions still happen. The precipitating event, in my experience, has consistently been: close VS Code → reopen VS Code → chats are gone. Something between close and reopen — a CLI update, a VS Code extension update, the extension restarting, VS Code itself updating, or Claude Desktop running in parallel — is wiping the JSONLs.

I am not the only person reporting this. The same pattern shows up across:

  • #41458 — cleanupPeriodDays: 99999 set, 490 sessions deleted anyway.
  • #38055 — "Minor version update permanently deletes chat history and scheduled tasks."
  • #12908 — "Conversation History disappeared after update."
  • #38691 — "All sessions lost after Claude Desktop update on Windows."
  • #48334 — "Desktop app update deletes session history."
  • #59248 — "Silent retention cleanup deletes session transcripts with no warning, opt-in, or recovery."

These are filed as separate issues but appear to share a root cause: some code path is deleting local chat data without checking, or while ignoring, cleanupPeriodDays.

This has cost me months of chat history on a personal project. I built a recovery tool (macOS + Time Machine): https://github.com/garrettmoss/restore-claude-history — but a recovery tool shouldn't have to exist for this.

What Should Happen?

At minimum, one of:

  1. Honor cleanupPeriodDays. Whatever code path is currently bypassing it should check it.
  2. Warn before deletion. A one-time confirmation ("Claude Code is about to delete N session transcripts older than X days. Continue?") would have prevented every loss in the linked issues.
  3. Surface cleanupPeriodDays in the UI. The setting exists but is undiscoverable. Users hitting this for the first time have no idea the knob is there.

Any one of these would meaningfully reduce data loss. All three would close the gap entirely.

Steps to Reproduce

I cannot reliably reproduce on demand — that's part of the problem. The pattern I and others observe:

  1. Use Claude Code in VS Code over multiple sessions; accumulate .jsonl files under ~/.claude/projects/<encoded-cwd>/.
  2. Set cleanupPeriodDays to a high value in ~/.claude/settings.json (e.g. 36500).
  3. Close VS Code.
  4. Reopen VS Code some time later — minutes to days. (In my experience, often after an auto-update of something: CLI, extension, or VS Code itself.)
  5. Observe: JSONLs are gone from ~/.claude/projects/<encoded-cwd>/. The "Past Conversations" picker is empty or sparse.

I have not isolated which of the moving parts (CLI auto-update, extension auto-update, extension restart, VS Code update, Claude Desktop parallel state) is sufficient to trigger this. The linked issues above suggest it's not unique to my setup.

Is this a regression?

I don't know.

Claude Code Version

2.1.91 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING