Sub topic 1
Asking a Coding Agent for a Plan Before It Writes Code
Prerequisites
You should be able to read a code repository, run its tests, and use version control commands such as git diff and git commit. This chapter assumes you have basic experience asking a coding agent to work on an existing project.
Why ask for a plan before code
A coding agent can edit files quickly, but speed does not guarantee that it understood the task. If the request is incomplete, the agent may solve a nearby problem, change unexpected files, or choose an approach that conflicts with the project.
A plan creates a review point before those changes happen. You can check the proposed scope, assumptions, and tests while the cost of correction is low. The plan also gives the agent a clear sequence to follow.
What a useful plan contains
A useful plan is specific enough to review. It normally includes:
- Affected files: the files the agent expects to change or add, with a reason for each.
- Ordered steps: the implementation sequence, from investigation through testing.
- Risks and assumptions: facts the agent may be inferring, such as the application using one process or a particular configuration source.
- Verification: commands, tests, or manual checks that will show whether the change works.
The plan should match the requested problem. It should not include unrelated cleanup or speculative refactoring.
| Plan part | Question to ask |
|---|---|
| Files | Does each file belong in this change? |
| Steps | Can I review the work in this order? |
| Risks | Which assumptions could be wrong? |
| Verification | How will we know the result works? |
Give the agent the context it needs
State the goal and the behavior you expect. Include constraints such as supported versions, error formats, dependencies, or deployment limits. Mention relevant files when you know them, but let the agent inspect the repository rather than guessing its structure.
For a planning pass, explicitly say that the agent must not edit files. This separates read-only exploration from implementation.
Write the planning request
Use a request with a clear boundary:
I want to add rate limiting to the `/login` endpoint.
Goal: reject more than 5 failed attempts per IP address in 10 minutes.
Constraints: do not add dependencies; keep the existing error response format.
Do not edit files yet. Read the relevant code and give me a plan with:
1. Files to change and why
2. Ordered implementation steps
3. Risks and assumptions
4. How to test the resultReview the response before approving it. Correct wrong assumptions, answer questions, and request a revision when needed.
Exercise
Why should a planning request include a no-edits rule?
Show answer
It creates a review gate so you can correct the scope and assumptions before the agent changes files.