{"version":"2.1.268","anchor":"forced-destructive-removal-of-agent-worktrees","canonical_anchor":"forced-destructive-removal-of-agent-worktrees","heading":"Forced (destructive) removal of agent worktrees","tier":"internal","area":"Agent Worktrees","scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.268\/e\/forced-destructive-removal-of-agent-worktrees","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.268","markdown":"### Forced (destructive) removal of agent worktrees\n\nAgent worktrees can now be force-removed, deleting all their files after verifying they're linked worktrees, not standalone repos\n\n**What**\n\nCleaning up a git worktree used for an agent (a separate working copy of a repository, stored under `.claude\/worktrees`) now supports a forced, destructive removal path. It deletes all files in the worktree directory except a verified `.git` file, then removes the directory itself. Before doing this, it checks that the target is actually a linked worktree, meaning it has a `.git` *file* pointing elsewhere rather than being a standalone repository with its own full history. If the deletion only partially succeeds, the `.git` gitlink pointer is restored.\n\n**Why**\n\nThis lets Claude Code fully clean up an agent's worktree when needed, while the standalone-repo check guards against accidentally deleting the only copy of a repository's history, and the pointer restoration protects against leaving things in a broken half-deleted state if something goes wrong partway through.\n\n- Area: Agent Worktrees\n- Tier: Under the hood\n- Useful: 2\/5\n- Signal: 2\/5"}