Desktop app deletes session transcript when cleaning up merged worktree

Resolved 💬 1 comment Opened Apr 27, 2026 by YashYash Closed Apr 27, 2026

What happens

When the Claude Code Desktop app cleans up a worktree after its PR is merged, it also deletes the session JSONL transcript at ~/.claude/projects/<encoded-worktree-path>/<session-id>.jsonl.

The worktree directory is gone, the project dir under ~/.claude/projects/ is left as an empty shell (only stray files under tool-results/ survive), and the conversation history is unrecoverable.

Repro

  1. Start a session in a Claude-Desktop-managed worktree (branch like claude/<name>-<id>).
  2. Open and merge the PR for that branch.
  3. Within ~30s of merge, the worktree is removed and the session's .jsonl is deleted.

Observed concretely: PR merged at 19:13:48 UTC, project dir mtime updated at 19:14 UTC (transcript deletion), worktrees dir mtime updated at 19:31 UTC (worktree removal). No user-configured hooks involved — confirmed empty in ~/.claude/settings.json and project .claude/settings*.json. Session entrypoint was claude-desktop.

Why this is bad

Cleaning up the worktree itself is fine — the code is in master, the dupe checkout is dead weight. But transcript deletion is a separate, unjustified choice. The transcript is the only record of what was tried, what failed, what was decided during that session. Losing it means:

  • You can't go back and ask "why did we do it that way?"
  • You can't --resume or fork the conversation later
  • You can't audit what tools the agent ran, what it read, or what it almost did before backing off
  • The PR body is a sanitized after-the-fact summary, not the working trace

Ask

Decouple transcript retention from worktree cleanup. Either:

  1. Keep the JSONL by default after merge cleanup (preferred), or
  2. Move it to an archive location (e.g. ~/.claude/archived-projects/), or
  3. Provide a setting to opt out of transcript deletion.

Worktrees can go; transcripts shouldn't.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗