Plan-then-Code
The agent proposes a plan; a human approves it before any files change.
Problem
Given a task, a coding agent will often start editing files immediately. If it misread the task or picked a poor approach, you find out only after it has changed 20 files. Reviewing that diff is slow, and undoing a wrong direction costs more than the task itself.
- Wrong approaches are cheapest to catch before any code exists.
- Developers don’t want to approve every small step.
- Plans can look reasonable and still miss the hard part.
- Agents explore the codebase better when they aren’t also editing it.
Solution
For any task beyond a trivial edit, have the agent work in a read-only planning step first. It explores the relevant code, then writes a short plan: the approach, files to change, new tests, risks and open questions. The developer reviews the plan, corrects the approach or answers the questions, and approves. Only then does the agent switch to editing, following the plan. If reality differs from the plan mid-task, the agent stops and updates the plan instead of improvising a different design.
Diagram
Corrections are cheapest at the plan stage. A two-minute plan review often saves an hour of diff review and rework.
When to use
Use it when
- Tasks touch several files or an unfamiliar part of the codebase
- There's more than one reasonable approach
- Mistakes would be expensive to unwind (schema, API, security changes)
- You want to stay in control of design without writing the code
Avoid it when
- One-line fixes and obvious changes
- Pure exploration where you want the agent to try things quickly in a branch
- When you'd approve without reading; then the plan is just overhead
Trade-offs
Gains
- Wrong approaches caught before any code exists
- The developer stays in charge of design decisions
- The approved plan doubles as PR description and documentation
Costs
- Adds a step to every non-trivial task
- Plans can hide the hard part behind vague steps
- Developers may rubber-stamp plans they didn't read
Worked example
Linkwatch MVP2 adds Slack alerts alongside the existing log-file alerts.
- Agent (plan mode)Reads the alert code and config, and changes nothing. Proposes: add a
SlackNotifierclass next toLogNotifier, a webhook URL in config, retries in the notifier, 4 new tests. - Open questionThe plan asks: “Should a Slack failure block the log-file alert?”
- DeveloperAnswers no, the notifiers must be independent. Also says to put both behind a
Notifierinterface so email can be added in MVP3. Approves the revised plan. - Agent (editing)Implements the plan: 6 files changed and 5 tests added, all passing.
- ComparisonIn a test without planning, the agent wired Slack directly into the checker loop. Undoing that took longer than the whole planned task.
Failure modes
| Failure | Symptom | Mitigation |
|---|---|---|
| Vague plan | "Update the alert logic" with no files or approach | Plan must list files, approach, tests and open questions |
| Rubber-stamp approval | Plans approved in seconds; problems surface in review | Keep plans short enough to actually read; review the risks section |
| Plan drift | Agent quietly does something different from the plan | Agent must stop and update the plan when reality differs |
| Planning trivial tasks | Plan reviews for one-line changes | Skip planning below a size or risk threshold |