Spec-Driven Development

Spec-Driven Development (SDD) is a methodology that makes software specs the ground truth for AI coding agents. Instead of the agent reading prose and guessing, it queries a compiled knowledge graph.

What problem does it solve?

AI coding agents are powerful but imprecise. Give them 600 lines of prose in a .dog file and they'll waste 8,015 tokens scanning for the 4 lines that matter. They hallucinate entity names, invent relationships, miss required fields. The longer the spec, the more they drift.

SDD solves this by compiling human-written specs into a positional DAG graph — a token-efficient structure the agent loads in one shot. The DAG is 94% smaller than source. It doesn't replace reading — it replaces scanning.

Without SDDWith SDD
Agent input~8,100 tokens of prose~740 tokens of graph
Entity namesExtracted by guessworkExact, from DAG
RelationshipsInvented or missedPre-compiled edges
HallucinationCommonNear-zero
VerificationManual reviewAutomated (dotdog validate)

The DAG: a compressed index, not a summary

If the agent ignores the DAG and reads .dog files directly, they waste 8,015 tokens. The DAG is a compiled index — it doesn't replace reading the spec, it replaces scanning 600 lines of prose to find which 4 lines matter.

A .dag file stores entities, properties, states, lifecycles, and relationships in a v2 positional format — no JSON keys, no whitespace overhead. The agent gets the exact graph: 11 entities, 5 relationships, every property typed, every lifecycle transition mapped. One file. All structure.

The practice

  1. Specify — write .dog files: entities with properties, states, lifecycles, and relationships
  2. Validate — score completeness before every commit. The score must not decrease.
  3. Compile — build a .dag graph. 94% smaller than source. Token-efficient.
  4. Expose — MCP server for AI agents. Six tools: getEntity, traverse, search, schema, summary, listProjects.
  5. Verify — detect drift between spec and code. dotdog verify --init auto-maps entities to code files.

The loop

npm install -g dotdog       # install
dotdog init my-app          # scaffold specs
dotdog validate             # score completeness
dotdog compile              # build .dag graph
dotdog serve                # expose to AI agents

The spec file anatomy

A complete spec project has 7 .dog files:

FilePurpose
SPEC.dogProduct description, user stories
constitution.dogHard constraints, scope (in vs out)
data-model.dogEntities + relationships + lifecycles
plan.dogPhased implementation order
INDEX.dogAgent entry points, issue→task mapping
COPY.dogOptional: copyright / license info
DESIGN-SYSTEM.dogOptional: design tokens, surfaces

Three files are required for validation scoring. Four are optional. A complete spec pushes from 95% to 100%.

Why specs as ground truth?

AI agents are trained on the internet — they know every framework, every API, every pattern. What they don't know is your project. Your entity names. Your lifecycle rules. Your invariants.

When specs are in prose (READMEs, docs, comments), the agent has to interpret them. Interpretation means drift. Drift means wrong code.

When specs are in a DAG, the agent queries instead of interpreting. No guessing entity names. No inventing properties. No missing required fields. The DAG is a database for the agent's brain.

AI agents aren't optional anymore

Every developer has an AI agent in their editor, in their CLI, in their CI pipeline. These agents will read your codebase whether you prepare for them or not. The question is: do they read structured ground truth, or do they read prose and guess?

SDD makes your codebase agent-native. The .dag is the agent's entry point. The MCP server is its query interface. The pre-commit hook blocks regressions. The agent never ships code that violates the spec — because the spec is law, not suggestion.

Who uses this

Further reading