Sub topic 13
Tooling that supports spec-driven development
This chapter assumes you have read the earlier chapters on requirements, tasks, and tests. You should also be comfortable with Git and a CI service. It describes the kinds of tools that keep a spec useful after you write it, and it shows one small check you can add yourself.
The working model
Spec-driven development needs no special product. You need four things:
- A place where the spec is stored.
- A way for the agent to read it.
- A way to check the agent's output against it.
- A gate that stops unchecked work from merging.
Each job can be done by a different tool.
Tool categories
| Category | Job in the workflow | Examples |
|---|---|---|
| Version control | Stores specs next to code and shows spec diffs in pull requests | Git, GitHub, GitLab |
| Spec-aware agents and toolkits | Guide the agent through requirements, design, and tasks | Kiro specs, GitHub Spec Kit |
| Instruction files | Give the agent standing rules | `AGENTS.md` and tool-specific equivalents |
| Test runners | Make acceptance criteria executable | pytest, JUnit, Jest |
| CI | Runs the tests and checks on every change | GitHub Actions, GitLab CI |
Spec-aware tools save effort because they create the three documents and walk the agent through them. They are not required. A specs/<feature>/ folder, an instruction file, and a CI job give you the same discipline with less lock-in. Check each tool's own documentation, because these products change quickly.
Add a traceability check
Tests prove that behavior works. They do not prove that every criterion has a task. A short script can check that. It reads the numbered criteria from requirements.md and the Covers: lines from tasks.md, which use the format from the earlier tasks example.
import re
import sys
from pathlib import Path
def criteria(text):
found = set()
current = None
for line in text.splitlines():
m = re.match(r"###\s+Requirement\s+(\d+):", line)
if m:
current = m.group(1)
continue
m = re.match(r"(\d+)\.\s+(WHEN|IF)\b", line)
if m and current:
found.add(f"{current}.{m.group(1)}")
return found
def covered(text):
found = set()
for m in re.finditer(r"Covers:\s*Requirement\s+([\d., ]+)", text):
found.update(re.findall(r"\d+\.\d+", m.group(1)))
return found
def main(spec_dir):
root = Path(spec_dir)
required = criteria((root / "requirements.md").read_text())
done = covered((root / "tasks.md").read_text())
missing = sorted(required - done)
if missing:
print("Criteria with no task:", ", ".join(missing))
return 1
print("All criteria are covered by a task.")
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1]))Run it with python check_spec.py specs/password-reset. It exits with status 1 when a criterion has no task, so CI can fail the build. Run it in the same CI job as pytest:
name: spec-checks
on: [pull_request]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install pytest
- run: python check_spec.py specs/password-reset
- run: pytestCommon errors
- Trusting the tool to enforce the process. An agent can skip a spec phase unless a check or a reviewer stops it. Back every rule in the instruction file with something CI can fail on.
- Specs outside the repository. A spec in a wiki cannot appear in the same pull request as the code, so drift goes unnoticed. Keep specs in Git.
- Counting coverage as correctness. The script confirms that a task mentions a criterion. It does not confirm that the task is done well. Tests and human review still do that.
- Brittle parsing. The script depends on a fixed format. If the team changes the heading style, update the regular expressions, or the check will pass with nothing to check. Add a test for the script itself.
- Choosing tools before the process. Settle your review gates and spec layout first, then pick tools that fit them.
Exercise
The traceability script passes, and every criterion appears in a Covers: line, but a reviewer finds that task 2 does not implement criterion 1.3. Which part of your tooling should have caught this, and why did the script not?
Show answer
The tests should have caught it, as should human review of the agent's output. The script only compares identifiers in requirements.md and tasks.md. It never looks at code. A test such as test_token_can_be_used_only_once fails when the behavior is missing, so every criterion needs an automated test in addition to a task that mentions it.
Exercise
Your team keeps specs in a wiki and code in Git. Name two problems this causes for spec-driven development with agents and one fix.
Show answer
The agent cannot reliably read the wiki page that matches its branch, and a spec change cannot be reviewed in the same pull request as the code change, so the two drift apart. Fix: move the specs into a specs/<feature>/ folder in the repository and point the instruction file at it.