{"version":"2.1.268","anchor":"agent-worktree-deletion-gains-a-force-remove-path-with-neste","canonical_anchor":"claude-rm-gains-a-force-remove-worktree-flag-and-rich","heading":"Force-remove stuck worktrees, with new safety checks and CLI\/fleet-view support","tier":"use","area":"Agent Worktrees","scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.268\/e\/agent-worktree-deletion-gains-a-force-remove-path-with-neste","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.268","markdown":"### Force-remove stuck worktrees, with new safety checks and CLI\/fleet-view support\n\nSessions and worktrees can now be force-removed when git or hooks can't clean them up, with new safety checks and a fleet-view confirmation\n\n**What**\n\n- Job\/session deletion logic now supports an explicit force-remove path for a worktree's directory, used when the normal removal (via git or the WorktreeRemove hook) can't clean it up.\n\n- Before force-removing, Claude Code checks for nested git repositories, tracked (not just uncommitted) changes, and verifies the worktree is actually registered in git's own worktree list; the worktree-state check now separately reports `trackedChanges` (real edits) versus plain `dirty` (which includes untracked files).\n\n- If removal is still withheld, the reason is one of `tracked_changes`, `nested_repositories`, `nested_unverified`, or `not_registered`, and a new `aFt` message generator produces detailed explanations for every possible refusal reason (dirty, unpushed, unpushed_shared, in_use, live_lock, occupied, shared_record, records_unreadable, unverified, identity_changed, and the remove_failed sub-reasons above).\n\n- The `claude rm` CLI command gains two new flags: `--discard-unpushed <commit>@<worktree-id>` to discard unpushed\/uncommitted changes on a worktree still at a given commit, and `--force-remove-worktree <worktree-id>` to force-delete a worktree directory.\n\n- The fleet view's job-delete action gained a second confirm-and-retry path for force-removing a worktree (alongside the existing 'discard unpushed changes' offer), and reports whether the branch was preserved.\n\n- Deletion telemetry and results now distinguish a forced removal from the existing 'left worktree in place' outcome, via a new `worktree_force_removed` event and a `forcedWorktreeRemoval`\/`forceRemoveWithheld` result field.\n\n**Why**\n\nWorktrees (the separate folders git uses for each session's checkout) can get stuck when git or a cleanup hook can't remove them, blocking session\/job deletion. This gives users and the CLI an explicit, safety-checked way to force the removal through instead of leaving orphaned directories behind, while refusing to blow away directories with nested repos or real tracked changes without being told to.\n\n- Area: Agent Worktrees\n- Tier: Use it now\n- Useful: 4\/5\n- Signal: 3\/5"}