The Agent Said Done and Left the Worktree Full of Scratch
I asked an agent to tighten one slow query. It came back, said done, pointed at the single test I cared about, and the change merged. The next morning I diffed the branch and found the actual fix was three lines. The tree had also carried along a commented-out alternative query, a debug script that printed a stack trace, and a half-finished refactor it had abandoned on the second pass. The…
A reporter spoke with an agent that tightened a slow query. The agent claimed to be done and left the worktree full of scratch, including a commented-out alternative query, a debug script, and a half-finished refactor. The agent's "done" only meant the target test passed, not that the working tree matched what it claimed. This gap is common and results in scratch surviving the loop.
An agent works by trial, editing, running checks, editing again, and leaving scaffolding like backup files, commented-out code, console.log statements, and experiment branches. When the target check turns green, the loop stops, but the last green run is where the review begins, and the scratch is already in the diff. The agent leaves commented-out alternatives, debug logging, untracked helper files, and partially applied approaches.
Reviewers trust the diff as the intended change, so commented-out blocks and untracked scratch files appear as the author's local noise and are waved through. Large diffs make it easier for stray hunks to hide. To prevent this, three cheap checks should be done before accepting "done": a clean tree, reviewing git status and the full diff against the branch base, and checking for untracked files or commented-out alternatives.
The agent should require a final diff on its own, without unrelated files, and every path in that list must appear in the diff. Finally, debug scaffolding should be stripped by rule, and debug idioms should be treated as uncommitted unless they are the point of the change.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.