Spec‑Driven Development: Make the Specification the First Commit

If your acceptance criteria live in a comment thread, they’re not requirements—they’re opinions. Spec‑driven development (SDD) turns those opinions into executable truth so code, tests, docs, and operations move in lockstep.

Building on our split between functional and nonfunctional requirements, this follow‑up introduces spec‑driven development: what it is, why it reduces drift, and how to run it inside agile without ceremony. We’ll connect behavior specs, API contracts, data schemas, and quality budgets to lightweight gates in CI/CD and SLOs in production. By the end, you’ll have a “small slice” pattern you can ship next sprint. This is where spec-driven development meets Agile, DevOps, and APIs.

From requirements to executable requirements

In the last piece, we treated functional requirements as what the system does and nonfunctional requirements as how well, how safely, how reliably it does it. Spec‑Driven Development makes both machine‑checkable. Instead of prose scattered across tickets and slides, SDD expresses the same intent as executable specifications—human‑readable, versioned artifacts that tools can compile, validate, simulate, and monitor against.

At its core:

  • Specify before you implement—thin slice first. Each story begins with a tiny, testable spec: the behavior and the quality thresholds that matter for that slice.
  • Let the spec drive everything downstream. Stubs, tests, mocks, docs, and pipeline checks are generated from—or validated against—the spec.
  • Change the spec first. When behavior or quality shifts, the pull request starts with a spec diff; the pipeline enforces compatibility and budgets before code merges.

A minimal stack of specs (and what each unlocks)

You don’t need a tool zoo. You need a few well‑named files under version control that the team can read and the pipeline can run:

Spec layerEncodesDrives & gates
Behavior spec (e.g., Given‑When‑Then scenarios)User‑visible outcomes and acceptance criteriaExample‑based tests; living documentation; story sign‑off
Interface contract (e.g., API schema)Endpoints, events, types, auth, error modelsStub/mocks; compatibility checks; SDK/doc generation
Data schemaValidation rules, PII tags, retention hintsInput validation; migration safety; privacy linting
Quality profilePerformance budgets, availability targets, security baseline, accessibility barCI fitness functions; SLOs/error budgets; release gates

These artifacts tie directly to agile habits: the story’s acceptance criteria link to behavior scenarios; the team’s Definition of Done references the quality profile; and the release checklist becomes a set of automated gates rather than a meeting.

What “spec‑driven” looks like inside a sprint

Three‑Amigos, then spec. Product, engineering, and design quickly align on one or two examples and the nonfunctional thresholds that make those examples credible.

Generate, then implement. Create a mock or stub from the contract; run example tests that fail; write the smallest code to make them pass.

Verify continuously. Fitness functions enforce budgets (latency percentiles, accessibility checks, dependency risk thresholds). Contract verifiers guard against breaking changes. Dashboards consume the same SLO numbers you used in the spec.

Release with confidence. Compatibility gates pass, budgets are green, and the behavior examples read like documentation because they are the documentation.

A tiny, end‑to‑end slice (spec first)

Behavior (Specification by Example)

Feature: Download monthly statement
  Scenario: Typical account under peak load
    Given a customer with 10k line items in March 2025
    When they request the March statement
    Then a signed PDF is delivered
    And 95% of requests complete within 4 seconds

Interface contract (excerpt)

paths:
  /statements/{month}:
    get:
      security: [ bearerAuth: [] ]
      parameters:
        - name: month
          in: path
          required: true
          schema: { type: string, pattern: "^[0-9]{4}-(0[1-9]|1[0-2])$" }
      responses:
        "200":
          description: PDF
          content:
            application/pdf:
              schema: { type: string, format: binary }
        "404": { description: Not Found }

Quality profile (excerpt)

performance:
  latency:
    p95_ms: 4000
    p99_ms: 6000
availability:
  monthly_target: "99.9%"
security:
  no_high_vulns: true
  pii_in_logs: false
accessibility:
  wcag_level: "AA"

From these three small files, your pipeline can: spin up a mock, fail builds on breaking API diffs, run performance checks against the budget, scan for high/critical vulnerabilities, and regenerate docs. Your production SLO dashboards reference the same targets—so “what we promised” matches “what we watch.”

Traceability without paperwork

In SDD, traceability isn’t a spreadsheet—it’s a graph the repo already implies:

  • A story links to its behavior scenarios and contract endpoints.
  • Each scenario maps to automated tests; each endpoint maps to a compatibility check.
  • Each quality objective maps to a fitness function and, in production, to an SLO and error budget.

When someone asks, “What proves this works and keeps working?”, you can point to the spec, the tests it generates, and the live indicators it powers.

Common pitfalls (and the fix)

  • Spec as a static document. If tools don’t run it, it will rot. Fix: Wire at least one automated gate to every spec layer on day one.
  • Over‑detailed specs. You’ll freeze design prematurely. Fix: Keep slices small; specify only what enables progress and protects risk.
  • Tool sprawl. Five linters, zero alignment. Fix: Prefer one spec → many consumers; avoid overlapping checks.
  • Specs lag code. The worst drift. Fix: Require a spec diff in any PR that changes behavior or quality; fail builds when spec and code disagree.

Adopt SDD in one sprint

  1. Pick one journey, one endpoint, and one quality risk (latency or auth).
  2. Write the smallest spec: a single scenario, a contract stub, and a tiny quality profile.
  3. Add two gates: breaking‑change detection for the contract and one fitness function for the quality target.
  4. Make it visible: link the spec from the story template and add the targets to a dashboard.
  5. Iterate: repeat for the next slice; promote recurring thresholds into team‑wide “quality bars.”

Summary

Spec‑Driven Development turns requirements into a living, enforceable backbone for agile and AI delivery. Write the spec first, keep it executable, and let it drive code, tests, docs, and operations. Tie your functional behavior and nonfunctional budgets to the same artifacts and you’ll replace drift with momentum. Next sprint, pick one slice and make the specification your first commit.

Unknown's avatar

Author: Jason Miles

A solution-focused developer, engineer, and data specialist focusing on diverse industries. He has led data products and citizen data initiatives for almost twenty years and is an expert in enabling organizations to turn data into insight, and then into action. He holds MS in Analytics from Texas A&M, DAMA CDMP Master, and INFORMS CAP-Expert credentials.

Discover more from EduDataSci - Educating the world about data and leadership

Subscribe now to keep reading and get access to the full archive.

Continue reading