[BUG] Claude desktop WorktreePool GC deletes user-created git worktrees in .claude/worktrees/

Status Fixed / completed
Reported on v2.1.280
Maintainer reply None cached
Activity 1 comment · opened Sep 22, 2026 · closed Sep 24, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The Claude desktop app's background worktree GC (WorktreePool / reapUntrackedWorktreeDir) deletes git worktrees under <repo>/.claude/worktrees/ that were created from the Claude Code CLI or with plain git worktree add.

It treats them as "untracked" (not in the desktop app's own worktree store) and, once they pass a minimum age, removes both the folder and its git worktree registration. Branches survive, but the working directories are gone, along with any uncommitted or untracked work in them. There is no prompt, no visible notice, and nothing goes to the Trash.

Over two days I lost ten worktrees this way, several of them in active use.

What Should Happen?

Worktrees the desktop app did not create should be left alone. At minimum:

  • never delete a worktree that has uncommitted or untracked changes
  • only reap directories that are entries in the desktop app's own worktree store
  • notify or ask before removing, and prefer moving to Trash over deleting
  • document the GC behaviour and offer a setting to disable it

Error Messages/Logs

From ~/Library/Logs/Claude/main.log (names and timestamps anonymised):


[info] [reapUntrackedWorktreeDir] Removed untracked worktree dir <repo>/.claude/worktrees/feature-a
[info] [reapUntrackedWorktreeDir] Removed untracked worktree dir <repo>/.claude/worktrees/feature-b
[info] [WorktreePool] untracked-dir GC: N untracked dir(s), M past min age, 1 removed


One worktree was explicitly kept because it holds an embedded repository:


[warn] [reapUntrackedWorktreeDir] <repo>/.claude/worktrees/feature-c holds a submodule/embedded repository (kept)

Steps to Reproduce

  1. In a git repo, create a worktree outside the desktop app:

git worktree add .claude/worktrees/my-feature feature/my-feature

  1. Work in it from the Claude Code CLI (optionally leave uncommitted changes).
  2. Keep the Claude desktop app running. The GC runs roughly every 30 minutes.
  3. Once the worktree is past the GC's minimum age, the folder is deleted and git worktree list no longer shows it.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.280 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

  • Claude desktop app version: 2.2553.1
  • The deletion is done by the desktop app, not the CLI: the CLI session logs show no git worktree remove at the times of deletion; the desktop app's main.log does.
  • Workaround: keep manually created worktrees outside .claude/worktrees/ (e.g. ../<repo>-wt/<name>); the GC only scans that directory.

View original on GitHub ↗

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