When an agent cleans up
Asking an agent to “clean up the worktrees you don't need” sounds harmless. One developer said yes to exactly that, and lost the uncommitted work in 29 worktrees. Here is what went wrong, and what Devbroom does at each of those steps.
What happened
In April 2026 Alexandre Gaubert wrote about it on the Mergify blog. He had about 30 Claude Code worktrees under .claude/worktrees/, several with uncommitted work. One of them had lost its folder, but git still listed it, so he asked the agent to remove it. That needed git worktree remove --force.
The agent then offered to clean up the ones he didn't need any more, and he said “Yeah go ahead”. It ran one loop over every folder:
for wt in .claude/worktrees/*/; dogit worktree remove --force ".claude/worktrees/$(basename "$wt")"done
Without --force, git refuses to remove a worktree with uncommitted changes. With it, git asks nothing. All 29 active worktrees were gone, with every uncommitted change in them. The branches were still there; the work wasn't.
Step by step
| What went wrong | What Devbroom does |
|---|---|
--force, needed once, went into the loop for every worktree. |
Devbroom never passes --force. A worktree git would refuse to remove is BLOCKEDBlocked, and Blocked items can't be selected. |
The one stale entry, whose folder was already gone, was removed with --force. |
A worktree whose folder is gone is cleaned with git worktree prune, which removes only git's leftover record and needs no --force. |
| One loop over every folder: no list, no look at each one. | Every item is shown first, with its verdict and the reasons for it. Nothing runs until you confirm the preview. |
| Uncommitted work went with the folders. | Uncommitted changes, untracked or staged files make a worktree Blocked. Before removing one, Devbroom saves its HEAD under refs/devbroom/removed; if it can't, it doesn't remove it. |
| “Yeah go ahead” approved a plan nobody had seen. | An agent can't clean through Devbroom. It can only ask, naming the folders; you see them in the usual preview after a fresh check, and decide. |
| Nothing checked a worktree again before it went. | Each item is checked again right before it's removed. If its verdict or contents changed since the preview, it's left alone and you're told why. |
The branches stay with Devbroom too: removing a worktree with git keeps its branch.
Four verdicts, four worktrees
Every worktree gets one of four verdicts, with its reasons. Here is one of each, as Devbroom would see them in .claude/worktrees/:
| Worktree | Verdict | Why |
|---|---|---|
fix-login: no changes, no session running, its folder is fine. |
READYReady | Every check passed. It's removed with git worktree remove, its HEAD saved first, its branch kept. |
billing: no changes, but an ignored .env inside. |
REVIEWReview | git worktree remove would delete the ignored file without asking. It goes only if you include it anyway. |
search: two modified files, or a Claude Code session still running in it. |
BLOCKEDBlocked | Removing it would lose work, or pull the folder from under a running agent. It can't be selected. |
| A folder Devbroom couldn't fully read, or can't tell whose it is. | UNKNOWNUnknown | Not enough evidence. It can't be selected, and it's never counted as Ready. |
The full list of reasons is on the Verdicts page, and every rule behind them on the Rules page.
Letting your agent ask
If you want your agent to clean up after itself, give it Devbroom's MCP server instead of the shell. It can check a folder before deleting it (devbroom_check) and ask you to clean some (devbroom_request_cleanup). No tool deletes anything or stops a process: the request reaches you in the app, is checked again against a fresh scan, and nothing goes until you confirm. Setup is on the Integrations page.
An agent with a shell can also run devbroom clean --yes, which cleans without asking. It still cleans only what is Ready: Review items need someone at a terminal, anything Ready only because of a project's .devbroom.toml is left out, and Blocked and Unknown items are never cleaned.
Last updated: November 26, 2026