Sub topic 1
Why Ask for a Plan Before Code
Prerequisites
This chapter assumes you have:
- Used a coding agent or AI assistant on a code repository.
- Basic version control skills: commits, diffs, and branches.
- The ability to read and run your project's test suite.
You do not need to know any specific agent tool. The ideas apply to any agent that can read and edit files.
The problem with editing immediately
A coding agent that starts editing as soon as you give it a task makes decisions you never see. It picks a design, chooses which files to touch, and fills gaps in your request with guesses. You find out about those guesses only when you read the diff.
Two failures are common:
- Solving the wrong problem. The agent reads "add rate limiting to login" and builds a global limiter for every endpoint. The code works, but it is not what you wanted.
- Touching more than you intended. The agent renames a helper, reformats a module, or adds a dependency along the way. The diff grows, and review gets harder.
Both failures cost you the same thing: time spent reading and undoing code that should not exist.
What a plan changes
A plan is a short written description of what the agent intends to do, produced before any file is changed. It moves the agent's decisions out of the diff and into text you can read in a minute or two.
Reading a plan is cheaper than reading a diff for three reasons:
- A plan is shorter than the code it describes.
- A wrong assumption is visible as a sentence, such as "assumes a single server process", and you can correct it directly.
- Nothing has changed on disk, so rejecting the plan costs nothing. There is nothing to revert.
The loop between steps B, C, and D is where you do your corrections. Fixing a plan takes one message. Fixing the same mistake after the code is written can take a rewrite.
A worked comparison
Suppose you ask for rate limiting on a login endpoint in two ways.
Direct request:
Add rate limiting to the /login endpoint.The agent may start editing right away. It might add a third-party package, store counters in memory, and change the error response. You discover each choice while reading the diff.
Plan-first request:
I want to add rate limiting to the /login endpoint.
Do not edit any files yet. Read the relevant code and give me a plan.The agent now returns text. If it writes "I will add a new dependency for rate limiting", you can reply "do not add dependencies" before any code exists. The later chapters cover how to write this request in full.
What you gain
| Without a plan | With a plan |
|---|---|
| Assumptions appear in the diff | Assumptions appear as sentences you can correct |
| Wrong direction found after code is written | Wrong direction found before any edit |
| Large diffs mixed with unrequested changes | Scope is agreed in advance |
| No reference for review | The plan is a checklist for the review |
The last row matters most. Once you have an agreed plan, "does the diff match the plan?" is a concrete question. Without one, you are judging the diff against your memory of what you wanted.
Cost
Planning adds a round trip. For a one-line fix it is not worth it, and a later chapter covers when to skip it. For a change that spans several files, adds behavior, or touches code you do not know well, the extra minutes usually repay themselves.
Exercise
A teammate says, "Planning is a waste of time. If the code is wrong, I will just revert it." Give two reasons a plan can still save effort.
Show answer
First, a wrong assumption is cheaper to find in a short written plan than in a diff, and fixing it takes one message instead of a rewrite. Second, a plan stops unrequested changes, such as a new dependency or extra refactoring, from entering the diff, so review is smaller. The approved plan also gives you something to compare the result against.