Specification-Driven Development: Align on Requirements Before Writing Code

    This article explains why collaborating with large language models often stalls on unclear requirements rather than code, and how Specification-Driven Development (SDD) addresses three structural gaps: semantic ambiguity, missing implicit constraints, and absent acceptance criteria. It walks through the four-stage SDD model (proposal, spec delta, tasks, archive), a sample repository layout, a reusable spec template based on scenarios and acceptance conditions, and the delta-merge plus automated validation mechanisms that keep documentation from rotting. It also covers tool-agnostic team adoption practices, common pitfalls, and signals for measuring the payoff.

    1. Where the Problem Starts: Why Working with LLMs Feels Like a Tug-of-War

    When you build with AI coding tools and large language models, one pattern keeps repeating: the time sink is not writing code, it is stating the requirement clearly. A developer describes the goal in a paragraph of natural language, the model produces a first implementation, and then a long round of back-and-forth begins. Edge cases were not considered, exception paths were not covered, data formats were never agreed on, and performance and compatibility expectations were left unwritten. Every round re-explains the context, the cost is spread across countless exchanges, and the final quality depends heavily on luck and prompt-engineering skill.

    Abstracted, the problem comes down to three structural gaps:

    • Semantic uncertainty: Natural language allows omission and ambiguity, so the same word maps to different implementations in different people’s heads.
    • Missing implicit constraints: Non-functional requirements (performance, security, observability, compatibility) rarely show up in a requirement description on their own, yet they determine whether an implementation is actually usable.
    • No acceptance criteria: Without a decidable definition of done, “it’s finished” becomes a subjective judgment and rework is inevitable.

    The core claim of Specification-Driven Development is to close these three gaps before any code is written: produce a structured specification first, making the goal, scope, constraints, and acceptance criteria explicit, so the implementation phase has something concrete to follow.

    2. The Basic Model of Specification-Driven Development

    The whole flow can be understood as four stages, with the specification as the single source of truth running through all of them.

    1. Proposal: State why the work is being done, what problem it solves, and what is out of scope. Scope boundaries are written down explicitly at this step to prevent later creep.
    2. Spec Delta: Describe the concrete impact of this change on system behavior, including new capabilities, modified behavior, and deprecations.
    3. Tasks: Translate the specification into executable, verifiable work items, each traceable back to a specific spec entry.
    4. Archive: Once the change is complete, merge the delta into the baseline specification to form a traceable history.

    A representative directory layout looks like this:

    1. project/
    2. ├── specs/ # baseline specs, long-lived
    3. │ └── auth.md
    4. ├── changes/ # change workspace
    5. │ └── add-refresh-token/
    6. │ ├── proposal.md # goals, scope, non-goals
    7. │ ├── tasks.md # executable task list
    8. │ └── specs/ # spec delta for this change
    9. │ └── auth.md
    10. └── AGENTS.md # collaboration conventions for AI tools

    The key value of this structure: during a change, the spec and the code live in the same repository, so a reviewer can decide before merging whether a behavior change has been explicitly declared, instead of reverse-engineering the intent from commit history after the fact.

    3. What a Spec Should Contain: A Reusable Skeleton

    A spec is not a relocated requirements document. It should be the minimal unit of description that is decidable and testable. A recommended form for each capability entry is “scenario + preconditions + behavior + result”:

    1. ### Capability: Refresh access token
    2. #### Scenario: automatic renewal after token expiry
    3. - Precondition: holds a valid refresh token, access token has expired
    4. - Behavior: use the refresh token to request a new access token
    5. - Result: return a new token pair, the old refresh token is invalidated
    6. #### Scenario: invalid refresh token
    7. - Precondition: the refresh token has been revoked
    8. - Behavior: attempt renewal
    9. - Result: return an authentication failure, the client redirects to re-login

    Four principles are worth holding to when writing:

    • Decidable: Every entry can be turned into a test case; avoid unverifiable phrasing such as “as fast as possible” or “reasonably friendly”.
    • Single responsibility: One entry describes one behavior, which makes conflicts and omissions easy to locate.
    • Explicit non-goals: Writing down what this change will not handle is the most effective way to control scope creep.
    • Non-functional constraints belong in the spec: Response latency targets, concurrency levels, logging and monitoring instrumentation requirements, and data retention policies should be entries, not verbal agreements.

    4. Delta Specs, Validation, and Archiving

    For Specification-Driven Development to stay usable over time, it has to solve the documentation-rot problem. Two mechanisms usually do the work.

    Deltas and merging. Each change writes only the difference, which is merged into the baseline once complete. Review load stays small, the evolution of history stays clear, and when something breaks you can pinpoint exactly which change introduced a given behavior.

    Automated validation. A lightweight script checks structural completeness before commit, for example:

    1. # Pseudocode: validate change directory structure completeness
    2. required = ["proposal.md", "tasks.md", "specs/"]
    3. for change in list_changes():
    4. for path in required:
    5. assert exists(change / path), f"{change} is missing {path}"
    6. assert has_acceptance_criteria(change), "missing decidable acceptance criteria"

    Archiving runs only after validation passes, merging the delta into the baseline. Wire this step into the CI pipeline and spec quality shifts from “depends on discipline” to “enforced by a gate”.

    5. Multi-Tool Collaboration and Team Adoption

    In practice, teams mix different AI coding tools and editors, and this is exactly where the value of specs stands out: a spec is a tool-agnostic plain-text asset, so any model or tool that can read the repository consumes the same context. Adoption recommendations:

    • Maintain a collaboration-conventions file for AI tools at the repository root, covering code style, directory responsibilities, prohibited practices, and commit requirements, to cut down repeated explanation in every conversation.
    • Agree on read/write boundaries per role: product and QA focus on spec entries and acceptance conditions, engineering focuses on task breakdown and implementation.
    • Keep spec review and code review separate but linked: first review whether the behavior is correctly declared, then review whether the implementation matches the declaration.
    • Keep initialization lightweight and introduce no secret configuration, so the process is not blocked by environment setup.

    6. Common Pitfalls and Measuring the Payoff

    Three typical misuses are worth avoiding: writing specs as bloated documents nobody maintains; documenting only the happy path while ignoring exceptions and boundaries; and letting specs drift from the implementation, so the baseline is never updated after merge.

    To gauge the payoff, watch a few signals: whether the number of requirement-clarification rounds drops, whether the share of rework commits shrinks, whether test cases can be derived directly from spec entries, and whether onboarding cost falls for new team members. Once the spec becomes the single source of truth, code review arguments shift from “what effect do you want” to “does the spec say so”, and the collaboration gain comes precisely from that shift.