Session becomes unreachable ("No conversation found") after git worktree remove deletes its own working directory

Open 💬 0 comments Opened Jul 11, 2026 by Amasus

Claude Code stores each session's transcript in a folder keyed by the absolute path of its working directory (e.g. ~/.claude/projects/<escaped-path>/). When a session is running inside a git worktree (created via the harness's worktree workflow) and is instructed — by Claude itself, following its own worktree-cleanup guidance — to run git worktree remove <path> on completion, that command deletes the directory the live session is rooted in.

Repro:

  1. Start a session in a harness-managed worktree (e.g. .claude/worktrees/my-worktree).
  2. Finish work, and follow the standard cleanup: git branch -d <branch> then git worktree remove .claude/worktrees/my-worktree.
  3. Try to resume/continue that same session (e.g. in the VS Code extension).
  4. Get: Error: Claude Code returned an error result: No conversation found with session ID: <id>.

The transcript .jsonl is not deleted or corrupted — it's still fully intact on disk. But the session becomes permanently unreachable through the UI, seemingly because the resume path depends on the working directory still existing.

Would be great to either: (a) have worktree-cleanup guidance tell the user/agent to end the session before removing its own worktree, or (b) make session resumption tolerant of a missing working directory so the transcript is still viewable/exportable.

Environment: VS Code extension, dev container on Linux/WSL2.

View original on GitHub ↗