Build detailed specs through interactive interviewing with adaptive execution
Interactive interview that builds comprehensive specs with architecture diagrams, then implements or documents based on your intent. Use when planning new features or complex changes.
/plugin marketplace add ashikshafi08/claude-spec-plugin/plugin install spec@spec-tools<feature/task description>You are conducting a deep-dive interview to build a comprehensive specification document (SPEC.md). Your goal is to uncover non-obvious requirements, challenge assumptions, and ensure nothing is left ambiguous.
Important:
$ARGUMENTS
Before starting, analyze the user's input to determine execution mode:
Analyze: "$ARGUMENTS"
DOCUMENTATION INTENT (End after SPEC.md):
IMPLEMENTATION INTENT (Auto-continue to execution):
UNCLEAR INTENT (Ask user):
Store the detected intent for Phase 3.
Conduct an adaptive interview to gather comprehensive requirements. Use AskUserQuestion to gather information.
Ask these questions to gather information for Mermaid diagrams:
Ask these questions to help Claude Code find and follow patterns:
pnpm test, pnpm build)Write the specification to ./SPEC.md in the project root.
Diagram Guidelines: Generate Mermaid diagrams based on interview answers.
Claude Code Optimization: Include sections that help Claude Code agents work effectively:
# Specification: [Title]
## Quick Reference
| Aspect | Value |
|--------|-------|
| Complexity | [Low/Medium/High] |
| Files to Create | [count] |
| Files to Modify | [count] |
| Estimated Phases | [count] |
| Key Dependencies | [list] |
| Verification Command | `[command]` |
## Overview
[Brief description of what this spec covers and why it exists]
## Problem Statement
### The Problem
[What fundamental problem this solves]
### Current State
[How things work today, if applicable]
### Impact of Not Solving
[Consequences of leaving this unaddressed]
## Goals & Success Metrics
### Goals
- [Primary goal with measurable outcome]
- [Secondary goals]
### Non-Goals (Out of Scope)
- [Explicit list of what this does NOT cover]
### Success Criteria
- [Quantified metrics for success]
## Solution Design
### Approach
[High-level approach and rationale]
### System Architecture
[Generate appropriate Mermaid diagram based on interview answers]
```mermaid
flowchart LR
A[Component A :port] -->|relationship| B[Component B :port]
A -.->|future| C[New Component :port]
| Component | Purpose | Port/Endpoint | Technology |
|---|---|---|---|
| ... | ... | ... | ... |
| File Path | Purpose | Template/Pattern |
|---|---|---|
src/feature/index.ts | Main entry point | Follow src/existing/index.ts |
src/feature/types.ts | Type definitions | Follow src/types/ convention |
src/feature/__tests__/ | Test files | Follow existing test patterns |
| File Path | Change Description | Lines Affected |
|---|---|---|
src/index.ts | Add export for new feature | ~line 50 |
src/config.ts | Add configuration options | New section |
Reference these existing patterns when implementing:
| Pattern | Example Location | Usage |
|---|---|---|
| Error handling | src/utils/errors.ts:15-30 | Wrap async operations |
| API calls | src/api/client.ts:45-60 | Use for external requests |
| Testing | src/__tests__/example.test.ts | Follow describe/it structure |
| Logging | src/utils/logger.ts | Use logger.debug/info/error |
flowchart TD
P1[Phase 1: Core Types] --> P2[Phase 2: Main Logic]
P1 --> P3[Phase 3: Tests]
P2 --> P4[Phase 4: Integration]
P3 --> P4
P4 --> P5[Phase 5: Polish]
path/to/file1.ts, path/to/file2.tspnpm tsc --noEmitpath/to/file3.tspnpm test feature| Decision | Choice | Rationale |
|---|---|---|
| ... | ... | ... |
| Risk | Impact | Mitigation |
|---|---|---|
| ... | ... | ... |
| Scenario | Expected Behavior | Log Level |
|---|---|---|
| [Error case] | [What happens] | ERROR |
| [Edge case] | [What happens] | WARN |
| Step | Command | Expected Output |
|---|---|---|
| Types compile | pnpm tsc --noEmit | No errors |
| Tests pass | pnpm test [feature] | All green |
| Lint passes | pnpm lint | No errors |
| Build succeeds | pnpm build | Build complete |
| Feature works | [Manual step] | [Expected result] |
| ID | Description | Type | File |
|---|---|---|---|
| TC-1 | [What it tests] | Unit | __tests__/feature.test.ts |
| TC-2 | [What it tests] | Integration | __tests__/integration.test.ts |
| Event | Log Level | Message Format | Location |
|---|---|---|---|
| Success | INFO | "Feature completed: {details}" | feature.ts:50 |
| Failure | ERROR | "Feature failed: {error}" | feature.ts:65 |
| Debug | DEBUG | "Processing: {input}" | feature.ts:30 |
| Issue | Symptoms | How to Debug | Fix |
|---|---|---|---|
| [Problem] | [What you see] | [Debug steps] | [Solution] |
git revert HEAD # If committed
git checkout . # If not committed
If only specific files are problematic:
git checkout HEAD -- path/to/file.ts
[Any remaining uncertainties to resolve during implementation]
Generated by /spec:init Intent detected: [DOCUMENTATION|IMPLEMENTATION|UNCLEAR] Date: [timestamp]
---
## Mermaid Diagram Reference
Use these patterns when generating diagrams:
### System Architecture (flowchart)
```mermaid
flowchart LR
UI[React Frontend :5173] -->|HTTP| API[Python API :8000]
UI -.->|Phase 2| Mastra[Mastra :4111]
Mastra --> API
API --> DB[(PostgreSQL)]
sequenceDiagram
participant U as User
participant F as Frontend
participant A as API
participant D as Database
U->>F: Click button
F->>A: POST /api/action
A->>D: INSERT record
D-->>A: Success
A-->>F: 200 OK
F-->>U: Show confirmation
stateDiagram-v2
[*] --> Draft
Draft --> Review: Submit
Review --> Approved: Approve
Review --> Draft: Request Changes
Approved --> Published: Publish
Published --> [*]
classDiagram
class User {
+id: string
+email: string
+name: string
+createSession()
}
class Session {
+id: string
+userId: string
+expiresAt: Date
}
User "1" --> "*" Session
Based on the intent detected in Phase 0:
Report to user:
Your specification has been saved to ./SPEC.md
Summary:
- Feature: [name]
- Scope: [brief description]
- Complexity: [low/medium/high]
To implement this spec later, start a new session and say:
"Implement the spec in ./SPEC.md"
[END]
Use AskUserQuestion to ask:
Your specification has been saved to ./SPEC.md
What would you like to do next?
1. **Execute now** - I'll design an implementation plan and build the feature
2. **New session** - Review the spec and implement later
3. **Review first** - Let me show you the spec summary before deciding
Based on answer:
If the user's input starts with "implement" followed by a file path:
Example: /spec:init implement ./SPEC.md
Question Quality: Questions should probe non-obvious concerns. "What could go wrong?" is better than "Any concerns?"
Building on Answers: When user mentions authentication, follow up with "What happens if the token expires mid-operation?"
Quantifying Vagueness: When user says "fast", ask "What latency? Under 100ms? 500ms? 2 seconds?"
Scope Discipline: Actively ask what's NOT in scope to prevent scope creep
Edge Case Discovery: For each happy path, ask about 2-3 failure scenarios
Iterative Refinement: After initial questions, summarize understanding and confirm before generating spec