Handoff Plan
Write the plan for an engineer who has never seen this codebase or this spec. They can write good code once they know the interface and the test. What they can't know is what you decided: which files, which names and signatures, which values from the spec, which tests prove each task. The plan records those decisions and nothing else.
Principles: test first, small tasks, frequent commits, no speculative features.
Save to docs/plans/YYYY-MM-DD-<feature>.md unless the user or project says otherwise.
1. Check scope
If the spec covers several independent subsystems, propose one plan per subsystem. Each plan should produce working, testable software on its own.
2. Map the files
Before writing tasks, list every file to create or modify and what it's responsible for.
- One clear job per file, with a clear interface. Prefer small, focused files.
- Group files that change together. Split by responsibility, not by technical layer.
- In an existing codebase, follow its patterns. Only plan a split for a file you're already changing that has become unwieldy.
3. Size the tasks
A task is the smallest unit that has its own test cycle and is worth reviewing on its own. Fold setup, config, and docs into the task that needs them. Split only where a reviewer could reject one task and approve its neighbor. Every task ends in something you can test independently.
Each step inside a task is one action with a checkable result: write the failing test, run it and see it fail, implement, run it and see it pass, commit.
4. Write the plan
Start with this header:
# <Feature> Implementation Plan
**Goal:** <one sentence>
**Approach:** <2–3 sentences>
**Stack:** <key technologies>
**Spec:** <path to the spec; the executor reads both>
## Global constraints
<Project-wide requirements from the spec, one line each, exact values copied verbatim:
version floors, dependency limits, naming and copy rules, platforms.>
## Risk list
<Up to five inputs or failure modes the spec implies but no test covers yet, most likely first,
each with the behavior a reasonable user would expect. Add a test for each to the task that owns the code.
An empty list means you checked, not that you skipped it.>
Then one block per task:
### Task N: <component>
**Files:** Create `path/new.py` · Modify `path/old.py:120-145` · Test `tests/test_new.py`
**Uses:** <exact signatures from earlier tasks>
**Provides:** <exact names, parameters, and return types later tasks rely on>
- [ ] Write failing test `test_rejects_empty_name`, which asserts `create_user("")` raises `ValueError`
- [ ] Run `pytest tests/test_new.py::test_rejects_empty_name -v`. Expect FAIL.
- [ ] Implement `create_user(name: str) -> User` in `path/new.py`
- [ ] Run the same command. Expect PASS.
- [ ] Commit: `git commit -m "feat: validate user names"`
What a step needs
A step is done when the implementer can write exactly one reasonable thing from it. It needs to be unambiguous, not complete.
| Step type | Include |
|---|---|
| Test | Test name and assertions as code, using the spec's exact values |
| Code | Exact signature, its file, and any values the spec fixes. Leave the body to the implementer unless the algorithm or exact copy isn't determined by the signature and tests. |
| Verify | The command and the output that means it passed |
| Cross-task | Point to the other task's Provides line. Don't repeat its code. |
There are two ways to fail:
- Gap: a line that decides nothing, like "TBD", "handle edge cases", "add validation", or a type no task defines.
- Transcript: a function body the signature and tests already determine. If the plan is longer than the code it describes, you wrote the code instead.
5. Self-review, then fix inline
- Coverage: can you point to a task for every requirement in the spec? Add any that are missing.
- Steps: go through each step and fix any gap or transcript.
- Names: check that signatures and names match across tasks (
clearLayers()in Task 3 shouldn't beclearAllLayers()in Task 7). - Risks: check that every item on the risk list has a test in its owning task.
- Proportion: if code blocks make up most of the plan, replace bodies with signatures and assertions.
6. Hand off
Share the plan path and ask the user to review it before any implementation starts. If they haven't said how to execute it, offer two options and recommend one in a sentence (based on how coupled the tasks are, how many there are, and what a shipped mistake would cost):
- Task-by-task with review: a fresh agent implements each task, and a reviewer checks it before the next one starts. This is the most thorough option.
- Single session: implement every task in this session, then review the whole branch once at the end. This is faster and cheaper.
Wait for their confirmation before you write code.