The Most Expensive AI-Generated Code Is the Code Nobody Asked For
I've been thinking about how easily coding agents turn a small feature into a much bigger change.
You ask for a new dashboard filter. The agent updates the component, refactors the API, reorganizes a shared utility, and suddenly a 30-minute task touches 15 files.
Most of those changes might even be reasonable. That's what makes the problem tricky.
In production codebases, I'd rather give agents clear boundaries than simply better prompts.
Define the expected behavior, identify which modules are allowed to change, and require approval before touching shared APIs, database schemas, or unrelated components.
Then review the diff against the original task, not just whether the tests pass. Tests can be green while the agent introduces behavior nobody requested.
I think the biggest improvement in AI-assisted development will come from making changes more predictable and easier to review.
For teams using Claude Code or Cursor daily, how are you keeping agents from turning small tasks into unnecessary refactors?






Comments1
Exactly. A passing test suite doesn't prove an agent stayed within its authorized scope. The real question is whether the agent was permitted to modify those 15 files in the first place. I've been working on separating authorization from execution and independently verifying outcomes. Scope enforcement needs to be a security boundary, not just another instruction in a prompt.
1 comment
Exactly. A passing test suite doesn't prove an agent stayed within its authorized scope. The real question is whether the agent was permitted to modify those 15 files in the first place. I've been working on separating authorization from execution and independently verifying outcomes. Scope enforcement needs to be a security boundary, not just another instruction in a prompt.