Sub topic 11
Choosing How Much Spec a Change Needs
This chapter assumes you know the spec-driven workflow from earlier in the tutorial: requirements, design, and tasks, followed by implementation with review gates. You should also be comfortable reading acceptance criteria and running automated tests. The question here is not how to write a spec. It is how much spec a given change deserves.
Why size is a decision
A full requirements, design, and tasks package takes time to write and review. A one-line prompt takes seconds. Neither is always right.
- Too little spec leaves the agent guessing. Different runs give different results, and you find the gaps in code review.
- Too much spec costs hours of writing and reviewing for a change that takes ten minutes to check by eye. Large specs also go stale faster and are skimmed instead of read, so they stop working as a review gate.
Treat sizing as an engineering trade-off. You are spending review effort now to avoid rework and risk later. The right amount depends on how likely the agent is to get it wrong, and how costly a wrong result would be.
Signals that call for more spec
Look at the change along a few dimensions before you decide.
| Signal | Low | High |
|---|---|---|
| Ambiguity | One obvious way to do it | Several plausible behaviors |
| Blast radius | One function or file | Many modules, a public API, a schema |
| Reversibility | A revert fixes it | Data migrations, sent emails, charges |
| Security or compliance impact | None | Authentication, payments, personal data |
| Number of people affected | You alone | A team, or external users |
| Verification cost | A glance or one test | Needs new test infrastructure or manual checks |
| Task length | Under an hour | Multiple sessions, several agent runs |
Ambiguity and reversibility matter most. A change that is ambiguous but easy to revert can be tried and thrown away. A change that is clear but irreversible, such as a migration, still needs a written plan and a rollback step.
Four sizes of spec
Most teams settle on a small set of levels. The names below are a convention, not a standard.
| Level | What you write | Typical change |
|---|---|---|
| 0: Prompt only | One or two sentences, plus the project instruction file | Rename a variable, fix a typo, add a log line |
| 1: Mini-spec | A short note with the goal, 2 to 5 acceptance criteria, and constraints | Bug fix, small endpoint, a validation rule |
| 2: Full spec | Requirements, design, and task list | New feature touching several components |
| 3: Full spec plus extra gates | Level 2, with a design review by a second person, a rollout plan, and a rollback plan | Authentication, billing, data migrations, public API changes |
Level 0 is not "no process". The project instruction file still applies, and you still run the tests. What you skip is the per-change document.
A decision flow
The flow below starts with the cheapest question. If you can verify the result by looking at the diff, you do not need a spec.
Use the flow as a default and override it when you have a reason. If you override it, say why in the pull request description so the next reader can follow your thinking.
Worked examples
A typo in an error message
You can verify this by reading the diff. Use Level 0: "Change 'recieved' to 'received' in src/errors.py." Writing acceptance criteria for this would cost more than the change.
A bug where discounts apply twice
The cause may be unclear, but the expected behavior is clear: a discount applies once. Use Level 1. The mini-spec below pins the behavior, and the first task is a failing test that reproduces the bug.
# Mini-spec: Discount applied twice
**Goal:** A discount code reduces the order total once, even when the cart is recalculated.
## Acceptance criteria
1. WHEN a cart with a valid discount code is recalculated THEN the system SHALL apply the discount exactly once.
2. WHEN a discount code is removed THEN the system SHALL restore the original total.
## Constraints
- Do not change the public `Cart.total()` signature.
- Add a regression test in `tests/test_cart.py` before fixing the code.This is about ten lines. It gives the agent a target and a check, and it takes a few minutes to write and review.
A new password reset flow
This has several behaviors (expiry, single use, response uniformity), touches storage and an endpoint, and has security consequences. Use Level 2 at least. Because it handles account recovery, many teams would add a second reviewer on the design, which makes it Level 3.
Replacing a payment provider
Money moves, and a mistake is hard to undo. Use Level 3. The extra gates here are a design review, a staged rollout behind a flag, and a written rollback step. The rollback step is part of the spec, not an afterthought.
Changes that don't fit the usual shape
Refactors
A refactor changes structure but not behavior, so there are few new acceptance criteria to write. The spec is the existing behavior. Before the agent starts, make sure tests cover that behavior. If they do not, the first task is to add characterization tests that record what the code does today. The size of the spec then depends on blast radius, not ambiguity.
Bug fixes
Start at Level 1 and let the failing test serve as the acceptance criterion. Move up a level if the root cause turns out to span components, or if the fix needs a behavior decision such as "should we reject this input, or accept and normalize it?" That decision belongs in a requirement.
Exploratory spikes
When you do not know what is feasible, a spec is premature. Run a time-boxed spike with a prompt and a clear question, for example "Can we stream results from this API?" Throw the code away or mark it clearly as a prototype. Write the spec afterward, using what you learned. A common failure is promoting spike code to production without ever writing the spec.
Changes that grow while you work
Sizing is not a one-time decision. Escalate when you see these signs:
- The agent asks several clarifying questions about behavior, not syntax.
- The diff touches files you did not expect.
- Two runs of the same prompt give materially different behavior.
- A reviewer asks "what was this supposed to do?"
When this happens, stop. Write the missing mini-spec or requirements, then continue. Do not keep prompting in the hope the agent will converge.
Splitting versus scaling
When a change is big, you have two options: write a bigger spec, or split it into several smaller changes with their own specs. Splitting is usually better, because each piece can be reviewed and reverted independently.
Split when the pieces can ship separately. Keep one spec when the pieces only make sense together, for example a schema change and the code that reads it. In that case, order the tasks so each one leaves the system working.
Where the time goes
A rough guide for the effort split across a Level 2 change:
- Requirements and acceptance criteria: reading and writing, with a short review.
- Design: only the decisions that are expensive to reverse, such as data shapes, interfaces, and failure handling.
- Tasks: small enough that each can be verified by a test or a short review.
Design is where specs most often get oversized. Write down decisions, not a tour of the codebase. If the agent can find a fact by reading the repository, you do not need to repeat it in the design.
Failure modes of sizing
- Ceremony creep. The team writes Level 2 specs for everything because "that is the process". Reviewers start approving without reading. Fix this by naming a Level 0 and Level 1 explicitly and using them.
- Optimism bias. A change looks like Level 1, but it touches a shared library. Check blast radius with a search for callers before you decide.
- Spec as a substitute for tests. A long spec with no executable checks is still a prompt. Even a Level 1 mini-spec needs at least one test or other concrete check.
- Retroactive specs. Writing the spec after the code only documents what the agent did. It does not constrain it. That is acceptable for a spike, but not for a feature.
- Inconsistent levels across a team. If each person sizes differently, reviewers cannot predict what they will see. Put your thresholds in the project instruction file or contributing guide.
Summary of the decision
- Ask whether you can verify the change by reading the diff. If yes, prompt only.
- Otherwise, rate ambiguity, blast radius, reversibility, and security impact.
- Pick the lowest level that covers the highest-rated signal.
- Re-check the level when the agent's behavior or the diff surprises you.
- Split large changes before you scale the spec up.
Exercise
A teammate asks an agent to add an optional locale field to a user profile API response. The field is read-only, defaults to "en", and no other service consumes the endpoint yet. Which spec level fits, and what is the minimum you would write?
Show answer
Level 1. The behavior is clear, the blast radius is small, and the change is easy to revert. Write a short mini-spec with two or three acceptance criteria (for example, WHEN a profile has no locale THEN the response SHALL include "en") and require a test that checks the default. A full design document would cost more than it saves.
Exercise
You start a Level 0 prompt to "make the export faster". After two runs, the agent changed caching in one run and pagination in the other. Name two signals that you should escalate, and say what you would write next.
Show answer
The two runs gave materially different behavior, and the goal is ambiguous ("faster" has no measurable target). Stop prompting. Write a mini-spec at Level 1, or Level 2 if the change spans modules, with a measurable criterion such as "WHEN exporting 10,000 rows THEN the system SHALL finish in under 5 seconds", plus a benchmark or test that checks it, and a constraint on what may change (for example, no change to the export file format).
Exercise
Why is a refactor of a payment module not automatically Level 0 even though it adds no new behavior?
Show answer
Sizing depends on blast radius and reversibility as well as ambiguity. A payment module has high impact if it breaks. The existing behavior acts as the spec, so first confirm that tests cover it (add characterization tests if they do not), then use a higher level with a task list and review gates, because mistakes may be costly and hard to detect by reading the diff.