Spec-Driven Development for Coding Agents

Spec-Driven Development for Coding Agents

When an agent writes the code, the spec carries the intent. Observable outcomes, hard constraints, explicit non-goals, test-ready acceptance criteria — and the drift problem.

When an agent writes the code, the specification is your clearest expression of intent — and the quality ceiling of everything the agent produces. An executable spec states observable outcomes, hard constraints, explicit non-goals, and acceptance criteria concrete enough to become tests. Spec effort scales with task size, durable specs drift like documentation unless reconciled in the same change, and no spec replaces the decisions you have not made yet — or the review at the end.

Why the spec became the work

A vague instruction to a human engineer fails loudly. They ask questions, push back, or stall — the ambiguity surfaces before it becomes code. A vague instruction to a coding agent can fail silently. The agent may stop and ask instead — as of November 2026, Claude Code documents an AskUserQuestion tool that asks multiple-choice questions to gather requirements or clarify ambiguity — but when it does not ask, it fills the gaps with plausible assumptions and can return confident, well-formatted code that solves a slightly different problem than the one you had. The output may not announce the divergence; you find it in review, or worse, after the merge.

That asymmetry is why specification stopped being overhead and became the work itself. When generation is cheap, the scarce input is a precise statement of what should exist afterward. The goal is not a clever prompt; it is a task statement that would survive being handed to a contractor who never asks follow-up questions.

Spec-driven development, in this narrow sense, is a discipline rather than a tool. As of November 2026, some products build the spec into a file format and a workflow (Kiro, for example, generates a requirements or bugfix file, a design file, and a tasks file for every spec); some teams keep specs in issues or task descriptions; an agent prompt typed into a terminal is a spec with a lifespan of one session. The discipline — deciding what must be true before asking for code — applies identically across all of them, which is why this article is about what the spec says, not where you type it.

What an executable spec contains

Four elements separate a spec an agent can execute from a wish it will interpret.

State behavior as observable outcomes, not implementation instructions. "Users see their saved filters on the dashboard after a reload" gives the agent a target it can verify against; "store the filters in localStorage inside the dashboard component" makes a design decision you may not have wanted to make, while leaving the actual goal unstated. Describe what must be true when the work is done, and reserve implementation directives for the places where the choice genuinely matters to you.

State the hard constraints. Every codebase has invariants the task must not disturb: interfaces that must not change, dependencies that must not be added, an existing helper that must be used instead of reinvented. An agent may find some of these by reading the code, but it cannot respect a constraint that exists only in your head — an unwritten dependency policy, for example, is not something it can infer from silence.

State the non-goals out loud. This is a cheap defense against over-engineering. Asked to add a field to a form, an agent may also restructure the validation, extract a reusable form abstraction, or add a configuration option for a future you did not plan. One line — "no refactoring of the existing validation; no new abstractions" — puts that whole branch of unwanted work out of scope before it is generated, instead of cutting it after.

Make acceptance criteria concrete enough to become tests. "Works correctly" is not checkable; "the saved filter persists across reload, the empty state is unchanged, and existing dashboard tests stay green" is. A criterion that resists being restated as a test may be hiding an undecided question.

One minimal spec, shown as shape rather than template:

text
Outcome:      Users see their saved filters on the dashboard after a reload.
Constraints:  Do not change the /filters API contract. No new dependencies.
              Use the existing useLocalStorage helper for persistence.
Non-goals:    No migration of legacy filter formats. No refactor of
              dashboard state management.
Acceptance:   Saved filter persists across reload. Empty state renders
              unchanged. Existing dashboard tests stay green.

Nothing about the format is sacred. The four elements are.

Granularity: matching spec size to task size

A structured spec for a one-line fix is ceremony; a one-line spec for a cross-cutting change is negligence. The judgment is matching spec effort to the task, and it follows the stakes.

Task shapeRight-sized specExample
Mechanical, single-siteOne precise sentenceRename this function and update its call sites
Contained feature workThe four elements, brieflyThe saved-filters spec above
Multi-file or judgment-adjacentFull spec, written before any generationA permissions change touching API, UI, and tests

The reliable smell of a spec grown too large: acceptance criteria you could not verify in one review sitting. A spec whose outcomes take an afternoon to check is describing several tasks wearing one name, and the agent's output can be an unreviewable diff to match. Decomposing one intent into several agent-sized specs — each independently verifiable, each landing separately — is engineering work to own rather than hand off. Some spec tools can generate a task breakdown from a spec (as of November 2026, Kiro writes discrete tasks to tasks.md and, when you run all of them, works out which tasks depend on each other; GitHub's Spec Kit has you run agent skills one at a time, reviewing each result before continuing, to turn a specification into a plan, tasks, and working code), but deciding which risks to split out and in what order to land the pieces is a judgment about risk and sequencing, not syntax.

Decomposition also compounds: small specs produce small diffs, small diffs get real reviews, and real reviews are the stage the whole delegation loop depends on.

Where specs live and how they drift

Two lifespans, two disciplines.

An ephemeral spec — the task statement you give an agent for one piece of work — lives exactly as long as the task. Its only obligation is precision at the moment of delegation. Much delegated work needs nothing more, and promoting every task prompt into a durable document is process for its own sake.

A durable spec — a file in the repository describing how a subsystem should behave — earns its keep differently. It orients future work, human and agent alike, and a working hypothesis, not a documented rule, is that agents that read it treat it as authoritative long after everyone else has stopped reading it. That trust is the risk: durable specs drift from the code exactly the way documentation does, and a stale spec is worse than none, because it feeds every agent session that reads it a confident falsehood. An agent given last year's spec can produce last year's behavior, cleanly implemented.

The workable discipline is reconciliation in the same change. When an implementation legitimately diverges from a durable spec — a constraint turned out wrong, a better boundary emerged — the spec update lands in the same commit as the code that diverged. Deferred reconciliation is drift with a to-do attached. If a durable spec has been misleading for a long time and nobody noticed, that is also information: it was not orienting anyone, and deleting it is more honest than maintaining it.

The honest limits of a spec

A spec cannot contain judgment you have not exercised. Writing one surfaces the open decisions — where the boundary sits, what happens on failure, which behavior is load-bearing — but surfacing them is all it does. An engineer who delegates before deciding has not skipped the decision; they have transferred it to a system that can make it silently and plausibly. If writing the spec feels hard, that difficulty is the actual task announcing itself.

Over-specification has a cost too. A spec that dictates every implementation detail recreates the typing bottleneck in prose and discards what generation does well — producing a competent draft within stated constraints. The skill is choosing what to pin down: outcomes, invariants, and boundaries pinned tightly; mechanics left to the agent and judged in review.

And the spec never removes the review. A precise spec narrows the space of wrong outputs; it does not empty it. The agent can misread a criterion, satisfy the letter of a constraint while violating its intent, or introduce a defect in territory the spec never mentioned. Specification and review are the two ends of the same loop — what the spec promises, the review verifies — and investing in one is not permission to skip the other.

For teams commissioning work as much as writing it, the same frame holds: the precision of what was asked for bounds the quality of what comes back — from an agent or a vendor — and the review still has to check what arrives.

Project Inquiry