Open source · v0.9.0 · MIT
Spec-Driven Development for AI agents.
An AI agent has one advantage over a human: it forgets everything between turns. This project turns your engineering rules into files the agent cannot skip, and gates it cannot talk its way past.
npx create-sdd-ai-stack my-app- 1command
- to a gated Next.js 16 project
- 25rule files
- across 12 stacks, one spine
- 8agents
- wired on the first run
- 0deps
- the CLI itself
// WHAT IT IS
The spec is the source of truth. The agent is not.
Spec-Driven Development started as a discipline: write down what the system must do before writing the code. This project applies it to the agent itself — the spec, the rules and the acceptance criteria all become files, and the agent is a worker executing them rather than an author inventing them.
// Without a spec
- The agent guesses the folder structure every time.
- Nobody can prove which rules were actually read.
- A red test is “probably fine, I will fix it next task”.
- The prompt is 2,000 words and the model skims it by turn 40.
- The conventions live in a human's head, then in a review comment, then vanish.
// With SDD
- The structure is a file. `ARCHITECTURE.md` is the only answer.
- Every claim needs pasted terminal output, not a summary.
- A red test means stop. It is written in the laws, not in a review comment.
- Rules are routed: read the index, open only the one file you need.
- Conventions ship as `stacks/*.md`, versioned and diffable like code.
01
Spec
PLAN.md holds exactly one task in flight, sized so it fits in an attention span. If it takes more than an hour, it is split before it starts.
02
Rules
stacks/*.md is the engineering knowledge: architecture, language, testing, security. Routed by index so the agent reads the minimum necessary.
03
Evidence
A task closes only when the green terminal output is pasted. Not described. Pasted, with the real counts.
// WHY IT WORKS
Four properties that decide whether an agent produces good code.
Not opinions. Each one is a property of the repository that either holds or does not, and most of them can be checked by a script.
16.5ktokens
Context is a budget
The mandatory read order costs ~16.5k tokens before the first line of code. That is why every doc opens with a router, and why the spine is compressed. An agent that reads 40 files to answer one question hallucinates by file 30.
4CI gates
Rules that cannot be bypassed
Branch protection on main, a coverage floor at 95/85/90, npm audit at high severity, and a job that fails if an action is pinned to a deprecated runtime. A green build is not the same as a correct change.
0dead code
The template obeys its own rules
The first audit found the reference feature imported by nothing. It is now wired, behind real auth, with E2E proving the auth rejection writes no row. A template that violates its own conventions teaches the wrong lesson.
98.5% line coverage
Measured, not asserted
Coverage is a gate with a floor in the file, not a number in someone's memory. Lowering it requires a written reason next to the change.
// PRACTICES
The six rules the template enforces, and the one that matters most.
Every practice here exists because its absence produced a bug that a test now prevents.
One task in flight
PLAN.md holds exactly one `[-]` task. Two means the agent stopped wrong. Micro-scoping is not bureaucracy: an agent that loses the thread mid-task writes code nobody asked for.
If it takes more than 1 hour, split it in two before starting.
Behavioural acceptance criteria
Commands prove the code compiles. Criteria prove the code is right. The task template asks for Given/When/Then, the 401 that writes no row, the forbidden role, the repository that throws.
Every criterion needs a test that would fail without the change.
A Server Action is public
The browser is untrusted. Authentication, then authorization, then validation, then mutation, then cache — in that order, on the server. A disabled auth stub in a template is a trap, so this one is wired and tested.
Authorization lives in the data layer, not only in the UI.
Test against the build
`next dev` does not minify and takes a different render path. A green E2E against dev proves nothing about production.
E2E runs against `next build && next start`, on Chromium and Firefox.
No dead code
An unmeasurable function is a function nobody ran. Every generated slice compiles on the first run; the parts that need a human decision fail at runtime, loudly, not at build time.
Every new export must be imported somewhere. Grep it.
Evidence is never compressed
A token-saving tool may shorten your prose. It may never shorten the evidence block. Full command, full exit code, real counts.
Paste the output. Describing it is not the same as running it.
// AI IN THE LOOP
The agent is a worker, not an author. That is the whole design.
The failure mode of agentic development is not a model that is wrong. It is a model that is confidently, fluently, unaccountably wrong — and nobody can tell from the diff which parts were invented.
| Layer | The human | The agent |
|---|---|---|
| The spec | Decides the why and the acceptance criteria. | Reads PLAN.md, takes the single `[-]` task, stops at the boundary. |
| The rules | Writes the convention once, as prose, in the right file. | Opens only the doc the router points at. Does not invent a convention that is not written down. |
| The code | Owns the architecture and the trade-off. | Implements inside the vertical slice, hexagonal arrows inward, one reason to change per file. |
| The evidence | Decides whether the claim is credible. | Runs the gate, pastes the real output, and refuses to mark a task done on a red test. |
The spec
The human
Decides the why and the acceptance criteria.
The agent
Reads PLAN.md, takes the single `[-]` task, stops at the boundary.
The rules
The human
Writes the convention once, as prose, in the right file.
The agent
Opens only the doc the router points at. Does not invent a convention that is not written down.
The code
The human
Owns the architecture and the trade-off.
The agent
Implements inside the vertical slice, hexagonal arrows inward, one reason to change per file.
The evidence
The human
Decides whether the claim is credible.
The agent
Runs the gate, pastes the real output, and refuses to mark a task done on a red test.
// What the laws forbid
- The agent silently rewrites a convention instead of asking. §6 of the laws forbids editing the rules without a human.
- The agent marks `[x]` on a green typecheck and a skipped E2E. The evidence block is the acceptance, not the build.
- The agent adds a library because it was faster to type. §Golden rules: prove the native is enough first.
- The agent invents architecture when the spec is silent. §3: if it is not in the files, ask. Never improvise.
// INSTALL
One command. No configuration, no account, no telemetry.
The CLI has zero runtime dependencies. It copies files, creates a directory, and gets out of the way.
// Create a project
# the whole thingnpx create-sdd-ai-stack my-app# skip the install, it is slownpx create-sdd-ai-stack my-app --no-install# rules only, into a project you already havenpx create-sdd-ai-stack . --rules-only// What lands
my-app/├── src/ Next.js 16 App Router + Tailwind v4 + Biome│ ├── app/ routing only — no business logic│ ├── features/example the live vertical slice, wired and tested│ ├── shared/ ui (shadcn) · lib · server (auth, env)│ └── proxy.ts the network boundary├── tests/ unit · integration · e2e├── SDD/ the rules — the product│ ├── AGENTS.md agent laws + delivery flow│ ├── specs/ PLAN.md, tasks, history│ ├── stacks/ 25 rule files, one spine│ └── SKILLS/ scripts that check the rules└── AGENTS.md shortcut → ./SDD/AGENTS.md// Options
--rules-only
Install only the rules, into an existing project. No app.
--submodule [url]
Install ./SDD as a git submodule, so `git submodule update` syncs the rules.
--git
git init plus the first commit, using your own git identity.
--shortcuts <mode>
auto (symlink with stub fallback), stub, or symlink. AGENTS.md, CLAUDE.md, .cursorrules, .windsurfrules, copilot-instructions.md, .clinerules, GEMINI.md.
--install
Run npm install for you. Off by default.
--template <name>
next (default) or none.
// First run of the generated app
cd my-appnpm installnpx playwright install chromium firefoxnpm run dev# the gate, before you believe yourselfnpm run typecheck && npm run lint \ && npm run test && npm run build// WHAT LANDS ON DISK
One command, a project that already looks like a product.
Not a skeleton: two working templates, the design system applied, the gates wired, and the first commit made by your own git identity.
Two complete apps
Next.js 16 App Router and a Vite + React 19 SPA — same design system, same gates. Both build, lint, test and pass E2E from the first command.
The design system, applied
Matrix tokens as a portable file: carbon and phosphor palettes, a theme switcher that restores before the first paint, and the 44px tap-target law with a test.
An identity, not a globe
favicon, apple-touch-icon, PWA icons, a web manifest and an Open Graph card — the things a generated app usually only gets after the first share.
A responsive law with teeth
The design contract ships as a spec: 390/768/1440, no horizontal scroll, no target under 44px, no body text below 13px. It fails the build, not the review.
Slices that generate clean
create-feature emits a compiling, tested vertical slice in Biome's own form — the first command an agent runs cannot leave a red gate behind.
The signature, opt-in
The boot rain and the terminal teaser ship one import away, and no template mounts them. The costume is your decision, not the kit's.
// INDICATIONS
Wired agents, recommended tooling, and the stacks with rules.
The shortcuts point at one file. Whichever agent you use, it reads the same laws.
// Agents, wired on the first run
// Recommended
Caveman
Token compression and spend observability for your own agent runs. Same compression law as the rule files: prose may be compressed, evidence may not.
Playwright
The E2E layer. Tests run against the production build on two engines, which is why a passing suite means the build works.
Biome
Lint and format in one binary, fast enough to run on every save. `next lint` was removed in Next 16; run your linter directly.
shadcn/ui
Components copied into your repo, so you own the code. `components.json` ships pre-configured, so the first `npx shadcn add` does not ask for a layout.
Zod
One schema, both sides. The client check is a courtesy; the server is the only source of truth.
// Stacks with a rule file
// CONTRIBUTE
The rules are the product, so the rules are open.
Most of this repository is prose. That makes contribution unusually cheap: a better sentence in the right file is a real improvement.
Report a bug with evidence
The fastest fixes come with a failing command. If a rule led an agent astray, say which rule and what it did instead.
Open an issue →Add a rule file
A new stack is one markdown file following the pattern, listed in stacks/README.md. Spine first: map it to clean-code.md, do not duplicate it.
See the pattern →Propose a gate
A rule nobody checks is a rule nobody follows. If you can write a script that fails when the rule is broken, that is the highest-value contribution here.
See the existing checks →// Local development
git clone marcelinosandroni/sdd-ai-stack && cd sdd-ai-stacknpm installnpm test # the CLI suitenpm run check:coveragenpm run check:docs# prove the template still buildsnode bin/create-sdd-ai-stack.mjs .sandbox --no-install --yescd .sandbox && npm install && npm run build// House rules for a pull request
- Conventional Commits, English, with the agent in the trailer.
- A test that would fail without your change. Break the code and watch it go red.
- Editing anything under stacks/ or DESIGN.md is forbidden without asking first — those are the law of the template.
- Green output pasted, with the real counts.
// Need help or found something?