Spec Generation Workflow
Structured workflow for generating a specification document before writing any
implementation code. Specs-before-code prevents scope drift and makes review cheaper.
Arguments
$ARGUMENTS — one of:
<name> — feature or component name (e.g., "user-auth", "batch-processor") → full generation workflow
validate <path> — run spec health check on an existing spec (former /spec-check)
Workflow
Phase 1: Scope Validation
- Confirm the feature/component boundaries with the user
- Identify dependencies and integration points
- Check for existing specs that overlap (avoid duplication)
- Review related stage contracts if any exist
- If a decision warrants an ADR, apply the three-part test: is it (1) hard to reverse, (2) surprising to future readers, and (3) a genuine trade-off with real alternatives? Skip ADRs for trivial or self-evident decisions.
Phase 2: Draft Spec
- Create
specs/<name>.md (or .yaml / .json per project convention)
- Follow the spec template from
.claude/rules/spec-conventions.md
- Required sections: Identity, Inputs, Behavior, Outputs, Constraints, Acceptance Criteria
- Link to related specs, ADRs, or design docs
Phase 3: Validate (inline spec health check)
Run the full validation checklist (formerly /spec-check):
- Structure check — verify all required sections per
spec-conventions.md:
Identity, Inputs, Behavior, Outputs, Constraints, Acceptance Criteria
- Reference check — for every file or resource referenced, verify it exists on disk
- Acceptance criteria quality — each criterion must be testable, specific, and independent
- Naming convention — filename uses kebab-case, Identity name matches filename
- Constraint completeness — Constraints section is non-empty with spec-specific exclusions
(not generic "don't do bad things")
Report as:
=== SPEC CHECK: <name> ===
Structure: [PASS/FAIL]
References: [PASS/FAIL]
Criteria: [PASS/FAIL]
Naming: [PASS/FAIL]
Constraints: [PASS/FAIL]
If any check fails, fix before proceeding.
Phase 4: Review
- Run the plan-reviewer agent for adversarial review
- Address any findings before marking the spec as ready
- Get user sign-off on the final spec
Phase 5: Register
- Add the spec to the project's spec index (if one exists)
- Cross-reference in relevant CONTEXT.md files
- The spec is now the source of truth for implementation
Principles
- A spec is a contract, not a wishlist — every statement should be verifiable
- Acceptance criteria are the spec's value — if they're vague, the spec is vague
- The spec drives implementation, not the reverse — don't retrofit specs to match code
- Keep specs DRY with stage contracts — a spec describes WHAT, a stage contract describes HOW
Validate Mode (/gen-spec validate <path>)
When $ARGUMENTS starts with validate, run only Phase 3 (spec health check) against
the specified spec file. Skip generation phases. Report PASS/FAIL with diagnosis.
Search order for the spec: specs/, docs/specs/, docs/contracts/, then literal path.
1---2name: gen-spec3description: Generate a structured specification document before writing implementation code, validating scope, drafting specs, and registering them in the project.4---56# Spec Generation Workflow78Structured workflow for generating a specification document before writing any9implementation code. Specs-before-code prevents scope drift and makes review cheaper.1011## Arguments12- `$ARGUMENTS` — one of:13 - `<name>` — feature or component name (e.g., "user-auth", "batch-processor") → full generation workflow14 - `validate <path>` — run spec health check on an existing spec (former `/spec-check`)1516## Workflow1718### Phase 1: Scope Validation19- Confirm the feature/component boundaries with the user20- Identify dependencies and integration points21- Check for existing specs that overlap (avoid duplication)22- Review related stage contracts if any exist23- If a decision warrants an ADR, apply the three-part test: is it (1) hard to reverse, (2) surprising to future readers, and (3) a genuine trade-off with real alternatives? Skip ADRs for trivial or self-evident decisions.2425### Phase 2: Draft Spec26- Create `specs/<name>.md` (or `.yaml` / `.json` per project convention)27- Follow the spec template from `.claude/rules/spec-conventions.md`28- Required sections: Identity, Inputs, Behavior, Outputs, Constraints, Acceptance Criteria29- Link to related specs, ADRs, or design docs3031### Phase 3: Validate (inline spec health check)3233Run the full validation checklist (formerly `/spec-check`):34351. **Structure check** — verify all required sections per `spec-conventions.md`:36 Identity, Inputs, Behavior, Outputs, Constraints, Acceptance Criteria372. **Reference check** — for every file or resource referenced, verify it exists on disk383. **Acceptance criteria quality** — each criterion must be testable, specific, and independent394. **Naming convention** — filename uses kebab-case, Identity name matches filename405. **Constraint completeness** — Constraints section is non-empty with spec-specific exclusions41 (not generic "don't do bad things")4243Report as:44```45=== SPEC CHECK: <name> ===46Structure: [PASS/FAIL]47References: [PASS/FAIL]48Criteria: [PASS/FAIL]49Naming: [PASS/FAIL]50Constraints: [PASS/FAIL]51```5253If any check fails, fix before proceeding.5455### Phase 4: Review56- Run the plan-reviewer agent for adversarial review57- Address any findings before marking the spec as ready58- Get user sign-off on the final spec5960### Phase 5: Register61- Add the spec to the project's spec index (if one exists)62- Cross-reference in relevant CONTEXT.md files63- The spec is now the source of truth for implementation6465## Principles66- A spec is a contract, not a wishlist — every statement should be verifiable67- Acceptance criteria are the spec's value — if they're vague, the spec is vague68- The spec drives implementation, not the reverse — don't retrofit specs to match code69- Keep specs DRY with stage contracts — a spec describes WHAT, a stage contract describes HOW7071---7273## Validate Mode (`/gen-spec validate <path>`)7475When `$ARGUMENTS` starts with `validate`, run only Phase 3 (spec health check) against76the specified spec file. Skip generation phases. Report PASS/FAIL with diagnosis.7778Search order for the spec: `specs/`, `docs/specs/`, `docs/contracts/`, then literal path.