12 min read
Spec-driven development in practice
How a written spec drives the AI agents that build our software, on one real project
Mario Jurić · Posted on December 4, 2026
Spec-driven development is a way of building software with AI agents in which a written specification, kept in the repository, is the source of truth: agents build from it, reviewers check against it, and it changes before the code does. The prompt starts a session. The spec outlives it.
We have built this way for a year, on every project, inside the delivery engine we described in the AI software factory. This post is the practical half: what a spec has to settle, how the loop runs on Claude Code, one project from start to finish, and the bug that taught us the most.
Why a prompt is not enough once agents write the code
An agent that is asked for a feature produces a feature. It satisfies the request in front of it, and the cheapest way to satisfy a request is usually new code that works today. That is fine for a prototype and it is how codebases fill up with three versions of the same thing.
A spec changes what the agent is satisfying. Instead of "add campaign scheduling", the agent gets a document that says what scheduling is in this product, which data it touches, which decisions it must respect and how anyone will know it works. The same document is what the reviewing agent grades against afterwards, so the work and the check cannot drift apart.
The second reason is memory. Agent sessions end, context windows fill, and a model starting fresh knows nothing about why the last change was made. A spec in the repository is the working memory that survives all of that. It is also the only kind of documentation we have found that stays true, because it changes in the same commit as the code.
What a spec has to settle before an agent starts
The format matters less than the questions. Ours answer these, in roughly this order:
What changes, and why. One paragraph a non-engineer can read. If nobody can write it, the work is not ready to start, and no amount of agent speed fixes that.
The data. Which entities are created or changed, with their fields and types. This is where most of the expensive mistakes are made, so it is where most of the human time goes.
The contract. What the rest of the system, or an outside client, can rely on: the shape of inputs and outputs, the errors, the permissions.
How it will be checked. Acceptance criteria written so that a machine can run them where possible, and so that a person can judge them where not.
What it must respect. Links to the earlier decisions this change depends on. We keep those as a numbered decisions ledger in the repository, so an agent can read why something is the way it is before it tries to change it.
Then the spec gets a place for the verdict: the reviewing agent writes its architectural review into the spec itself, so the history of a change sits next to its intent.
How the loop runs on Claude Code
Every unit of work gets its own SPEC.md, maintained by one agent whose only job is the spec. It writes no code. The roadmap, the initiatives that group specs together and the decisions ledger are owned by another agent, the project manager, which is consulted before substantial work starts. A hook checks that it was.
Implementation is split by layer: database, domain logic, server, interface. Each layer has its own agent, and each agent reads the spec before it touches a file. When the work is done, an auditor agent reads the change against the same rules the implementers were given and writes its verdict into the spec. A hook refuses to let a session end without that review running.
An index of every spec, initiative and decision is compiled automatically after every edit by a small script that no human or agent writes by hand. Nobody maintains a status page. The status is whatever the repository says.
None of this needs anything exotic. Claude Code gives you the pieces: subagents for the lanes, hooks for the checks that must happen every time, skills for the workflows that only matter sometimes. The essay on our software factory goes through each one and the order we would set them up in.
One project, start to finish: eight hours of spec, two to three days of build
Mailoo is a drip email campaign engine with no screens at all: you run it by asking an AI assistant, which calls its 21 MCP tools. It was internal R&D, never deployed to customers, which made it a clean test of the method.
The specification took eight hours of human time, spent almost entirely on deciding rather than producing. It happened in one conversation with Claude Opus, fewer than ten messages, each one constructed rather than typed. Out of it came the data model and fifteen design principles for how the tools should behave.
Our delivery pipeline built and shipped the working system from that spec in two to three days, followed by a few hours of conversation to polish the flow.
Then it failed in the most instructive way available. We shipped twenty-one tools and Claude Desktop could not create a single campaign. The field that held each step's settings was an open, untyped object, so the assistant had no way to know what belonged in it. It guessed, and every guess was rejected.
The principles document said never to put typed data behind an untyped field. The data model, written an hour later in the same conversation, said the opposite, and explained why it was simpler. Both were loaded. The agents implemented the data model faithfully and broke the principle completely.
The fix took hours. The lesson changed how we write every spec since: the storage model and the interface contract now live in one document, and any disagreement inside a spec is resolved before anything gets built. If two parts of your spec can contradict each other, assume the agents will pick one, and assume you will not like which.
The same file had a quieter problem. The data model carried screen coordinates for a visual editor that Mailoo does not have, because it had been checked against five products that are all operated by dragging boxes around a canvas. Nobody decided to put those fields there. Assumptions travel with the examples you design from, so read your spec for the ones you did not choose.
What spec-driven development does not solve
Honest limits, because the method is often sold without them.
A correct structure is not a correct result. Our gates catch a change that crosses a boundary, skips a step or breaks a type. A change that is structurally perfect and functionally wrong can still get through. Writing acceptance checks a machine can run narrows that gap; it does not close it.
Agents grade their own homework generously. A model asked to write tests will write hundreds that pass and check very little. The spec has to say what a meaningful check is, and a person still has to look.
Review becomes the bottleneck. When agents produce a day's work in an hour, the human reading the change is the slowest part of the line. A good spec makes review faster, because the reviewer checks the change against a short document instead of reconstructing intent from a diff, but it does not make the volume go away.
It is wrong for early exploration. When nobody knows yet what the product is, writing specs slows down the learning. We keep very early ideas outside the process until they are clear enough to be worth specifying.
How to start on your own project
- Put one SPEC.md per change in the repository, next to the code it describes, and make the agent read it before it writes anything.
- Write the acceptance checks first and make as many of them runnable as you can.
- Keep the data model and the interface contract in the same document. Contradictions inside a spec turn into bugs faster than anything else.
- Keep a decisions ledger: short, numbered entries that say what was decided and why. Link specs to the decisions they depend on.
- Have a reviewing agent grade every change against the spec, separately from the agent that wrote it, and record the verdict in the spec.
- Spend the human time on the spec. On Mailoo it was eight hours against two to three days of building. That ratio is the point.
If you want this set up for your own team, that is work we do: AI software factory development for a team's whole delivery process, or agent harness development for one agent that has to be trusted to run on its own.


