How do you stop a coding agent from editing files it was never asked to touch?
I asked an agent to fix one failing test and it came back having "tidied up" three unrelated modules, renamed a helper, and reformatted a config file. Each change was arguably fine, but the diff was impossible to review.
What's worked for me so far:
- Naming the exact files in scope up front
- Telling it to list any extra changes it wants to make instead of making them
- Keeping the formatter in CI so it has no reason to reformat by hand
Still not bulletproof. How do you keep agents on a short leash without micromanaging every step?
Comments · 2
Say it explicitly: only touch these files, and list what's off-limits. Then check the diff, and reject anything out of scope.
Give it small tasks with a clear definition of done. Big vague requests are where the "helpful" cleanups come from.