This skill should be used when the user asks to "create a spec", "write specification", "spec out a feature", "design a feature", "document requirements", or when planning features before implementation. Also auto-invokes when .spec folder exists and user discusses feature design.
This skill implements a checkpoint-driven specification workflow where:
Step → Save State → Show Result → Ask "Continue?" → Wait for User
The orchestrator ONLY:
The orchestrator NEVER:
All exploration, analysis, and writing is done by sub-agents. Results are summarized back to the orchestrator.
┌─────────────────────────────────────────────────────────────────┐
│ Spec Orchestrator (Main Conversation) │
│ - Checkpoint management │
│ - User interaction (AskUserQuestion) │
│ - Phase transitions │
│ - Sub-agent invocation via Task tool │
└──────────────────────────────┬──────────────────────────────────┘
│ Task tool calls
┌───────────────────────┼───────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ DISCOVERY │ │ DESIGN │ │ FINALIZE │
│ spec-context- │ │ spec-functional │ │ spec-document- │
│ analyzer │ │ -designer │ │ writer │
│ spec-domain- │ │ spec-api- │ │ spec-validator │
│ explorer │ │ designer │ │ spec-acceptance │
│ spec-constraint │ │ spec-edge-case │ │ -generator │
│ -gatherer │ │ -finder │ └─────────────────┘
└─────────────────┘ └─────────────────┘
| Checkpoint | When | State Saved |
|---|---|---|
SESSION_CREATED | After session initialization | Session folder, initial input |
CONTEXT_ANALYZED | After codebase analysis | Related code, patterns, architecture |
DOMAIN_EXPLORED | After domain exploration | Entities, relationships, terminology |
CONSTRAINTS_GATHERED | After constraint gathering | NFRs, dependencies, limitations |
FUNCTIONAL_DESIGNED | After functional design | Requirements, user stories |
API_DESIGNED | After interface design | Contracts, data models |
EDGE_CASES_IDENTIFIED | After edge case analysis | Boundaries, error scenarios |
SPEC_DRAFTED | After document creation | Complete spec draft |
SPEC_VALIDATED | After validation | Feasibility confirmed |
ACCEPTANCE_GENERATED | After criteria generation | Testable acceptance criteria |
SESSION_COMPLETE | After finalization | Archived, ready for TDD |
Orchestrator Action: Check for existing sessions
# Check for active sessions
ls .spec/sessions/*/context.json 2>/dev/null
If session exists:
If no session:
Orchestrator Action: Create folders and initial files
# Run init script
bash ~/.claude/skills/spec/scripts/init-spec-folder.sh "feature-name"
Checkpoint: SESSION_CREATED
Save responses to input.md
Orchestrator Action: Invoke sub-agent
Task(
subagent_type="spec-context-analyzer",
prompt="Analyze the codebase for context related to: [feature description]
Target areas: [from user input]
Save results to: [session_path]/discovery/context.md
Return a brief summary (5-10 lines) of:
- Related existing code and patterns found
- Architecture constraints identified
- Key integration points"
)
Checkpoint: CONTEXT_ANALYZED
Orchestrator Action: Invoke sub-agent
Task(
subagent_type="spec-domain-explorer",
prompt="Explore the domain for: [feature description]
Context: [from previous step summary]
Save results to: [session_path]/discovery/domain.md
Return a brief summary of:
- Key entities identified
- Important relationships
- Business rules discovered"
)
Checkpoint: DOMAIN_EXPLORED
Orchestrator Action: Invoke sub-agent
Task(
subagent_type="spec-constraint-gatherer",
prompt="Gather constraints for: [feature description]
Context: [from discovery]
Domain: [from domain exploration]
Save results to: [session_path]/discovery/constraints.md
Return a brief summary of:
- Performance requirements
- Security considerations
- Dependencies and compatibility
- Technical limitations"
)
Checkpoint: CONSTRAINTS_GATHERED
Orchestrator Action: Invoke sub-agent
Task(
subagent_type="spec-functional-designer",
prompt="Design functional requirements for: [feature description]
Context from discovery:
- Context: [summary]
- Domain: [summary]
- Constraints: [summary]
Save results to: [session_path]/design/functional.md
Return a brief summary of:
- Number of requirements defined
- Key user stories or use cases
- Main behaviors specified"
)
Checkpoint: FUNCTIONAL_DESIGNED
Orchestrator Action: Invoke sub-agent
Task(
subagent_type="spec-api-designer",
prompt="Design interfaces and contracts for: [feature description]
Functional requirements: [from previous step]
Domain model: [from discovery]
Constraints: [from discovery]
Save results to: [session_path]/design/api.md
Return a brief summary of:
- Interfaces/APIs defined
- Data models created
- Contract specifications"
)
Checkpoint: API_DESIGNED
Orchestrator Action: Invoke sub-agent
Task(
subagent_type="spec-edge-case-finder",
prompt="Identify edge cases for: [feature description]
Functional requirements: [from design]
API contracts: [from design]
Constraints: [from discovery]
Save results to: [session_path]/design/edge-cases.md
Return a brief summary of:
- Number of edge cases identified
- Categories (boundary, error, race condition, etc.)
- Most critical scenarios"
)
Checkpoint: EDGE_CASES_IDENTIFIED
Orchestrator Action: Invoke sub-agent
Task(
subagent_type="spec-document-writer",
prompt="Write the complete specification document.
Session path: [session_path]
Feature: [feature description]
Combine all discovery and design artifacts into a cohesive spec.
Save to: [session_path]/spec.md
Return: document structure outline"
)
Checkpoint: SPEC_DRAFTED
Orchestrator Action: Invoke sub-agent
Task(
subagent_type="spec-validator",
prompt="Validate the specification document.
Spec file: [session_path]/spec.md
Check for:
- Completeness (all requirements testable)
- Consistency (no contradictions)
- Feasibility (technically achievable)
- Clarity (unambiguous language)
Save validation report to: [session_path]/validation.md
Return: validation status and any issues found"
)
If issues found:
Checkpoint: SPEC_VALIDATED
Orchestrator Action: Invoke sub-agent
Task(
subagent_type="spec-acceptance-generator",
prompt="Generate testable acceptance criteria from the specification.
Spec file: [session_path]/spec.md
Edge cases: [session_path]/design/edge-cases.md
Format each criterion as Given/When/Then.
These will feed directly into TDD test-designer.
Save to: [session_path]/acceptance-criteria.md
Return: number of criteria and category breakdown"
)
Checkpoint: ACCEPTANCE_GENERATED
Orchestrator Action: Archive and summarize
Checkpoint: SESSION_COMPLETE
Ask user: "Specification complete! Would you like to start TDD implementation now?"
If yes → Suggest invoking /tdd skill with spec path as input
When user says "Resume spec" or skill detects active session:
// Read context.json
const context = loadContext(sessionPath);
const lastCheckpoint = context.checkpoints[context.checkpoints.length - 1];
## Resuming Spec Session
**Session**: [session_id]
**Feature**: [feature description]
**Last checkpoint**: [checkpoint type] at [time]
**Progress**: Phase [N], Step: [step name]
**Last action**: [description of what was done]
Continue from here?
Based on checkpoint type, resume at the appropriate step in the workflow above.
{
"schema_version": "1.0",
"session_id": "2026-02-01_feature-name",
"metadata": {
"created_at": "2026-02-01T10:00:00Z",
"updated_at": "2026-02-01T14:30:00Z",
"feature": "Feature description from user"
},
"input": {
"description": "User's feature description",
"known_constraints": "Any constraints mentioned",
"target_areas": ["area1", "area2"]
},
"discovery": {
"context_summary": "Brief summary of codebase analysis",
"domain_summary": "Brief summary of domain exploration",
"constraints_summary": "Brief summary of constraints"
},
"design": {
"functional_count": 5,
"functional_summary": "Brief summary of requirements",
"api_count": 3,
"api_summary": "Brief summary of interfaces",
"edge_case_count": 8,
"edge_case_summary": "Brief summary of edge cases"
},
"review": {
"spec_outline": "Document structure",
"validation_status": "passed",
"validation_issues": []
},
"output": {
"spec_file": ".spec/sessions/*/spec.md",
"acceptance_criteria_file": ".spec/sessions/*/acceptance-criteria.md",
"acceptance_criteria_count": 12
},
"checkpoints": [
{
"type": "SESSION_CREATED",
"timestamp": "2026-02-01T10:00:00Z"
},
{
"type": "CONTEXT_ANALYZED",
"timestamp": "2026-02-01T10:15:00Z"
}
]
}
Use AskUserQuestion tool with options:
{
"questions": [{
"question": "[Summary of what was done]. Continue to [next step]?",
"header": "Spec",
"options": [
{"label": "Continue", "description": "Proceed to next step"},
{"label": "Stop here", "description": "Save checkpoint and stop. Resume later."},
{"label": "Show details", "description": "See more information about this step"}
],
"multiSelect": false
}]
}
{
"questions": [
{
"question": "What type of specification are you creating?",
"header": "Spec Type",
"options": [
{"label": "New Feature", "description": "Specifying a completely new feature"},
{"label": "Enhancement", "description": "Extending existing functionality"},
{"label": "Refactoring", "description": "Restructuring without changing behavior"},
{"label": "Bug Fix", "description": "Specifying the correct behavior for a bug"}
],
"multiSelect": false
}
]
}
When user chooses "Stop here":
Session saved at checkpoint: [type]
To resume: say "Resume spec" or invoke /spec
CRITICAL: Always use Task tool for sub-agents. Never do the work inline.
// CORRECT - Delegate to sub-agent
Task(
subagent_type="spec-context-analyzer",
prompt="Analyze codebase for [feature]..."
)
// WRONG - Don't do this inline
Read(source_file) // Don't read files directly
Grep(pattern) // Don't search directly
Write(spec_file) // Don't write directly
SKILL.md - This orchestration documentagents/ - Sub-agent definitions (9 agents)references/ - Best practices and templatesscripts/ - Utility scriptsexamples/ - Example sessions.spec/learnings.json - Cross-session learnings.spec/sessions/*/context.json - Session state.spec/sessions/*/progress.md - Human-readable progress.spec/sessions/*/input.md - User's initial input.spec/sessions/*/discovery/ - Discovery phase artifacts.spec/sessions/*/design/ - Design phase artifacts.spec/sessions/*/spec.md - Final specification.spec/sessions/*/validation.md - Validation report.spec/sessions/*/acceptance-criteria.md - For TDDspec (creates) → acceptance-criteria.md → tdd-test-designer (consumes)
When user finishes spec and wants to implement:
spec skill outputs acceptance-criteria.md/tddtdd-test-designer reads acceptance criteria as inputThe acceptance-criteria.md file uses this format for TDD compatibility:
# Acceptance Criteria for [Feature]
## Criterion 1: [Name]
**Priority**: High/Medium/Low
**Category**: Happy path / Edge case / Error handling
**Given** [precondition]
**When** [action]
**Then** [expected result]
### Test Hints
- Suggested test name: `should_[behavior]_when_[condition]`
- Key assertions: [list]
- Mock requirements: [list]