When to use this
- You have a detailed specification (API contract, RFC, design doc) and want an agent to implement it
- You have automated tests that can verify conformance
- The implementation is too large to get right in one pass and benefits from iterative repair
The workflow
n-l-spec-conformance.fabro
How it works
Spec reading and planning
Theplan node reads the specification and produces an implementation plan. Because the spec may be long (thousands of lines), the prompt tells the agent to read it from a file rather than trying to include it inline:
Implementation with a shared thread
Theimplement and fix nodes share a thread_id="impl", so they accumulate context across loop iterations. When the agent returns to fix after a failed conformance run, it sees the full history of what it built and what broke. Combined with fidelity="full", the agent retains the detail it needs to make targeted repairs.
The conformance loop
The core of this pattern is the test-fix loop:Fix node prompt
Thefix prompt reads conformance output and targets specific failures:
Max visits as a safety valve
max_visits=5 on the fix node prevents infinite loops. If the agent can’t pass in 5 iterations, the workflow moves on with the best result so far. Tune this based on spec complexity: a 30-line spec might need 2 iterations, a 2,000-line spec might need 10.
Goal gate on full conformance
Thetest_full node has goal_gate=true. If the full conformance suite never passes, the workflow is marked as failed even if execution reaches the exit node. This makes the workflow’s success criteria explicit: partial conformance is not a passing result.
Model assignment
Themodel_stylesheet assigns a cheaper model as the default and routes implementation work to a more capable model:
.impl class targets both the implement and fix nodes (both have class="impl"). Planning and implementation get the stronger model with high reasoning effort; any lightweight nodes you add later (summaries, notifications) default to the faster model.
Adding a human approval gate
For high-stakes specs, add a human gate after planning:plan.md, the human reviews it, and either approves (proceeding to implementation) or sends it back for revision.
Adapting for your project
To use this pattern:- Write your spec as a Markdown file in the repo (e.g.
docs/spec.md) - Write conformance tests that exercise the spec’s requirements via a CLI or test runner. Split them into quick (core paths) and full (everything) suites.
- Wire the Makefile so
make conformance-quickandmake conformance-fullrun the suites and output results - Customize the prompts to reference your spec file, your project’s language and conventions, and your conformance contract
What you’ve learned
- The conformance loop (implement, test, fix, repeat) is the core pattern for spec-driven development
- Two-tier conformance (quick then full) keeps iteration fast
- Shared threads (
thread_id) give the fix node context from prior iterations max_visitsprevents infinite loops when the agent can’t passgoal_gatemakes conformance a hard requirement for workflow success