Plan the change before the agent touches a file
The most common AI-agent failure isn't bad code — it's editing the wrong scope. This prompt forces a file-by-file plan and an explicit out-of-scope section before any edits happen.
See Code promptsThe failure pattern: you ask an AI agent for a focused change. It comes back having edited 17 files, half of which had nothing to do with what you asked. You now spend longer reading its diff than you would have spent doing the change yourself.
The fix isn't a smarter model. It's a hard stop between "understand the task" and "make changes."
The pattern
Plan how to [goal], but do not edit any files yet.
Produce:
1. Files to touch — full path, what changes in each, in roughly what order
2. New files to create — path + one-sentence purpose
3. Files to delete or rename — and what to update afterwards
4. Public API surface changes — anything callers will notice
(function signatures, response shapes, env vars, DB schema)
5. Migration steps — if data or schema changes, the order they need
to happen in to stay deployable
6. Risk callouts — what could break, what's hard to roll back,
what needs a feature flag
7. Out of scope — what I asked about that I'm explicitly not doing
in this pass
Wait for me to approve the plan before you write any code. If parts
of the plan would be cleaner as two separate changes, say so.
Why the out-of-scope section is load-bearing
Section 7 is the one most people skip. It's also the one that prevents the "while I was in there" creep where the agent rewrites surrounding code that wasn't part of the ask.
Forcing the agent to write down what it's not doing surfaces the assumptions it would have silently made. You'll catch about half the "wait, why did you also..." moments before they happen.
When this earns its keep
- Any change that touches more than two files
- Anything with a migration (DB, env var, public API)
- Any refactor where "small" might not be small
- Anytime you're about to give an agent destructive permissions
When to skip it
For a one-file change to a function you know well, planning before editing is overhead. Use this when the cost of an unwanted scope blast is high, not when you're just renaming a variable.
The full version is on Code prompts, along with 13 other additions this week — steering ("course-correct without rewinding"), incident response ("ranked causes across logs, deploys, config"), IaC plan translation, and more.
More spotlights: See the archive →