Skip to main content
Blitz
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage
Edit page

057 · Spec-driven development

A project’s specification is the work’s contract: written and refined with the model, checked before it’s approved, implemented in its order, verified requirement by requirement, and kept true as the specs and the work change. The specs are the files /spec writes; Blitz reads them, checks them, and traces each requirement’s ID to the work that implements it.

Status Built (2026-11-07, for v0.9.4): SDD-01–SDD-06, SDD-10–SDD-12, SDD-20–SDD-21, SDD-30–SDD-32, and SDD-40’s blitz spec verify --ci. Planned: SDD-13 (verifying projects that aren’t code with Evals’ rubrics), SDD-40’s organization reviews that require approved specs, and running the tests that name an ID outside an agent’s turn (Implement’s agent runs the project’s tests). The plan is the one the owner agreed on 2026-11-07; decided: the ledger lives in .agents/.ledger/, with a diff for each change to an approved spec; the impact scan asks first, with its estimated cost.
Source pkg/engine/specs (reading and the checks; ledger.go, evidence.go), pkg/engine/spec_review.go (ListSpecs, ReviewSpec, the model’s review), pkg/engine/spec_trace.go (TraceSpecs, ApproveSpec, VerifySpec), pkg/engine/spec_impact.go (RecordSpecChange, ImpactSpec), pkg/engine/specs/declaration.go, pkg/engine/specs/progress.go (done, next up, drift, what’s left), pkg/engine/agents/builtin/blitz.md and coder.md (cite the IDs), pkg/engine/compose.go (the spec recipe), pkg/engine/draft.go (the spec brief), apps/cli/specs.go (blitz spec), apps/desktop/web/src/studio/SpecsPane.tsx, apps/desktop/web/src/studio/SpecTrace.tsx, apps/desktop/web/src/studio/specs.ts
Tests pkg/engine/specs/specs_test.go, pkg/engine/specs/ledger_test.go, pkg/engine/spec_review_test.go, pkg/engine/spec_trace_test.go, pkg/engine/spec_impact_test.go, pkg/engine/specs/declaration_test.go, pkg/engine/specs/progress_test.go, pkg/engine/agents/frontmatter_test.go, pkg/service/server/mcp_test.go (TestSpecsOverTheAPI), apps/cli/specs_test.go, apps/desktop/web/src/studio/specs.test.ts
Depends on spec_014_agents (the project-spec agent, /spec), spec_040_studio (STU-05, STU-05a, STU-11), spec_045_composer, spec_044_health (grades, for phase 2)

1. Purpose

Spec-driven work fails in two quiet ways: a spec that can’t be checked (so “done” is an opinion), and a spec that changes after the work was done (so the work no longer does what the spec says, and nobody notices). Blitz already writes specs (/spec) and fits a workspace to them (/setup, /skills update, /agents update). This spec closes the loop: write → review → approve → implement → verify → change → impact → fix → verify, traced by the requirements’ IDs (AUTH-01), not by whole files.

2. The format read

The project-spec agent’s (spec_014): .agents/specs/NNN-<name>.md, numbered in the order the work happens, and README.md, the index. A spec starts # NNN. <Title>, then Status: (draft, approved, in progress, implemented, changed, retired), Depends on: (earlier specs, by file name or number) and, in 001-overview.md, Kind:; then Context, Goals and Non-goals, the numbered items each with an ID (- **AUTH-01** …), Done when and Open questions, as headings or bold labels.

3. Phase 1: write and review (built)

  • SDD-01 WorkspaceService.ListSpecs (Workspace.ListSpecs): the Markdown files in .agents/specs, the index first, then by number, then the unnumbered by name; each with its title (the heading without its number), status, what it depends on, how many requirements with IDs, and the checks’ errors and warnings and its open questions. No folder is no specs. Studio › Specs (STU-11) lists them so (“002 · Orders”, its file, status and requirement count, an error or warning count at the right); blitz spec list prints them a line each.
  • SDD-02 The checks without a model (specs.Lint): no # title; no number in the file name; no or an unknown Status:; a Depends on: naming itself, a spec that isn’t there (errors), or one later in the order (a warning); a dependency loop (an error, with its path); no requirements with IDs; an ID twice in the spec or in another (errors); an empty item; a vague word in an item (“fast”, “secure”, “easy”, “scalable”, “as needed”, …: say how much or how it’s measured; English only, the model’s review covers other languages); no Done when; open questions (info). The index’s check: the numbered specs it doesn’t name. IDs are read from list items, bold or plain, two to four digits with an optional letter (FS-61a), never inside code blocks, and not names that only look like IDs (UTF-16, ISO-8601, RFC-9110).
  • SDD-03 WorkspaceService.ReviewSpec (path, the text as edited, judge): the checks on the text in place of the file, against the rest of the specification; with judge, the suggestions model’s review too (specJudgeBrief): requirements that can’t be checked, wording read two ways, contradictions with another spec (by ID), cases it doesn’t settle, how instead of what, goals no requirement serves; at most 12, by line, marked as the model’s, with what it cost. A model that fails or a reply that isn’t findings is a problem; the checks’ findings come all the same. A path outside .agents/specs, or not Markdown, is INVALID_ARGUMENT. Secrets are masked in what’s sent. Studio runs the checks as the spec is edited (half a second after typing stops) and the model’s on Review with AI, its cost shown after; the index gets only its own check.
  • SDD-04 Refine with AI: the composer (spec_045) with the spec recipe: the user says what should change, the composer asks only what it can’t work out (up to its question limit), then drafts the whole spec again in the format above, keeping its IDs; the draft is checked (SDD-02’s errors, against the rest of the specification) and sent back to fix. Compare the changes shows each change (lineHunks, a line diff) with a box to keep it, all kept at first; Use the changes kept puts the result in the form, unsaved. Redraft (STU-05) stays the one-shot rewrite, with the same format brief.
  • SDD-05 A new spec (+, a title) is the next number’s file, in the format: its heading, Status: draft, and the empty sections.
  • SDD-06 blitz spec review [file…] [--judge]: every spec without files (a bare name is in .agents/specs); a finding a line, path:line: severity: message, the model’s marked; with --judge, what the model’s review cost; exit 1 when a check found an error, so CI can gate on the specification.

4. Phase 2: trace and verify (built)

  • SDD-10 The ledger, .agents/.ledger/, committed with the work: specs/<name>.json holds a spec’s approval (when, by whom: git’s user.name, else the computer’s user; the text’s hash) and each requirement’s trace: its text and fingerprint (the text without case, spacing or emphasis, hashed) as approved, and its last verification (when, at which fingerprint, its state, judged or not, the reason, up to 8 pieces of evidence). baselines/<file> is the text approved; diffs/<time>-<name>.diff, a unified diff of what changed, is kept each time a spec approved before is approved again with another text. WorkspaceService.TraceSpecs (a spec, or every spec) gives each requirement with its line, how it differs from the approval (added, changed, or removed: still in the approval, gone from the spec), its state, the reason and the evidence, and stale when its text changed since it was verified; ListSpecs adds whether the spec is approved and how many requirements are traced, implemented and changed.
  • SDD-11 Approve (WorkspaceService.ApproveSpec; blitz spec approve <file> [--force]): the saved spec gets Status: approved (written in place of its Status: line, or after its title), refused when the file changed since it was read; its baseline and ledger entry are written, a requirement whose fingerprint didn’t change keeping its verification. A spec with errors (SDD-02) or open questions isn’t approved without force (FAILED_PRECONDITION, SPEC_NOT_READY, saying why); Studio asks “Approve it anyway?”. Studio’s Approve, Verify and Verify with AI wait until the spec is saved.
  • SDD-12 Verify (WorkspaceService.VerifySpec; blitz spec verify [file…]), in two passes. Without a model, free: each requirement’s ID is looked for in the workspace’s files (git’s, not ignored, without blocked paths; not the specs or the ledger; up to 512 KiB each, binaries skipped) and the last 500 commits’ messages; an ID counts only whole (ORD-01 isn’t in ORD-010). Evidence is a file’s line (a test when its path looks like one, a document for .md, .txt, .rst, .adoc, code otherwise) or a commit; a requirement is traced when code, a test or a commit names it, untraced otherwise (a document that only mentions it doesn’t implement it). With judge, the suggestions model reads each requirement’s evidence (the lines around each, commits, and for an untraced one what the search index finds for its text; secrets masked; at most 96 KiB) and says implemented, partial, missing or contradicted, with a reason naming the file and line; a verdict it can’t give leaves the check’s result. Asked with estimate, it says only what that would cost (from the prompt’s size, as Health’s estimates; whether the model has a price) and writes nothing: Studio’s Verify with AI and --judge without --yes show the estimate before anything is spent. The ledger keeps every result. Studio shows a spec’s requirements in a table under its checks (requirement, state with its reason, where it was found), the list says “1 of 2 traced” for an approved spec and how many changed since approval, and Show every requirement is the matrix of every spec’s, a row opening its spec. Running the tests that name an ID is phase 4’s (SDD-30), which knows the project’s test command.
  • SDD-13 Planned. Projects that aren’t code (research, analysis, writing) verify against their documents, notebooks and data, with Evals’ rubrics (spec_042) in place of unit tests.

5. Phase 3: change and impact (built)

  • SDD-20 A saved change to an approved spec is recorded (WorkspaceService.RecordSpecChange; Studio after Save, blitz spec impact first): its requirements are compared with the ledger’s fingerprints (added, changed, removed, each with its text then and now); when any changed, the spec’s Status: says changed (refused if the file changed meanwhile) and a diff from the baseline is kept in diffs/, not again when it’s the same as the last one kept. Studio then says how many requirements changed since approval and offers Scan the impact, also offered under the requirements while any changed. The scan (WorkspaceService.ImpactSpec), without a model and free: from where each changed or removed requirement was found (the ledger’s evidence and its ID in the work now), the declaration holding it (specs.Declaration: the function, method, type or class a comment documents a few lines below, else the nearest one above, in Go, Python, JavaScript and TypeScript, and Rust), and that declaration’s uses: its language server’s references (20 s each), else a whole-word search of the workspace’s files; at most 12 declarations and 30 uses each. For the added and changed, what the search index finds for the new text. Places are listed once each (file and line, its kind, why: the ID, the symbol, or the search), at most 120, never the specs or the ledger.
  • SDD-21 The report, by the model, only after its estimate (the owner’s decision: Write the fix with AI asks first with what it will cost; blitz spec impact --judge prints it, and spends only with --yes): a summary of what has to change and the risk, the ordered steps to bring the work in line (tests first, then code, then documentation; each naming the files it touches), and the other specs’ requirements the change contradicts, by ID. The report is kept as .agents/.ledger/impact/<time>-<name>.md, ending with “verify the spec and approve it again”. Copy the steps puts them on the clipboard; Fix in a chat closes Studio and puts a prompt in the chat box (not sent) naming the spec and the report. The spec stays changed until it’s approved again.

6. Phase 4: implement and keep true (built, but as listed)

  • SDD-30 Implement (WorkspaceService.PlanSpec; Studio’s Implement; blitz spec implement <file>, which prints the prompt to pipe to blitz): the spec’s requirements not yet implemented (no verification judging it implemented at its current text), in order; the dependencies not done that it waits for; and a prompt for an agent: read the spec, the specs it depends on and .agents/AGENTS.md; the requirements; its Done when; tests first (see each fail, then pass); cite each requirement’s ID in a comment at the code, in the test and in the commit message (Implements: ID); run the project’s tests before saying it’s done; and, when a dependency isn’t done, check what it needs is there. Studio shows the plan and Start in a chat puts the prompt in the chat box, not sent. The Blitz and coder agents cite the IDs whenever they implement from .agents/specs/, so Verify traces their work.
  • SDD-31 Drift. At a turn’s end, when files it changed hold the evidence of an approved requirement (code or test, not documents or commits), the turn says which (“This turn changed the work behind approved requirements ORD-01 (002-orders.md). Verify them again”). Verification returns an approved spec’s drifted requirements: changed since approval (added, changed or removed), lost (traced, implemented or partial before, untraced now), or judged missing or contradicted by the model. Studio says how many drifted after Verify. A pass without the model keeps the model’s verdict while the requirement’s text is unchanged and its ID still found in the work.
  • SDD-32 Next up. A spec is done when it’s approved, unchanged since, and every requirement is traced or judged implemented; next up is the first in order not done whose dependencies are; one with a dependency not done waits for it. The list says so for each spec (ListSpecs: done, next, blocked_by). Open questions show among the checks’ findings (SDD-02).
  • SDD-40 blitz spec verify --ci exits 1 when an approved requirement drifted (SDD-31), saying which and why, so a pull request can’t merge work that left its spec. Planned: an organization’s reviews can require approved specs.