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: >4 Guided specification generation wizard. Use when adding a new feature, API endpoint,5 or component — forces a written spec before implementation. Validates scope, drafts6 a structured spec, checks it against conventions, and registers it in the project.7 NOT for: single-file bug fixes, refactors with no new behavior, or documentation-only changes.8metadata:9 source: https://skillmd.com/skills/samyakjhaveri/gen-spec10---1112# Spec Generation Workflow1314Structured workflow for generating a specification document before writing any15implementation code. Specs-before-code prevents scope drift and makes review cheaper.1617## Arguments18- `$ARGUMENTS` — one of:19 - `<name>` — feature or component name (e.g., "user-auth", "batch-processor") → full generation workflow20 - `validate <path>` — run spec health check on an existing spec (former `/spec-check`)2122## Workflow2324### Phase 1: Scope Validation25- Confirm the feature/component boundaries with the user26- Identify dependencies and integration points27- Check for existing specs that overlap (avoid duplication)28- Review related stage contracts if any exist29- 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.3031### Phase 2: Draft Spec32- Create `specs/<name>.md` (or `.yaml` / `.json` per project convention)33- Follow the spec template from `.claude/rules/spec-conventions.md`34- Required sections: Identity, Inputs, Behavior, Outputs, Constraints, Acceptance Criteria35- Link to related specs, ADRs, or design docs3637### Phase 3: Validate (inline spec health check)3839Run the full validation checklist (formerly `/spec-check`):40411. **Structure check** — verify all required sections per `spec-conventions.md`:42 Identity, Inputs, Behavior, Outputs, Constraints, Acceptance Criteria432. **Reference check** — for every file or resource referenced, verify it exists on disk443. **Acceptance criteria quality** — each criterion must be testable, specific, and independent454. **Naming convention** — filename uses kebab-case, Identity name matches filename465. **Constraint completeness** — Constraints section is non-empty with spec-specific exclusions47 (not generic "don't do bad things")4849Report as:50```51=== SPEC CHECK: <name> ===52Structure: [PASS/FAIL]53References: [PASS/FAIL]54Criteria: [PASS/FAIL]55Naming: [PASS/FAIL]56Constraints: [PASS/FAIL]57```5859If any check fails, fix before proceeding.6061### Phase 4: Review62- Run the plan-reviewer agent for adversarial review63- Address any findings before marking the spec as ready64- Get user sign-off on the final spec6566### Phase 5: Register67- Add the spec to the project's spec index (if one exists)68- Cross-reference in relevant CONTEXT.md files69- The spec is now the source of truth for implementation7071## Principles72- A spec is a contract, not a wishlist — every statement should be verifiable73- Acceptance criteria are the spec's value — if they're vague, the spec is vague74- The spec drives implementation, not the reverse — don't retrofit specs to match code75- Keep specs DRY with stage contracts — a spec describes WHAT, a stage contract describes HOW7677---7879## Validate Mode (`/gen-spec validate <path>`)8081When `$ARGUMENTS` starts with `validate`, run only Phase 3 (spec health check) against82the specified spec file. Skip generation phases. Report PASS/FAIL with diagnosis.8384Search order for the spec: `specs/`, `docs/specs/`, `docs/contracts/`, then literal path.