Sub topic 6
Breaking work into small, verifiable tasks
This chapter assumes you can write and run unit tests, use Git, and have already prompted a coding agent. It also assumes you have a requirements document with numbered acceptance criteria and a design document. The task list is the last planning artifact before implementation.
Why tasks need to be small
A coding agent works inside a limited context window and tends to lose track of constraints as a session grows. A task like "implement password reset" invites the agent to make many decisions at once: storage, expiry, endpoints, error handling. Some of those decisions will be wrong, and you will find out only after reading a large diff.
A good task is small enough that you can review its result in a few minutes. It is also specific enough that you can tell whether it is finished.
What a good task contains
Each task should have four parts:
- A concrete outcome. Name the thing that will exist afterward, such as a token store or an endpoint.
- Boundaries. Say what the task does not cover, so the agent does not wander into the next task.
- A link to the spec. Reference the requirement numbers it satisfies, such as "Requirement 1.3".
- A check. State how to verify the result, usually a test that passes.
Here is a task list for the password reset requirement:
## Tasks
- [ ] 1. Add a reset token store
- Store the token, its issue time, and a used flag.
- Covers: Requirement 1.1, 1.3
- [ ] 2. Implement token redemption
- Reject expired tokens and tokens that were already used.
- Write tests first. Covers: Requirement 1.1, 1.3
- [ ] 3. Add the reset-request endpoint
- Return the same response for registered and unregistered emails.
- Covers: Requirement 1.2The "Covers" lines make the list traceable. A reviewer can check that every acceptance criterion appears in at least one task, and that no task exists without a reason.
Ordering tasks
Order tasks so that each one builds on work that already exists and has been verified. Put foundations first: data structures, then logic, then the interface that exposes the logic. In the example, the endpoint comes last because it depends on the token store and redemption logic.
The loop back on failure matters. If the agent cannot pass the check for one task, you fix that task before moving on. Stacking new work on a broken foundation hides the original fault.
Testing a task's size
Use these questions to judge whether a task is the right size:
| Question | If the answer is "no" |
|---|---|
| Can you describe the result in one sentence? | Split the task. |
| Can you verify it with a test or a command? | Add a check, or rewrite the task. |
| Would the diff fit on one screen or two? | Split the task. |
| Does it map to at least one requirement? | Question whether it is needed. |
Tasks can also be too small. "Create an empty file" costs more in review overhead than it saves. A useful task produces something that can be checked on its own.
Running tasks one at a time
Give the agent one task per run, and tell it to stop afterward. The instruction file from earlier in the tutorial can hold this rule once, so you do not repeat it:
- Work on one task from `tasks.md` at a time and stop for review after each.After each task, review the diff, run the tests, and tick the checkbox. Commit before starting the next task. Small commits make it easy to revert a single task if it turns out to be wrong.
Common errors
- Vague tasks. "Improve error handling" has no finish line. Name the specific errors and the expected behavior.
- Tasks without checks. If nothing can fail, you cannot tell whether the agent succeeded.
- Hidden dependencies. A task that needs an earlier task's output, but is listed before it, forces the agent to guess or invent the missing piece.
- Tasks that silently change requirements. If a task reveals that a requirement is wrong, stop and update the spec instead of letting the code diverge.
Exercise
A task reads "Add the password reset feature, including the database, email sending, and the web form." Name two problems with it and describe how you would fix it.
Show answer
The task is too large to review in one pass, and it has no stated check or requirement link. Split it into ordered tasks such as a token store, token redemption, an email-sending function, and the reset endpoint. Give each task a "Covers: Requirement N.M" line and a test that must pass before the next task starts.
Exercise
Task 3 depends on code from task 2, but a teammate reordered the list so task 3 comes first. What is the likely effect on the agent, and what would you do?
Show answer
The agent will either invent a stand-in for the missing code or fail partway through, and the result may not match the design. Restore the order so each task builds on verified work, and add a note to the later task naming the earlier one it depends on.