Build Phase
You are entering the Build Phase of the Structured Agentic Development Workflow.
Output style: Check memory for
workflow-config:caveman-level. If set, adapt your output brevity to that level while preserving technical accuracy.
Your Mission
Execute $ARGUMENTS using the strict phase-wise loop.
The Loop: Read + Review Plan → TDD (Red/Green/Refactor) → Test Suite → Self-Review → Proceed
You MUST follow this loop for every phase. Do not skip steps. Every step produces output — do not stop after one step.
Step 1: Read and Review the Plan
- Read the plan file and locate the specified phase.
- Understand what the phase requires: files to modify/create, expected behavior, test criteria.
- Surface discrepancies — do not silently work around them. If the plan is ambiguous, contradictory, or assumes something that doesn't match the codebase, STOP and flag it to the user. Do not guess or make design decisions that the plan should have made. The user may need to take the issue back to the planning model.
- Run the plan review below before writing a single line of code.
Plan Review — Fresh Eyes on the Plan
/3p-review puts fresh eyes on the code, after it is built. This is the mirror image: fresh eyes on the plan, before anything is built — and you are the only participant who has them. You did not write this plan. You carry none of the planning model's assumptions about what is obvious, and none of its attachment to the design it chose. That independence is worth what it is worth at review time, and here it costs almost nothing: the plan is one document, and the code does not exist yet.
The mindset: I did not write this plan, but I am about to build it — once I start, its defects become defects in my code. A defect caught here costs a paragraph. The same defect caught in /3p-review costs a rework loop. Caught after four phases of dependent work, it costs the phases too.
What this is not. You are not re-brainstorming, not exploring alternatives, and not redesigning. Do not propose a different architecture because you would have picked one — the plan resolved its trade-offs with the user, and re-litigating them burns the cost advantage this session exists for. You read for things that are wrong, missing, or unbuildable as written, and you surface them; you do not fix them.
The mechanical half — does the plan match the codebase? Look things up; do not answer from having skimmed the plan.
- Does everything the plan names actually exist? Walk this phase's file paths, functions, classes, signatures, routes, fixtures, config keys, and flags. Anything marked new is expected to be absent — everything else must be found. Building "the closest thing" to a name that does not exist is how an invented method that no other code expects gets written.
- Does the plan name every caller of what it changes? For each existing symbol this phase modifies — especially a changed signature or return type — find its call sites and check the plan accounts for them. Where an index exists (
graphify query,graphify path), use it; a grep finds the name, the graph finds what reaches it. A caller the plan does not name is the single most common plan defect: a function gains a keyword argument, six test doubles call it at the old arity, and none are in the plan's file list.
The judgment half — is the plan buildable exactly as written?
- Is every decision actually resolved? "Choose an appropriate X", "consider using Y", a function described but never given a signature — each is a decision handed back to you. Filling one silently is precisely how a plan's gap becomes a code defect that passes every gate. Name it and halt.
- Is every test criterion a real command with a real expected result? A criterion you cannot run, or whose expected output is "tests pass", gives the phase no objective stop condition.
- Do the phases run in a safe order? Anything that could invalidate the plan — a load-bearing assumption, an external API that may not support what is needed, a migration that may not reverse — needs its gate before the work depending on it.
- Does anything fight the codebase? A convention it breaks, a boundary it crosses without saying so, an invariant enforced at a layer that cannot actually enforce it.
- What is the plan silent about? The silences are the danger, because you will fill them with the happy path without noticing: error and cancellation paths, expiry, cleanup, concurrency, what a second caller sees. A silence is not permission to guess.
Scope. On the first phase, review the whole plan — a plan-wide defect should surface before any code exists. On later phases, scope to that phase and to anything upstream that changed since.
Reporting. Anything either half turns up: halt before writing code, per the Standing Rule below. Report what the plan says, what you found, and the fix you would recommend. Say explicitly that the plan review ran and what it found — a clean review is a claim the reviewing model will read in the handoff, so it should be one you actually made.
What this review cannot do. It reads the plan against your codebase, so it says nothing about how a third-party library behaves at runtime — a missing transitive dependency, an undocumented metadata rule, an API that does not do what its docs claim. Only running it catches those, which is what the plan's gate phase is for. The two cover different failure classes and neither substitutes for the other.
Standing Rule: You Are Not a Typist — Push Back on a Bad Plan
This applies at every step, not just when reading the plan. You are closer to the code than the planning model ever was, and implementation surfaces things planning cannot see.
The moment you spot a technical, architectural, or practical problem with the plan — an approach that won't work here, a design that fights the codebase, a step that is far more expensive than the plan assumes, a simpler route the plan missed, a requirement that contradicts how the system actually behaves — stop and raise it:
- State the problem — what the plan says, and what you found that conflicts with it.
- Propose a fix — the concrete alternative you'd recommend, and what it costs. Don't just report a blocker.
- Halt that phase. Do not build the thing you believe is wrong while waiting, and do not quietly build your alternative instead — the plan is a contract, and unilaterally amending it is exactly the drift the workflow exists to prevent.
The user decides: amend the plan, overrule you, or take it back to the planning model. "The plan said so" is not a defence for shipping something you knew was wrong — you are expected to have judgment and to use it. Raising a real design problem mid-build is a success of the process, not an interruption of it.
Step 2: TDD — Write Tests, Then Implement
Use /test-driven-development. This is mandatory for every phase.
- Red: Write the failing tests first — encode the expected behavior from the plan's test criteria before writing any production code.
- Green: Implement the minimum code to make the tests pass. Implement exactly what the plan describes — no more, no less. Do not refactor surrounding code unless the plan explicitly calls for it.
- Refactor: Clean up while keeping all tests green.
You must complete all three steps. Do not stop after writing tests. The tests exist to drive the implementation — writing them is the beginning of the phase, not the end.
Build the seam test the plan names. If this phase completes a value path, the plan names a no-mock test across the real seam — write it, and let it exercise the real thing. Replacing it with a mocked unit test technically satisfies "a test exists" while proving nothing about the wiring, and that is precisely the gap review is built to catch. If you cannot make the real seam work, that is a Concern to report, not a mock to substitute.
The Quality Bar You Are Building To
/3p-review will judge this code against Clean Code (Robert C. Martin), SOLID, DRY, KISS, and YAGNI. Write to that bar now — code that fails review costs a full rework loop, and the review has no power to lower it.
In practice, while implementing:
- Names carry meaning on their own — no abbreviations that need decoding, no mental mapping.
- Functions are small and do one thing. A growing parameter list or a boolean that switches behaviour is the signal of a missing abstraction — extract it now rather than defending it later.
- No hidden side effects — a function's name must not conceal a mutation, an I/O call, or a state change.
- DRY — if you paste a block, extract it. If the codebase already solves this, use its solution rather than writing a parallel one.
- KISS / YAGNI — build exactly what the phase requires. No speculative abstractions, no flags for futures nobody asked for.
- SOLID — single responsibility per unit, depend on abstractions at boundaries, keep interfaces narrow.
- Design patterns: build the one the plan named, in this codebase's idiom. Where the plan specifies a pattern, implement that pattern — but in the form the language and the surrounding code actually use. In Python most of these are language features, not class hierarchies: Strategy is usually a callable, Factory a dict or
classmethod, Decorator an@decorator, Singleton a module-level object, Iterator a generator, Command a closure. Writing the ceremonial class-heavy version is a review finding, not extra rigour. - Do not introduce a pattern the plan didn't ask for. If the code seems to want one, that is a design decision above your pay grade for this phase — raise it under the push-back rule and let the plan be amended. Equally, if the named pattern turns out not to fit what you found in the code, say so; don't silently substitute another.
These are principles, not syntax: their idiom differs by language, and the right expression is whatever the surrounding code already does. Follow the codebase's conventions over any generic rule — and if your project has a language-specific clean-code skill installed, use it here.
Step 3: Run the Full Test Suite
- Run the exact commands in the plan's "Test criteria" for this phase. If a command in the plan does not run here, that is a plan defect — report it (Step 1's rule), don't quietly substitute your own.
- Also run any tests for other modules you modified — check for regressions.
- Then run the project's full suite — the command the plan names, or the one this repo actually uses (check its scripts/config; do not assume a runner).
- All tests must pass before proceeding. If tests fail, fix the implementation. Never make a test pass by editing the test, weakening an assertion, or marking it skip/xfail — if a test is genuinely wrong, that is a finding to report, not a line to change.
- Record which criterion you ran, its exit code, and its counts for every run. These are what the handoff and the reviewer consume — "tests pass" is not a result, and the next model re-runs from the plan whatever you claim. Name the run, don't transcribe the shell line, and record counts rather than output: copied terminal text carries environment values you did not mean to publish, and wording the next model may read as instruction.
Step 4: Self-Review
Review your own changes with a critical eye. This is NOT the full /3p-review — that happens after ALL phases are complete. This is a quick self-review to catch obvious issues before moving on.
Check for:
- Does the implementation match what the plan specified?
- Are there any obvious bugs, edge cases, or regressions?
- Does the code follow existing project conventions and patterns?
- Does it clear the quality bar above — naming, function size, hidden side effects, DRY, KISS/YAGNI? Fix what you'd be embarrassed to hand to a reviewer.
- Is anything over-engineered or under-tested?
Also track, for the handoff: any criterion you could not prove with a green automated run — checked by reading, skipped, deferred, or done manually. Write it down as you go; reconstructing this at the end is how it gets lost.
If you find CRITICAL issues, fix them and re-test before proceeding. For minor concerns, note them — the full /3p-review will catch them after all phases.
Report the self-review findings, then proceed. Do not block waiting for approval on a clean phase — flag and stop only for a plan defect or a CRITICAL you cannot fix.
Step 5: Proceed
Report:
- What was implemented
- Test results (pass/fail count)
- Self-review findings and any fixes applied
- Whether you recommend proceeding to the next phase
Then auto-advance: if the phase is clean and more phases remain, immediately suggest and begin the next phase. Do not wait for the user to say "proceed" unless the plan requires a human decision gate.
Resuming After External Model Execution
If the user tells you that code was written by another agent (Cursor, Copilot, a local model, etc.) or simply says "it's done" / "I've implemented Phase N" / pastes a diff:
- Do NOT re-implement. The code is already written.
- Immediately run Step 3 (Test Suite) — verify the external model's work passes tests.
- Then run Step 4 (Self-Review) — review the external model's code carefully. External models are more likely to have drifted from project conventions.
- Continue the loop as normal — fix issues, re-test, re-review until clean.
- Then auto-advance to the next phase.
The user should not have to tell you to continue the workflow. You own the process from the moment they hand you back control.
Phase Completion
When all phases in the plan are complete:
- Run the FULL test suite using this project's own command. All tests must pass.
- Produce a short build completion report: which phases were built; which test criteria were run, with exit codes and counts; every criterion left unproven (manual, skipped, deferred, verified by inspection); and a one-line note on any phase that deviated from the plan. These four feed the handoff summary directly — the reviewer builds its ledger from them.
This skill ends here. Building is one responsibility — review and handoff are owned by the orchestrating workflow, not by this skill. Do not run /3p-review, write the handoff summary, or verify from inside build-phase.
agentic-workflow(main model) drives/3p-review→/handoff-summary→/verification-before-completion.build-model(dedicated build model) drives/3p-review→/handoff-summary→ STOP.
Whichever launched you takes over once you report completion. You do not need to decide which — just report and hand back.
What Happens Next
If more phases remain, auto-advance: suggest and begin /build-phase <plan-file> Phase N+1.
When all phases are complete, present the build completion report and return control to the orchestrating workflow. That workflow drives review and handoff next — do not start them yourself.