Skip to content

[BUG] Chat JSONLs deleted from ~/.claude/projects/ despite cleanupPeriodDays set high — appears triggered by updates/restarts #62272

Description

@garrettmoss

Important

Recovery tool (macOS + Time Machine): I've published a script that recovers deleted chat JSONLs from macOS Time Machine snapshots — https://github.com/garrettmoss/restore-claude-history

Doesn't fix the underlying deletion bug, but if your chats are already gone and you have a Time Machine drive with snapshots from before the loss, you can get them back. Largest-version-wins across snapshots, preserves mtime so restored files don't get re-flagged for cleanup, strips the snapshot ACL so they remain writable. macOS only. (See this issue's comment thread for the Windows side).

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workingdata-lossduplicateThis issue or pull request already existsplatform:macosIssue specifically occurs on macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions