Sub topic 7
Asking for a Plan Before Any Edits
This chapter assumes you can read and write code, use Git branches and commits, and run a test suite from the command line. It also assumes you have used an AI coding agent before.
Why plan first
A coding agent can start editing within seconds of reading your request. That speed is a risk. If the agent misreads the task, you find out after it has changed several files. Asking for a plan first moves the misunderstanding to the cheapest point: a short list of bullets you can correct before any file changes.
A plan is a checkpoint on the agent's understanding. It shows which files the agent intends to touch, in what order, and how it will check its work. You compare that against the scope you wrote in the previous chapter.
How to ask
Put the request for a plan inside the task description, and say that editing must wait for your approval. The example below is a scoped task with this request at the end.
Refactor pricing.py: extract the tax calculation from format_invoice into its own function named calculate_tax.
Constraints:
- Do not change the public signature or the return value of format_invoice.
- Touch only pricing.py and tests/test_pricing.py.
- Run `pytest tests/test_pricing.py` before and after the change and report both results.
First describe your plan in a few bullet points. Wait for my approval before editing.The last two sentences matter. "Describe your plan" produces the bullets. "Wait for my approval" stops the agent from continuing into edits on its own.
What a good plan contains
Read the plan against a short checklist.
| Check | What to look for |
|---|---|
| Files | Only files inside the scope you set |
| Order | Small steps, each of which can be tested alone |
| Behavior | A statement of what stays the same |
| Verification | Which commands run after each step |
| Unknowns | Questions or assumptions the agent states openly |
A plan that touches a file you did not mention is a signal to stop and ask why. A plan with one large step, such as "update all callers", should be split. A plan with no verification step is incomplete, even if the edits look right.
The planning loop
Planning is a short conversation. You read the plan, correct it, and approve it only when it matches your intent.
Correcting a plan
Give feedback that is specific. Suppose the agent's plan says it will also rename TAX_RATE usages in reports.py. You can reply:
Remove the reports.py step. It is out of scope. Keep the work in pricing.py and tests/test_pricing.py. Add a step that runs pytest after extracting the function, before changing the caller.The agent then returns a revised plan. Repeat until the plan is one you would accept in a code review. Approve with a clear message such as "Approved. Do step 1 only, then stop and report." Limiting the first approval to one step also prepares you for the next chapter's idea of small, reversible steps.
When to skip it
Not every change needs a plan. A one-line rename in a single file costs more to plan than to review afterward. Plan whenever the change spans several files, touches public behavior, or you are unsure how the code is organized. The planning step is also a cheap way to learn what the agent found in an unfamiliar codebase.
Common errors
- Asking for a plan but not saying to wait. Some agents then plan and edit in the same turn.
- Approving a vague plan such as "refactor and clean up". Ask for named files and named steps.
- Treating the plan as a guarantee. The agent can still drift during editing, so you still verify and review the diff.
Exercise
You asked an agent to extract a function in one file. Its plan has three steps: extract the function, update the callers across the repository, and reformat all files with a new linter configuration. What do you do before approving, and why?
Show answer
Reject or revise the plan. The caller update and the reformatting step go beyond the one-file scope, and "update the callers across the repository" is too large to verify as one step. Ask the agent to limit the plan to the named file, remove the reformatting step, and add a test run after each step. Then approve only the first step.
Exercise
Write the final two sentences you would add to a task description so the agent plans first and does not edit on its own.
Show answer
"First describe your plan in a few bullet points. Wait for my approval before editing."