{"version":"2.1.326","anchor":"exitworktree-tool-prompt-updated","canonical_anchor":"exitworktree-tool-prompt-updated","heading":"ExitWorktree refuses to remove a worktree while a task may still be running in it","tier":"notice","area":"Worktrees","scope":"individual","heads_up":true,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.326\/e\/exitworktree-tool-prompt-updated","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.326","markdown":"### ExitWorktree refuses to remove a worktree while a task may still be running in it\n\nExitWorktree now refuses to remove a worktree while a background task or agent may be working there, unless discard_changes is set\n\n**What**\n\nA worktree is a separate working copy of a git repository that Claude can work in. The `ExitWorktree` tool leaves it, either keeping it or removing it.\n\n- Removing a worktree is now refused while a background task or agent may still be working there, unless `discard_changes` is set. The message says \"Nothing was removed\" and names the running task.\n\n- The tool's instructions now say `discard_changes` also removes the worktree from under any task still running, so it should be set only after you confirm.\n\n- The instructions now say removing also deletes the branch, unless a hook made the worktree or git refuses, in which case the branch is not deleted.\n\n- The result carries a sandbox note that is added to what the tool returns.\n\n**Why**\n\nThis guards against a worktree being deleted while a background agent is still working in it and losing that work. Claude should now ask you before forcing the removal.\n\n- Area: Worktrees\n- Names: `ExitWorktree`\n- Tier: You'll notice\n- Useful: 2\/5\n- Signal: 1\/5\n- Scope: individual\n- Heads-up: yes"}