Spec-driven development with a formally defined process
Spec-driven development with a formally defined process
I build software with AI coding agents, and the process they follow is now a formal definition. Its binding rules are one JSON file, checked against a schema (a second file that describes the shape the first must have), and the agent is handed those rules every time it starts work. It reads almost as a program. This post is about what that gives me: tools can check the process, I could even write a model of its flow by hand and have a checker test it, in my experience the agent strays from it less, and the instructions are just over half the length of my old ones. If you work with an agent and a set of instruction files, some of it should carry over.
The context
Spec-driven development (SDD) means the agent works from written artifacts, a spec, then a design and a plan, before it writes code. In 2026 a handful of tools set the pattern:
- GitHub Spec Kit: a command-line tool and slash commands for specify, plan, tasks and implement, plus YAML workflows with gates (steps where the run waits for a person’s approval).
- Kiro (AWS): specs, plus steering files, Markdown files of project guidance that can be set to load in every interaction. It also has workflow recipes, files that describe a multi-step run.
- BMAD Method: agent personas (analyst, PM, architect, developer, QA) and workflows that go from a brief to stories.
- OpenSpec: a folder for each change the agent works through, and a workflow schema in YAML.
- AWS’s AI-DLC workflows: stage files in Markdown with YAML frontmatter (structured fields at the top of each file).
My setup is one developer and several agent products, meaning coding agents from different vendors: Claude Code, Codex and Cursor. Each piece of work is a work item that moves through four stages: design, implementation, documentation and closure, with one commit per stage. The stages run in Claude Code, each in its own session, which I’ll call a stage session. The work of the first three stages is reviewed by agents from all three products, a group I call the panel. My earlier post describes the panel when it was still a manual habit.
Before this version, the process was a folder of ten instruction documents the agent followed: Process.md, Conventions.md, Collaboration.md and seven procedures for single jobs, such as addressing review feedback or closing an item. It had grown too much, so I started over from scratch, carrying nothing across.
The problem
In all five tools, the agent follows Markdown that it reads and interprets: Spec Kit’s commands and templates, Kiro’s specs and steering files, BMAD’s personas and workflows, OpenSpec’s change folders, AI-DLC’s stage files. Four of them now add structured workflow files that a tool validates. AI-DLC compiles its stage frontmatter into a checked JSON graph. OpenSpec has openspec schema validate. Spec Kit “rejects invalid workflow definitions before the run is created.” Kiro’s recipes are JSON or YAML, checked by its own validator. What they check is the workflow’s structure, such as its step types and order; the instructions inside it, the prompts and stage bodies, are still prose. And among the five I found none that documents a review panel across agent products.
A general critique of SDD tools is that agents don’t reliably follow all those files. Birgitta Boeckeler, writing in 2025 about the tools she tried: “I frequently saw the agent ultimately not follow all the instructions.”
My agent reads and interprets text too. So I split the process in two. The binding rules are what must hold in every stage: the gates, the roles, the naming and the review rules. The steps are how one stage gets done. In my setup the binding rules live in one JSON file that is handed to the agent in every stage session and checked by tools. The steps live in runbooks, short Markdown files that the JSON file names. The rules are still sentences and the steps still Markdown; what changes is where the rules live and that tools can check them.
The solution
A formal definition
One JSON file, workflow.json, holds the binding rules, and its schema checks the file’s shape. It covers:
- the stages, each naming its runbook, and their gates: I sign off on a stage when its review succeeds, and only I move an item on to the next stage;
- roles: a parent session, the one I talk to, drives an item but does no stage work itself; for each stage it starts a child session, the stage session;
- naming conventions, for item folders, commits and review files;
- general rules, such as “Only the user moves an item to its next stage, or back.”;
- how reviews run and when they stop.
Fields refer to each other. A cross-reference is a field naming another field, written {x.y}. For example, a finding is an issue a reviewer reports, and one field, review.finding, sets the bar for which issues are worth reporting: those that “would make the item build the wrong thing, fail, or mislead”. The rule for turning findings down points at that field: “The addresser may reject a finding below {review.finding} as left to the implementer’s judgement.” The addresser is the session that answers a review, deciding what to fix; the implementer is the agent that builds the item. So a finding that falls below the bar can be turned down and left to the implementer.
The steps are not in the JSON. In the words of the process’s reference README, its documentation for people: “a stage’s steps are in the runbook its runbook field names. Any other runbook holds how one step is done, naming the JSON’s fields instead of restating them.” There are thirteen runbooks: one per stage, and the rest for single jobs such as answering a review.
To me it reads almost as a program, I think because its fields have names and refer to each other, and a tool can look its rules up. The agent still reads and interprets it, as it would any text. What the format gives me is this:
- The agent strays from it less. That’s my experience, compared with the old folder of documents. I haven’t measured it.
- Tools check it. The schema checks the file’s shape, and a test checks that every
{x.y}reference, in the JSON and in the runbooks, resolves to a real field. - Formal tools can reason about it. More on this below.
- An agent drew a diagram from it. Once, when I asked, an agent drew the process’s flow from the file.
- One source. The agent’s text and the tools’ checks come from the same file: a hook, a script Claude Code runs on an event, renders it for the agent (next section), and the process’s Python tools, which load it and run reviews, read it from disk.
- Overrides are mechanical. Each project that uses the process has an override, a small file of its own settings. It merges into the definition mechanically and is checked (see the narrow override below).
- A change is a diff. The definition and runbooks are files in git, and a change to the process is a diff to review, made through a work item like any other.
To see how far “formal” goes, I wrote a model of one item’s flow by hand, as a JSON file of events: each stage’s commit, and my sign-off after it. Each event lists preconditions, what it needs to be true when it happens: documentation’s commit needs the implementation sign-off, from the definition’s gates, and each sign-off needs its own stage’s commit. The model also has ordering rules from the definition, which say what comes before what, such as each sign-off coming before the next stage’s commit. A precondition is a claim; the ordering rules are what should guarantee it. I ran it through a consistency checker of my own, a tool that looks for an order of events, allowed by the ordering rules, in which a precondition doesn’t hold. The model checks clean.
My first draft didn’t. It left out that each sign-off comes after its own stage’s commit, and the checker reported three errors, one per sign-off: a sign-off could come before the work it signs off. That was a gap in my hand-written model, not in the definition. Then I dropped one ordering rule on purpose, the one that puts the implementation sign-off before documentation’s commit, while documentation’s commit still required that sign-off. The checker reported it with a witness, an order of events that breaks it:
item-flow-gate-removed.json:/events/4/requires/0: W001 error: approved(implementation) may fail at commit_documentation: never established
witness: commit_design -> approve_design -> commit_implementation -> commit_documentation
item-flow-gate-removed.json: 1 error, 0 unused
The rest of the output is the checker’s codes and a summary. In plain words: in that model, documentation can be committed before I’ve signed off the implementation, by the order on the witness line. Two limits. The model is mine, written by hand, so what the checker checked was my model of the file. And it tests consistency only: had I dropped the precondition as well, so documentation’s commit no longer needed the sign-off, the model would check clean again. Whether a gate belongs there is still my call.
I haven’t seen this documented elsewhere: one file for every stage holding gates, roles, naming and review rules, checked by a JSON Schema, with the runbooks’ references into it tested, and handed to the agent in every stage session.
Loaded every session
A hook is a script Claude Code runs on an event, and a SessionStart hook runs when a session starts. Mine is a Python script that hands Claude a rendering of the definition: the fields only the tools read, such as the reviewer list, are left out, and the project’s override is merged in. It runs on start, on resume, on clear (when the conversation is emptied) and on compaction (when Claude Code condenses a long conversation to free up room), so every stage session has the rules, even after a compaction. I checked all four cases by hand in a scratch project.
The rendering has to fit a character budget: the hook refuses anything over 9,500 characters. Claude Code caps a hook’s context at 10,000 characters, and past that it moves the text to a file and gives Claude a preview of it. In the repo I write these posts in, the rendering is 7,881 characters; it varies a little from project to project, since each project’s override is merged in. If the definition fails to load (a bad override, an oversized result, a missing definition, an old Python), the hook tells Claude so, and that it must tell me before anything else.
Reviewers run as separate sessions in their own copy of the work. They don’t get the rendering; each gets a brief and the change’s diff instead.
Review rules
A review round is one pass of the panel over a stage’s work. Each finding carries a severity: Blocker, Major, Minor or Nit. A finding is upheld when it’s fixed or deferred (written down as a backlog entry for later) rather than turned down. A review has a budget, a limit on rounds, which is a different thing from the hook’s character budget. The review rules are written as sentences, not bare numbers, and they cover when rounds are converging (findings getting fewer or less severe), when a review has failed and when it has succeeded. The success rule, as the file has it:
Two rounds in a row within the budget with nothing upheld above Minor, whatever their counts.
That is, two rounds in a row with only Minor or Nit findings upheld, however many. Google’s Elephant-Goldfish Model (EGM), a design-doc workflow for agents published on Google’s GitHub, has a similar rule in its review-loop skill: “Two consecutive clean rounds.”
When a review doesn’t succeed, it goes back to me, so running out of rounds is never taken as success. Kiro’s workflow docs make the same choice in an example loop, where “the cap pauses the run instead of declaring success.”
The panel
Six reviewers run by default across the three agent products: three Claude models in Claude Code, two models in Codex and one in Cursor, each reading the same stage’s work on its own. Among the five tools I found no review panel across agent products; some smaller projects send reviews to other agent products, credited below. The earlier post covers why I review this way.
A narrow override
A project’s override can change only ten extension points, such as the project’s test command, extra review checks and extra steps in a stage. The hook script’s check accepts nothing else, so a project can’t change anything else. BMAD does something similar: a project overrides only the fields each of its skills (packaged agent tasks) exposes.
It develops itself
There are two copies of the process: a dev copy, where changes are made, and a live copy that every project of mine runs on. A change to the process is a work item in the dev copy, with the same stages and reviews as any other, and closing the item copies the dev copy into the live one. OpenSpec is built with its own tool too: it “is built with OpenSpec.”
What isn’t new
Spec-first stages, approval gates, instruction files and hooks are standard. Smaller projects do parts of the rest: Flowspec ships a JSON Schema for its workflow file, superpowers re-injects its starting instructions by hook, GSD (archived June 2026) writes rules for when a revision loop stops, and anywhere-agents, Chorus and Spec Kitty send reviews to other agent products.
The figure sums up how this setup compares with the five tools:
What I didn’t expect
Less text
Today’s definition and runbooks come to 32,599 characters. The ten documents they replaced came to 57,943, measured from a private backup of the old process. That’s just over half. Both sides count only the instruction files the agent follows. The new process keeps its reasons and decisions in a README that I didn’t count, so the claim here is about the instructions alone. And in a session the agent is handed less than the new side’s 32,599: the hook’s rendering, 7,881 characters in the repo I write these posts in.
Tight prose
Keeping the rendering under the budget is what set my goal of minimal, tight instructions. The aim is to give agents less to misread; I haven’t measured whether it does. In practice that means bulleted lists, short and clear instructions, no justifying a rule inside it, no restating, and no noise. The runbooks aren’t loaded by the hook, so they sit outside the budget, but they follow the same style. Two lines from the runbook every stage session (a child) follows:
- “Run only the child’s stage.”
- “Leave no notes for the next child: what the next stage needs goes into the item’s docs.”
The item’s docs are its written spec, design and plan, kept in the item’s folder.
Reviewers needed a bar
Early on, a design review didn’t settle: reviewers kept reporting decisions left open, and each round answered them with more specification. The finding counts over its first four rounds were 26, 30, 20 and 16. Now the definition sets the bar for what reviewers report, and a detail an implementer can settle sensibly falls below it.
If you want to try it
You don’t need the whole thing:
- Put the binding rules of your process in one structured file with a schema, and keep the steps in short files it names.
- Load the rules into every session with a hook, under a budget, so the agent has them from the start and again after a compaction, without having to open a file first.
- Write your review stop rules as sentences, and tell reviewers what is worth reporting.
- If you can describe your flow in a tool that checks orderings of events, such as a model checker, write the model by hand and run it, then drop one ordering rule on purpose and see whether the checker names it.