5.3 KiB
5.3 KiB
| name | description |
|---|---|
| spec-driven | Spec-driven product workflow: requirements → spec.md → plan.md → small task.md files with explicit inputs/outputs (≈100–200 line changes each). Use when the user wants to restart cleanly, write requirements, draft a product spec, break a plan into tasks, run /spec-driven, or says 重新開始 / 需求文件 / 拆 task / 從需求做到 task. |
Spec-Driven Workflow
Freeze what we want, then how it behaves, then how we deliver, then one-step tasks. Never invent code while a phase is unapproved.
Artifact root
docs/product/<slug>/
README.md # phase status
requirements.md
spec.md # after requirements approved
plan.md # after spec approved
tasks/
INDEX.md
T001-short-slug.md
Templates live in this skill:
references/templates/{requirements,spec,plan,task}.md
references/workflow.md
Optional scaffold:
bash .grok/skills/spec-driven/scripts/init-run.sh <slug> "<one-line goal>"
Invocation
| Form | Behavior |
|---|---|
/spec-driven |
Ask slug + goal if missing; continue current phase |
/spec-driven <slug> |
Work on that run |
/spec-driven <slug> --status |
Report phase + file presence only |
/spec-driven <slug> --phase N |
Only if prior artifacts exist; still require user OK for this phase output |
Phases: 0=init, 1=requirements, 2=spec, 3=plan, 4=tasks, 5=ready-to-implement.
Hard gates
- One phase per turn cycle. Write the current phase document(s), summarize for the user, stop.
- Advance only when the user clearly approves (e.g. 「需求 OK」「spec 通過」「可以拆 task」).
- Do not implement product code until:
plan.mdapproved, andtasks/INDEX.mdexists with at least onetodotask, and- user says to implement a specific
T###(or all).
- Do not skip templates' required sections.
- If prior phase file is missing → stop and say which file is needed.
Step 0 — Init
- Resolve
slug(kebab-case, e.g.haixun-console). - If
docs/product/<slug>/missing → runinit-run.shor create the same structure. - Write/update
README.mdwith goal, phase=requirements, dates. - Ask user to confirm scope in one sentence if ambiguous.
Step 1 — Requirements
- Read templates + existing product context (
docs/architecture.md, related plans,AGENTS.mdconstraints). - Write
requirements.mdusing the template (product language only). - Forbidden in requirements: API paths, Go package paths, PR lists, implementation steps.
- Present: In/Out scope, P0 vs later, success criteria, open questions.
- Set README phase note:
awaiting-requirements-approval. - STOP.
Step 2 — Spec
Preconditions: requirements.md exists and user approved.
- Write
spec.mdfrom requirements (behavior contracts). - Include Retain / Replace / Remove vs current codebase where relevant.
- Follow project rules when specifying contracts: JSON envelope,
page/pageSize, unix nanoseconds UTC, job guarded updates, auth header matrix. - Forbidden in spec: milestone calendars, task IDs, "we'll refactor later" without a concrete behavior.
- Present summary → README
awaiting-spec-approval→ STOP.
Step 3 — Plan
Preconditions: spec.md approved.
- Write
plan.mdwith milestones M0…Mn, dependencies, risks, verification commands. - Map each milestone to a task id range (e.g. M1 → T010–T019) but do not write full task files yet unless user asked to combine plan+tasks in one approval (default: plan only).
- Present summary → STOP.
Step 4 — Tasks
Preconditions: plan.md approved.
- Create
tasks/INDEX.mdand one file per task fromreferences/templates/task.md. - Task size rule: estimate 100–200 lines of production code change. If larger, split. If smaller and independent, still OK but avoid micro-noise (<~30 lines unless critical fix).
- Every task MUST have: Goal, Inputs, Outputs (paths + behavior), Out of scope, Acceptance checks (commands), Depends on.
- No vague tasks ("improve UX", "cleanup backend").
- Present INDEX + count → STOP until user approves task breakdown.
- On approval: README phase=
ready-to-implement.
Step 5 — Implement (only when asked)
- Pick exactly one
T###(or user-specified set). - Mark INDEX
doing→ implement only that task's Outputs → acceptance →done. - Do not pull in neighbor tasks "while you're there" unless user expands scope.
- Prefer
make test/go test ./.../make web-buildas listed in the task.
Status reporting (--status)
Print:
- slug, goal, phase
- which of requirements/spec/plan/tasks exist
- task counts by status from INDEX
Style
- Chinese or English matching the user; product docs for this repo default to 繁體中文.
- Complete sentences in requirements/spec; tasks can be tighter checklists.
- Link related existing docs; do not duplicate architecture textbooks into requirements.
Anti-patterns
- Writing all four layers in one go without approval
- Coding during requirements/spec
- Tasks without file paths or acceptance commands
- Treating
docs/post-project-plan.mdas approved requirements without copying into this pipeline - Inflating a "whole product" requirements doc without P0/P1/P2 prioritization