Sub topic 12
A plan, implement, verify workflow
This chapter assumes you can run your project's tests from the terminal, use basic git (branch, diff, commit), and have started one of the three agents in a project. It also assumes you know that an agent calls tools in a loop. Here you will apply that loop to a repeatable workflow with three phases.
Why split the work into phases
An agent that receives a vague request often starts editing straight away. It may pick the wrong files, misread the goal, or change more than you wanted. Splitting the task gives you a checkpoint after each phase, and a wrong direction costs a few minutes instead of a large diff.
Phase 1: plan
Ask the agent to read and think, not to edit. Name the goal, the constraints, and the output you want.
- Claude Code has a plan mode, which you can cycle to with Shift+Tab. In it the agent can read files but cannot edit them.
- Codex CLI and Copilot CLI have no identical switch. You get the same effect by writing "Do not change any files yet" in the prompt, or by running with a read-only sandbox.
A useful planning prompt looks like this:
Users report that ISO week dates such as 2026-W05-3 fail to parse.
Read src/date/parse.ts and its tests. Do not edit any files.
List the files you would change, the new test cases you would add,
and any risks. Keep the plan under 10 lines.Read the plan. Correct it if it touches files you did not expect. Planning is cheap, so this is the best place to redirect the agent.
Phase 2: implement
Create a branch first, so the work is isolated. Then give the agent one narrow task at a time.
git switch -c agent/fix-date-parsingImplement the plan. Add the failing tests first, then change
parse.ts until they pass. Do not edit files outside src/date/.Small steps keep the diff reviewable and keep the context window focused. If the task is large, ask for the plan's steps one by one and commit after each.
Phase 3: verify
Never accept "done" as proof. Ask the agent to run the project's checks, then run them yourself.
npm test
npm run lint
git diffIf a check fails, paste the failing output back to the agent and return to the implement phase. Instruction files help here: if CLAUDE.md or AGENTS.md lists the test and lint commands, the agent runs the right ones without being told.
Review before you commit
Read the full diff. Look for deleted tests, loosened assertions, unrelated edits, and new dependencies. Stage only what you accept with git add -p.
git add -p
git commit -m "Fix date parsing for ISO week dates"Common errors
| Error | Result | Fix |
|---|---|---|
| Skipping the plan | Edits in the wrong files | Start in read-only or plan mode |
| One huge task | Unreviewable diff | Split into steps, commit each |
| Trusting "tests pass" | Hidden regressions | Run the tests yourself and read the diff |
| Working on the main branch | Hard to undo changes | Use a branch per task |
Exercise
An agent reports that all tests pass after a change. Name two checks you should still do before committing.
Show answer
Run the tests and lint yourself rather than relying on the report, and read the full git diff. Look for weakened or deleted tests, unrelated edits, and files outside the intended scope. Stage only accepted changes with git add -p.
Exercise
Why do you create a branch before the implement phase, and what do you do if the agent's changes go in the wrong direction?
Show answer
A branch isolates the agent's work from your main line. If the changes are wrong, you can discard them by switching back and deleting the branch, or return to the planning phase with a corrected plan and restart.