My agent kept rewriting code that worked
For a while my AI agent would refactor code that was already fine. The tests passed, the logic was right, it just wanted to make it prettier.
The fix was a rule that says the agent cannot touch code that is not part of the task. One line, huge difference.
Unrequested changes are the most expensive output an agent can produce.
Top comments (1)
The smallest guard I like here is requiring a reason tied to the task before a file can be touched. If the agent cannot name the failing test, requested change, or explicit cleanup scope, it should leave the file alone. Pretty diffs are where review time quietly disappears.