Feature Specification Process
Create a specification for the following: $ARGUMENTS
Specifications clarify WHAT to build before implementation begins.
Instead of discovering ambiguity mid-implementation (expensive),
surface it upfront through structured exploration and clarification.
This is the highest-leverage pattern for complex features.
Mapping to Claude Code Workflow
| Claude Code Phase |
Spec Phase |
What Happens |
| Explore |
Phase 1: Explore |
Read files, understand context, check PROJECT.md |
| Plan |
Phase 2: Specify |
User stories, acceptance criteria, edge cases |
| Plan |
Phase 3: Clarify |
Interactive disambiguation (max 5 questions) |
| Plan |
Phase 4: Validate |
8-point spec quality checklist |
| Plan |
Phase 5: Handoff |
Summary report, suggest /tdd |
When to Use This Process
| Scope |
Approach |
| Trivial (typo, config, rename) |
Don’t use this skill – just do it directly |
| Small (well-understood, single concern) |
Quick spec shortcut (skip clarification) |
| Medium (multi-concern, some ambiguity) |
Full process |
| Large (cross-cutting, unfamiliar domain) |
Full process, thorough clarification |
Quick spec shortcut: For small well-understood changes with
no domain ambiguity, collapse to: Explore -> Specify -> Validate
-> Handoff. Skip clarification entirely. Use when the feature can
be described in one sentence and has no competing interpretations.
Scope negotiation: If the request contains 3+ distinct features,
recommend splitting into separate specs before proceeding. Each spec
should cover one coherent feature with independent user value.
Product vs feature: If the request describes an entire product
or system (multiple independent capabilities, separate components,
its own installation story), treat it as a product-level spec:
- One user story per major capability (not per implementation task)
- Acceptance criteria verify capability, not component details
- Implementation chunking goes in Notes or during TDD, not as
separate specs
- Spec size will exceed the standard guideline — this is expected
If a product spec exceeds 12 stories, consider splitting into a
product spec (overview) + separate feature specs (details).
Product specs with interacting capabilities need explicit
interface contracts — file paths, data formats, handoff
expectations. Document these in Assumptions or a dedicated
section. Without them, components may diverge on implicit
conventions that break silently at integration time.
Supporting Files
Load these on demand, not all upfront:
Process Overview
Phase 1: Explore
Phase 2: Specify
Phase 3: Clarify (interactive, skippable)
Phase 4: Validate
Phase 5: Handoff
Each phase must complete before the next begins.
Phase 3 is skipped if no ambiguities are found.
Phase 1: Explore
1.1 Understand the Request
- Read the user’s feature description carefully
- Identify: new feature, enhancement, bug fix, behavior change,
integration, or workflow change
- Extract key concepts: actors, actions, data, constraints, triggers
- Note initial assumptions about scope and intent
1.2 Explore Current Code
- Read files in the affected area (focus on files mentioned in the
request + 1 layer of direct dependencies)
- Trace the data flow through the application layers
- Identify existing patterns, utilities, and conventions to reference
- Note what already exists — don’t spec what you can grep
Greenfield projects: If the codebase doesn’t exist yet, explore
the inputs that define WHAT to build: analysis docs, design docs,
reference materials, domain knowledge files, and similar projects.
The goal is the same — understand context before specifying — but
the context lives in documents rather than code.
Context tip: Steps 1.2 and 1.3 are independent — run them in
parallel (e.g., use subagents) when the codebase is large or
unfamiliar.
1.3 Read Project Context
- Load
PROJECT.md for domain context, architecture overview,
existing patterns, and domain-specific concerns
- These inform edge case detection, affected component identification,
and project-specific validation in Phase 4
- If
PROJECT.md doesn’t exist or contains only template
placeholders (YOUR_*_HERE), proceed without it — the generic
taxonomy categories still apply
- If the project clearly needs a
PROJECT.md (complex domain,
multiple conventions, domain-specific concerns), note this in
the spec’s Notes section as a recommendation. Don’t block the
spec process — create the spec first, suggest PROJECT.md after
1.4 Identify Affected Components
- List files and modules that will likely change
- Note their role in the architecture (data layer, domain, UI, etc.)
- This becomes the spec’s “Affected Components” section and later
feeds into TDD chunk decomposition
1.5 Check for Existing Spec
- Check the spec directory (from
PROJECT.md, default docs/specs/)
for an existing spec file matching this feature
- If found, load it and show a summary to the user
- Ask: “A spec already exists for this feature. Update it, or
start fresh?”
- Update: Preserve Clarifications history, bump
spec-version,
revise stories and criteria based on new request
- Fresh: Archive old spec with
.bak suffix (overwrite any
existing .bak), generate new one
Phase 2: Specify
2.1 Load Spec Template
Read spec-template.md for the
output format. Use its section structure and frontmatter schema.
2.2 Generate User Stories
For each distinct user-facing behavior:
- Write a user story: As a , **I want** ,
**so that**
- Assign priority: P1 (must-have), P2 (should-have), P3 (nice-to-have)
- Include a “Why P_” line justifying the priority
- Ensure P1 stories form a coherent MVP that delivers value alone
- Each story should be independently implementable and testable
2.3 Write Acceptance Criteria
For each user story, write testable acceptance criteria:
- Use Given/When/Then format for every criterion
- P1 stories need both happy-path and error-path criteria
- P2/P3 stories need at least one criterion each
- Scan PROJECT.md Quality Standards while writing — criteria
categories like accessibility are cheaper to add now than to
discover in Phase 4 validation
- See spec-template.md §Acceptance Criteria for complexity hints
and specificity guidelines
- Depth target: Criteria should be specific enough to write a
test from, but not so specific that they dictate implementation.
“Then the output contains a section for each finding” is testable.
“Then the template uses a Handlebars loop” is
implementation. When in doubt, describe the observable outcome
2.4 Identify Edge Cases
Load clarification-taxonomy.md.
Scan all 9 categories against the feature:
- For each category, assess: Clear / Partial / Missing
- Document edge cases discovered in the spec’s Edge Cases section
- Tag each edge case with its taxonomy category:
[Category N]
- At minimum for P1 features: empty state, error state, boundary values
- Check PROJECT.md domain-specific concerns (Category 9)
2.5 Document Assumptions
Record reasonable defaults for unspecified details. See
spec-template.md §Assumptions for guidelines. Use the taxonomy’s
“Reasonable defaults” as a guide.
2.6 Mark Ambiguities
For categories marked Partial or Missing where the ambiguity
materially impacts the spec:
- Add
[NEEDS CLARIFICATION: <specific question>] markers
- Maximum 5 markers across the entire spec
- Prioritize by impact — see
clarification-taxonomy.md §Prioritization
for the full ranking
- Make informed guesses for everything else (document in Assumptions)
- Write the “Out of Scope” section — at least one item for medium+
features
2.7 Write Spec File
- Create the spec directory if it doesn’t exist
- Write the spec to the configured location (default:
docs/specs/<feature-name>.md) using kebab-case for the filename
- Include all sections from the template
- Set frontmatter status to
Draft
- Size check: Standard features should target ~80-150 lines
before Clarifications. If significantly over, reconsider scope —
it may be multiple features. Apply scope negotiation (see §When
to Use). Product-level specs (see §Product vs feature) naturally
exceed this — up to ~300 lines is expected for products with
6-12 user stories
Phase 3: Clarify
Skip this phase if no [NEEDS CLARIFICATION] markers exist.
Report: “No critical ambiguities detected. Skipping clarification.”
3.1 Prioritize Questions
From the [NEEDS CLARIFICATION] markers:
- Rank by (impact x uncertainty) — highest first
- Select up to 5 for the question queue
- Each question must materially affect implementation or testing
- Never reveal upcoming questions — one at a time only
3.2 Interactive Questioning Loop
For each question in the queue:
- State context: Quote the relevant spec section
- Recommend an answer: Based on codebase patterns, project
context, and best practices. Format:
**Recommended:** Option X -- <one sentence reasoning>
-
Present options as a markdown table:
| Option |
Description |
Implications |
| A |
… |
… |
| B |
… |
… |
| C |
… |
… |
- Accept response: User replies with:
- Option letter (e.g., “A”)
- “yes” or “recommended” to accept the recommendation
- A custom short answer
- Update the spec immediately after each answer:
- Replace the
[NEEDS CLARIFICATION] marker with the answer
- Add to Clarifications section:
- Q: <question> -> A: <answer>
- Save the file (atomic update)
- Handle scope changes: If the user’s answer introduces new
scope (new scenarios, new capabilities, new actors), update
affected stories and criteria before proceeding. Treat the
answer as a mini re-spec of the affected section — don’t just
record it and move on
- Proceed to next question or stop
3.3 Stop Conditions
Stop asking questions when:
- All markers are resolved
- User signals completion (“done”, “skip”, “proceed”, “no more”)
- 5 questions have been asked
- Remaining ambiguities are low-impact
3.4 Full Abort
If the user says “wrong approach”, “start over”, or similar:
- Delete the spec file
- Report: “Spec discarded. Re-run /spec with a revised description.”
- Stop the process
3.5 Deferred Markers
If questions remain after early termination, replace unresolved
markers with: [DEFERRED: not clarified -- <brief reason>]
Phase 4: Validate
4.1 Load Validation Checklist
Read validation-checklist.md
for the 8-point criteria.
4.2 Run 8-Point Check
For each point, verify with specific evidence from the spec:
- Testability — Every Given/When/Then maps to a test assertion
- Completeness — Every story has criteria; every P1 has error paths
- Clarity — No vague adjectives without measurable targets
- Scope — Out of Scope section exists and is non-empty
- Independence — P1 stories deliver standalone value
- Priority — P1/P2/P3 assigned; P1 set forms coherent MVP
- Edge Cases — Failure modes identified per P1 story
- Resolution — No unresolved
[NEEDS CLARIFICATION] markers
4.3 Project-Specific Validation
Using PROJECT.md (already loaded in Phase 1), run the
project-specific checks per validation-checklist.md
§Project-Specific Validation.
4.4 Fix Issues
If points fail, fix the spec directly and re-run the checklist.
See validation-checklist.md §Handling Failures for the iteration
limit and fallback behavior.
4.5 Mark Spec Ready
Update frontmatter status:
- All points pass:
status: Ready
- Some warnings remain:
status: Ready-with-warnings
Phase 5: Handoff
5.1 Summary Report
Output to the user:
- Spec file path
- Number of user stories by priority (P1/P2/P3)
- Number of acceptance criteria total
- Number of clarifications resolved (if Phase 3 ran)
- Validation result (Ready or Ready-with-warnings)
- Any deferred ambiguities or validation warnings
5.2 TDD Integration
Explain how the spec maps to TDD implementation:
| Spec Section |
TDD Phase |
How to Use |
| User Stories |
Phase 1: Analysis |
Scope of what to explore |
| Acceptance Criteria |
Phase 3: Pre-Test |
Write these as failing tests |
| Edge Cases |
Phase 3: Pre-Test |
Additional test cases |
| Affected Components |
Phase 2: Planning |
Starting point for chunks |
| Assumptions |
Phase 1: Analysis |
Context for architecture decisions |
5.3 Suggest Next Step
Next: /tdd implement <feature> (spec: docs/specs/<feature>.md)
If the spec has warnings, note them:
“The spec has N unresolved warnings — review the Notes section
before starting TDD implementation.”
Non-code projects: If the spec covers content, configuration,
or documentation (no executable code), adapt the TDD mapping:
- “Write these as failing tests” → “Write these as validation
criteria or review checks”
- “Starting point for chunks” → “Starting point for content chunks”
- Suggest a structured implementation order rather than
/tdd
Post-Validation Pivot
If the user challenges a fundamental assumption after the spec is
marked Ready (e.g., changing the architecture, switching platforms,
redefining scope), handle it as a controlled re-spec:
- Acknowledge the pivot — don’t defend the existing spec
- Assess impact — which stories survive the pivot vs need rewriting?
- Bump
spec-version and update the frontmatter
- Rewrite affected sections — stories, criteria, affected components
- Re-run Phase 4 validation on the updated spec
- Log the pivot in Clarifications:
- Pivot: <old> → <new> (<reason>)
This is cheaper than starting fresh because unaffected stories,
edge cases, and clarifications are preserved.
Lessons Learned (Apply Every Time)
- Acceptance Criteria That Can’t Fail Aren’t Criteria -
If a Given/When/Then always passes regardless of implementation,
it tests nothing. “System handles errors” is not testable.
“When API returns 500, user sees error banner with retry button” is
- Edge Cases Come from the Domain, Not the Feature -
The most dangerous edge cases aren’t in the feature itself — they’re
in how the feature interacts with existing domain rules. A “delete”
feature seems simple until you consider: shared items, items in
progress, items with dependencies, undo expectations, sync conflicts
- The Spec Is Not the Plan -
Specs define WHAT and WHY. Plans define HOW. If you catch yourself
writing framework names, file paths, or algorithm choices, stop —
those belong in TDD, not here
- Three Clarifications Beat Ten Assumptions -
A single well-chosen clarification question that resolves a P1 scope
ambiguity saves more rework than ten documented assumptions. The
max-5 limit forces prioritization — use it on what matters most
- “Simple” Features Hide Domain Complexity -
“Add search” sounds simple until you consider: fuzzy matching,
pagination, permissions filtering, empty states, indexing strategy.
The taxonomy exists to surface this complexity before implementation
- User Stories Should Survive a Pivot -
If changing the tech stack invalidates your user stories, they
contain implementation details. “User finds events by keyword”
survives a rewrite. “User calls GET /api/search” doesn’t
- Don’t Spec What You Can Grep -
If the codebase already implements a pattern, reference it instead
of re-specifying it. “Follow the same pattern as OrderService”
is more accurate than re-describing what OrderService does
- Scope Creep Starts in the Spec -
Every “while we’re at it” in a spec doubles implementation time.
Be aggressive about P2/P3 classification. Ship P1, then spec P2
separately. The Out of Scope section is your best defense
- The Best Specs Are Boring -
A good spec reads like a checklist, not a narrative. If it’s
exciting to read, it probably contains opinions instead of criteria.
Save the creativity for the code
- Check Quality Standards During Specification, Not Just Validation -
Phase 4 catches missing criteria categories (accessibility, offline
behavior) but fixing them there costs a validation iteration. Scan
PROJECT.md Quality Standards during Phase 2.3 while writing criteria
— it’s cheaper to include them upfront than to discover them late
Session Scope
Specs complete in one session. There is no tracker or session
resumption mechanism. To revisit a feature’s spec later, re-run
/spec — Phase 1.5 detects the existing file and offers update
or fresh start.
Commit Guidance
Do not commit proactively. Wait for the user to request it.
Refer to PROJECT.md for project-specific commit conventions
(author, message format, trailers).