.claude/worktrees/ directories are silently recreated after deletion, even with Desktop closed and no owning process found
Environment:
- Claude Code CLI: 2.1.220
- macOS: 26.5.2 (BuildVersion 25F84), Darwin 25.5.0, arm64
- Claude Desktop app also installed (confirmed fully quit during testing, see below)
Description:
Two directories under <repo>/.claude/worktrees/ (from past EnterWorktree sessions on now-merged tickets) persisted across repeated rm -rf, being recreated within ~5 seconds every time, even with:
- The Bash tool's sandbox disabled (
dangerouslyDisableSandbox: true) - Claude Desktop fully quit (Cmd+Q, verified via
ps aux— zero related processes) - No tmux, cron, launchd agent, or mount responsible (all checked and ruled out)
These aren't real git worktrees: no .git file/dir inside either directory, neither appears in git worktree list, and git rev-parse --show-toplevel run from inside one just resolves up to the parent repo. The content looks like a partial copy of several tracked top-level directories and files from the repo, refreshed to current HEAD each time (one of the copied files matched a same-day commit exactly) — not a stale snapshot from when the work actually happened.
By elimination, the only remaining candidate is the Claude Code CLI installation itself doing background reconciliation against a worktree registry that outlives the session that created it — consistent with ExitWorktree's own docs, which explicitly refuse to touch "worktrees from a previous session (even if created by EnterWorktree then)," implying such a registry exists. Neither ExitWorktree (scoped to the current session) nor EnterWorktree with path (requires the path to be in git worktree list, which these aren't) can reach it.
Impact: Completed, merged work leaves permanently un-cleanable directory state behind, with no tool or command able to remove it. The recreated content also partially mirrors the private repo's structure, which is unwanted for a leftover that's supposed to be inert.
---
Drafted with Claude Code's help while investigating the issue live.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗