Insights Business| SaaS| Technology Spec-Driven Development: Why Contracts Come Before Code in AI-Assisted Teams
Business
|
SaaS
|
Technology
•
Nov 30, 2026

Spec-Driven Development: Why Contracts Come Before Code in AI-Assisted Teams

AUTHOR

James A. Wondrasek James A. Wondrasek
Spec-Driven Development and Why Contracts Come Before Code

AI coding agents write code in seconds. The software still misses what you meant.

Most teams have settled on the default of describing what they want in natural language and accepting whatever comes back. Call it prompt-first coding, or vibe coding if you prefer the catchier name. It’s fast and it’s low friction, and for a weekend prototype it works nicely.

Then you put it in front of paying customers, and the thing you asked for isn’t quite the thing you got. Nobody can say where the disconnect happened, because nobody agreed in advance what the right answer looked like. The practices built to close that gap are mapped in the wider spec-driven delivery picture.

That’s the gap spec-driven development exists to close. It proposes an ordering where a written, machine-readable contract gets agreed before a single line of generated code exists.

Spec-driven development vs vibe coding: what do you trade off?

Vibe coding keeps your intent in a chat thread and judges the result by feel. That’s what Karpathy described in February 2025: give in to the vibes, accept all, don’t read the diffs. As he later admitted about his own “forget the code exists” advice, accepting everything works right up until it doesn’t.

The trade is simple to state. You get speed up front because there’s no specification overhead. You give up the ability to check the outcome against any decision you made beforehand, which means drift is only discovered in review, in churn, or in production.

Vibe coding is the right call for prototypes, scripts and internal tools where you don’t care if the code is a mess. It’s the wrong call when the work is production, regulated, or spread across several handoffs.

GitClear’s analysis of 211 million lines found code duplication grew roughly fourfold between 2020 and 2024 while refactoring fell by 60%. None of that is attributable to vibe coding alone, but it’s the shape of technical debt that unverified output produces.

Where does translation loss actually happen in AI-assisted development?

Translation loss is meaning lost as an idea travels. The Microsoft developer blog names it precisely: teams “ship software that works but still misses the original intent,” and the problem is “the loss of meaning as ideas move from stakeholder needs to requirements, architecture, implementation, and validation.”

There are three gaps that matter here.

Gap one sits between what a human means and the artefact that encodes it. Requirements get written down as prose and drop the edge cases, the constraints, the reason behind a decision.

The next gap is between that artefact and the generated code, and it cuts two ways. An agent cannot judge what it is given, so it will turn an underspecified spec into code without noticing the spec was incomplete. It also drifts on its own, the failure mode the Allegro team calls intent drift: hallucinating endpoints, completing phantom features, making the reasonable-looking choice you never wanted.

The last gap is between the code and verified behaviour. The code runs, but nobody ever checked it against what was originally intended. It got reviewed and merged, and neither step involved comparing the code to the agreed intent.

Faster generation makes all of this worse by producing more unverified output at the same rate of loss.

Spec-driven development pins the intent down before any of those gaps can open.

What is spec-driven development?

Spec-driven development (SDD) is the practice of authoring a structured, machine-readable specification and reviewing it before any code gets generated. That specification becomes the single source of truth driving code, tests, documentation and agent behaviour.

As the team at Taskade put it, code got cheap, saying what you mean did not. Which is why the specification becomes the durable asset and the generated code becomes the replaceable output, much as a compiled binary is derived from source code. You change the source and rebuild; you don’t edit the binary by hand.

SDD is the umbrella term for the practice, and the specification is what it produces. Machine-readability is the thing that separates a spec from a paragraph of natural language sitting in a prompt.

SDD depends on an ordering principle that has its own name.

What does “contracts before code” actually mean?

Contracts before code means a formal contract, an interface, a schema or a requirement set, gets agreed and written before implementation begins. Code serves the contract. The contract doesn’t get reverse-engineered from the code afterwards.

If your team has ever written an OpenAPI document before implementing an API, defined a Protobuf schema before a gRPC service, or authored a JSON Schema before accepting user input, you’ve already done this. Contract-first, API-first and design-first development all apply the same discipline before implementation begins, and SDD extends that discipline across the full lifecycle to cover schemas, event contracts and agent behaviour. The spec-driven delivery cluster carries that ordering through the rest of the lifecycle.

The formats have a stable home. The Linux Foundation has become the neutral home of almost all the open API specification standards: OpenAPI and AsyncAPI under their own initiatives, JSON Schema under open foundation governance at the OpenJS Foundation, and Protobuf and gRPC through CNCF. That neutral stewardship makes shared tooling and verification possible across teams.

Kirill Velikanov makes the point well: the spec has to be unambiguous enough that an AI agent cannot misread it.

Event modelling is the same idea applied elsewhere. It models events before entities and state, and an event-based model keeps the history of changes alongside the current snapshot.

What is the difference between a spec as a governing artefact and a spec in the prompt?

The same words can sit in a prompt or exist as an approved specification. The difference is the status they carry.

A governing artefact carries a review gate where a human approves it. It holds authority over everything downstream, and it supports drift detection, so you can tell when code has wandered from it. Prose in a prompt goes through no approval or review, so it cannot be used to check the code.

InfoQ’s analysis of when SDD pays off describes this as treating the spec “as a governing artifact rather than inline prompt text,” where the outcome moved because authoring and implementing happened in separate generation steps.

A JSON Schema is a useful part of this, but it only checks shape. It can confirm that fields are present, correctly typed and holding allowed values, and it has no way to decide whether the content is correct. Governance happens in the verifier, where policy, approval and schema get turned into a yes or no before the agent acts.

The approval gate turns a specification into a baseline that generated code can be checked against. Keeping that baseline current is a loop of its own, and specification governance covers it. The return on that effort is set out in what an approved baseline actually buys you.

Why has the bottleneck shifted from writing code to verifying code?

Generation is now cheap and fast. Verifying that generated code matches what was intended is slow, human and scarce. That’s where your review time is going, and it’s a cost your business is already paying.

38% of developers report that reviewing AI code takes more effort than reviewing a colleague’s. The VS Code team roughly doubled its commit volume year on year after full AI adoption while review times rose 91%, and LinearB found AI-generated pull requests wait 4.6 times longer in review than human-written ones.

Agents execute fast but they can’t resolve ambiguity you left in. When the intent was unclear, the checking moves upstream to the specification, which is the only place ambiguity can be decided.

A machine-readable contract makes the check automatable. Contract tests, conformance gates and CI/CD validation can catch divergence without anyone eyeballing it. Without a spec to check against, your reviewers end up reading the code and trusting the model.

How does spec-driven development relate to test-driven development?

Both put intent into an artefact before the implementation exists. The difference is the level each one works at.

TDD writes a failing test for one unit of behaviour and cycles through Red-Green-Refactor. SDD writes a spec for a whole feature that sets out the interface it exposes, the contract it has to honour and the requirements behind it. Tests pin the behaviour of one unit, and specs pin the contract the whole feature operates inside, so the two complement each other.

TDD answers “does this unit do what I just claimed?”, and SDD answers “did we build the thing we agreed to build?”

BDD sits between them. It grew out of TDD in 2006, when Dan North introduced Given-When-Then and Gherkin as a shared artefact that product, QA and engineering could all read. Given-When-Then turns spec scenarios into executable behaviour checks. The strongest teams run SDD at feature level to agree what’s being built, TDD at unit level for design feedback, and borrow BDD phrasing for acceptance criteria.

Is spec-driven development just waterfall making a comeback?

No, the objection usually assumes the spec is written once at the start and never revised.

Waterfall fixed requirements for an entire system up front and learned late whether they were right. SDD specifies one slice at a time and learns from each before writing the next. As Thoughtworks’ Liu Shangqi describes it, SDD provides shorter feedback loops than pure vibe coding.

The spec stays alive. Birgitta Böckeler’s three levels, spec-first, spec-anchored, spec-as-source, describe increasing authority. At spec-first the spec is written before a change and not maintained. At spec-as-source, humans only edit the spec and code regenerates from it.

SDD isn’t free. Colin Eberhardt built the same feature around ten times faster without SDD, and the same write-up describes one test project that produced 689 lines of code against 2,577 lines of Markdown. Whether that ratio is waste or the point is the argument at the centre of SDD. Where a full framework is too heavy, plan mode is the lighter alternative: the agent interviews you, writes the result to a spec file, and a fresh session implements it.

Where this leaves you

Verification only works against something you agreed in advance, and that agreement has to be recorded as a contract before the first line of code exists.

A spec only governs through review, approval and a gate, and that institutional status makes verification automatable. The question worth asking of any AI-assisted build changes from “can we generate this faster?” to “did we agree the contract first, and can the code be checked against it?”

Frequently Asked Questions

How do I get started with spec-driven development?

Start small. Pick one feature, write the contract before the code, and review it with the people who will judge the result. A simple machine-readable spec in OpenAPI or JSON Schema is enough to begin. Then let the AI generate against it and check the output against the contract. Don’t overhaul your process first. The ordering matters more than the tooling.

Do I still need to review generated code if I have a spec?

Yes, but the review changes. You stop eyeballing every line for intent and start checking the code against the contract. Much of the mechanical checking can be automated through contract tests and CI/CD gates, so it disappears. Human review then focuses on the things the spec cannot capture: whether the contract itself is right, and whether the code behaves in ways nobody anticipated.

What does “machine-readable” actually mean, and why does it matter?

It means the spec is written in a formal format a tool can validate against, such as OpenAPI or JSON Schema, rather than free prose. That precision removes the ambiguity that lets generated code drift. When a spec is machine-readable, conformance can be checked automatically, so the gate is the contract’s precision, not a human reading between the lines or the model’s intelligence.

What happens if the spec and the code drift apart?

You lose the one thing the spec buys you: something to check the code against. A spec only governs while it stays in sync with the system, so drift is a signal, not a nuisance. Either the code is wrong and needs to change, or the spec is stale and needs revising. The fix is drift detection and reconciliation as a continuous loop, not a one-off clean-up. A living spec is the goal.

Can I retrofit spec-driven development to an existing codebase?

Yes, but you don’t re-spec the whole system at once. Pick the next change or the next risky integration, write the contract for that boundary first, and generate against it. Over time the pieces you care about become spec-anchored while the rest stays as it is. It’s a migration, not a rewrite. Contract-first discipline works at any boundary, even inside an older system.

Who should own and review the specification?

The people who can judge intent. That is usually the product owner or a domain expert, together with the engineers who will build against it. The spec carries authority through human review and approval, not through the text itself, so someone must be accountable for agreeing the contract before code exists and for keeping it current. Without that owner, a spec is just prose in a file.

Is spec-driven development the same as design-first or API-first development?

Not quite. SDD descends from design-first and API-first development and shares their contract-first discipline, but it applies the idea more broadly. API-first focuses on interfaces like OpenAPI or AsyncAPI; SDD treats any structured, machine-readable agreement, a schema, a requirement set, or an event model, as the governing contract. It is a continuation of that lineage, extended to everything an AI agent generates against.

How is a spec different from ordinary documentation?

Documentation describes; a spec governs. A spec carries a review gate, authority over downstream work, and drift detection against it. Documentation can sit out of date and nobody’s code changes as a result. When a spec drifts from the code, something is wrong and must be reconciled. That is why the spec is the durable asset in spec-driven development and the generated code is the replaceable output. Status, not wording, is the difference.

Can spec-driven development work with AI coding agents, or does it slow them down?

It makes them more useful, not slower where it matters. An agent produces exactly what it is given without judging whether it is correct, so its output is only as good as the contract it executes against. A reviewed, machine-readable spec gives the agent something precise to follow, and its output can then be checked automatically. The agent’s speed was never the bottleneck. Verifiable intent is, and the contract supplies it.

How do I keep the spec up to date as the system evolves?

Treat it as a living artefact, not a frozen phase gate. Revise the spec whenever learning accrues, and keep it in sync with code as the system changes. Fold spec review into your normal change process rather than treating it as a separate document. The three maturity levels, spec-first, spec-anchored, and spec-as-source, describe increasing authority, not frozen design. Where a full framework is too heavy, plan mode is the lighter alternative.

AUTHOR

James A. Wondrasek James A. Wondrasek

SHARE ARTICLE

Share
Copy Link

Related Articles

Need a reliable team to help achieve your software goals?

Drop us a line! We'd love to discuss your project.

Offices Dots
Offices

BUSINESS HOURS

Monday - Friday
9 AM - 9 PM (Sydney Time)
9 AM - 5 PM (Yogyakarta Time)

Monday - Friday
9 AM - 9 PM (Sydney Time)
9 AM - 5 PM (Yogyakarta Time)

Sydney

SYDNEY

55 Pyrmont Bridge Road
Pyrmont, NSW, 2009
Australia

55 Pyrmont Bridge Road, Pyrmont, NSW, 2009, Australia

+61 2-8123-0997

Yogyakarta

YOGYAKARTA

Unit A & B
Jl. Prof. Herman Yohanes No.1125, Terban, Gondokusuman, Yogyakarta,
Daerah Istimewa Yogyakarta 55223
Indonesia

Unit A & B Jl. Prof. Herman Yohanes No.1125, Yogyakarta, Daerah Istimewa Yogyakarta 55223, Indonesia

+62 274-4539660
Bandung

BANDUNG

JL. Banda No. 30
Bandung 40115
Indonesia

JL. Banda No. 30, Bandung 40115, Indonesia

+62 858-6514-9577

Subscribe to our newsletter