Desktop app deletes session transcript when cleaning up merged worktree
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
- Start a session in a Claude-Desktop-managed worktree (branch like
claude/<name>-<id>). - Open and merge the PR for that branch.
- Within ~30s of merge, the worktree is removed and the session's
.jsonlis 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
--resumeor 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:
- Keep the JSONL by default after merge cleanup (preferred), or
- Move it to an archive location (e.g.
~/.claude/archived-projects/), or - Provide a setting to opt out of transcript deletion.
Worktrees can go; transcripts shouldn't.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗