Turn an uncertain software request into an approved specification, a controlled implementation, and evidence-backed acceptance. Keep project documents in the repository's established location; otherwise use docs/spec-driven/<feature-slug>/.
Use this skill for new products, medium-to-large features, cross-module changes, or requests that need PRD/technical design, active clarification, multi-agent execution, or a main-agent judge. Do not use it for a small single-file change, a tiny bug fix, code explanation, review-only or diagnostic work, pure research, or a simple task whose specification is already complete.
$spec-driven-loop Build a multi-tenant job dashboard with role-based access and evidence-backed acceptance.
Follow repository instructions and authorization boundaries throughout. Match generated project documents to the user's language or the repository's existing documentation language; keep identifiers such as FR-001 and AC-001 stable.
TBD, ASSUMPTION, or BLOCKED.The requirements-grilling stage is informed by Matt Pocock's MIT-licensed grill-me / grilling decision-tree and frontier method.
Keep each fact in one authoritative document and reference its stable ID elsewhere:
PRD.md: why and what the product must do; owns scope, user behavior, business rules, assumptions, and product decisions.TECH_DESIGN.md: how the approved product behavior will work; owns architecture, contracts, data, operations, security, and technical decisions.ACCEPTANCE.md: observable proof that frozen requirements are met; owns pass/fail criteria and required evidence.AGENT_PLAN.md: who performs approved implementation work; owns dependencies, file ownership, validation, and agent task contracts.LOOP.md: current recoverable execution state and append-only loop history; owns attempts, evidence, judgments, rework, risks, and next action.Read references/document-templates.md when creating or updating these five documents. Read references/agent-and-judge-contracts.md before assigning implementation tasks, integrating agent work, judging acceptance, or issuing rework.
Before asking the user questions:
AGENTS.md, project instructions, existing specifications, and repository conventions.If frozen, approved PRD, Tech Design, and Acceptance documents already exist, verify their status, consistency, and applicability. Resume from planning or the current LOOP.md instead of repeating resolved grilling. If approval is absent or the request changes frozen behavior, return to the appropriate specification stage.
PRD.mdCreate the best initial PRD from the request and inspected system. Include:
FR-001, FR-002, ...);Do not turn unknowns into requirements. Label each unresolved item TBD, ASSUMPTION, or BLOCKED, and show which FRs it affects.
Represent unresolved decisions as a dependency tree. The current frontier contains only high-impact questions whose upstream decisions are resolved.
For each round:
PRD.md and its decision log, then recompute the frontier.Never auto-assume core product behavior, data ownership, permission or security behavior, migrations, external compatibility, payments or money movement, destructive actions, explicit performance targets, or behavior that changes final acceptance. Keep these as blockers.
When the product frontier is clear, summarize confirmed decisions, accepted assumptions, non-goals, deferred items, and remaining risks. Ask the user to confirm that the PRD reflects the shared product understanding before treating it as frozen.
TECH_DESIGN.mdAfter product behavior is understood, document:
Mark a design item BLOCKED when it depends on an unresolved product decision. Grill consequential technical choices with the same decision-tree/frontier method: one to three answerable questions per round, options and impacts, a recommendation with rationale, immediate document updates, and no hidden high-risk assumptions. Resolve ordinary implementation facts by inspecting the system.
ACCEPTANCE.md and Request ApprovalAfter the PRD and Tech Design share a stable understanding, write the acceptance contract. Give each criterion a stable ID (AC-001, AC-002, ...), link it to one or more FRs, and specify:
Cover applicable happy paths, boundary and invalid inputs, permissions, failure and recovery, repeated requests and idempotency, concurrency, compatibility, performance and capacity, migration, rollback, regression, and existing quality gates. Distinguish In Scope, Out of Scope, Non-goals, Deferred, Assumptions, Release Blockers, and Definition of Done.
Do not accept subjective criteria such as "good experience", "good performance", "high code quality", or "mostly works". Every blocking AC needs observable evidence such as automated tests, API responses, database state, logs, metrics, screenshots, performance results, or a precise manual check.
Show the user a concise specification summary and ask: The specification, scope, and acceptance conditions are defined. Do you approve implementation? Record the answer. Do not write production code without explicit approval.
AGENT_PLAN.mdOnly after implementation approval, split work into independently verifiable vertical slices rather than mechanically separating frontend, backend, and tests. For each task include:
Before parallel delegation, freeze shared interfaces, schemas, and public types. Confirm that writes do not overlap. Serialize any tasks with overlapping ownership or unresolved dependencies. Use multiple agents only when at least two tasks are truly independent and delegation is available and authorized; do not create agents merely to display parallelism.
The main agent maintains the specification, approves ownership changes, handles dependencies and conflicts, integrates results, runs system-level verification, and judges final acceptance. Subagents may not expand scope, change acceptance criteria, unilaterally change shared contracts, cross ownership boundaries, lower test requirements, or declare the whole project complete.
LOOP.mdCreate LOOP.md before production implementation. Its top section must expose enough state for a new session to resume after reading only the top status and current loop. Use exactly one current state:
drafting, grilling, awaiting-spec-approval, ready, implementing, judging, changes-requested, blocked, or accepted.
Each loop records its Loop ID, objective, FR/AC IDs, assignments, dependencies, outputs, changed files, commands/checks, results, evidence, main-agent judgment, failure conditions, rework requirements, unresolved risks, next state, and next action. Update the top state when reality changes. Never delete or overwrite a failed loop; append the next attempt.
Give each subagent only the context required by its task contract. Require the completion-report format from references/agent-and-judge-contracts.md. Treat contract deviations, new blockers, interface changes, and ownership conflicts as stop-and-report events.
Integrate in dependency order. Inspect actual changes instead of relying on summaries. Keep LOOP.md current with files, checks, results, evidence, risks, and status.
The main agent must:
Acceptance ID | Result | Evidence | Defect/Caveat.Allowed conclusions are ACCEPTED, CHANGES_REQUESTED, BLOCKED, and ACCEPTED_WITH_CAVEATS. Missing evidence for a blocking AC is a failure. Existing code, passing unit tests, a subagent's claim, or majority agreement is never sufficient by itself; only the frozen acceptance contract determines the result.
For CHANGES_REQUESTED, append a new loop for only the failed ACs, include reproduction evidence, constrain the minimum repair scope, and require regression coverage. Never weaken acceptance to manufacture a pass. After the same AC fails judgment in three consecutive loops, stop automatic rework and ask the user to choose redesign, scope change, accepted limitation, or termination of that part.
Lead with the result, then report completed scope, incomplete or deferred scope, the acceptance matrix, test and validation evidence, key design decisions, remaining risks, accepted assumptions, and suggested next steps. Ensure the final LOOP.md state matches the real outcome.