| name | brain-spec |
| description | Spec lifecycle management — create, interview, list, get, update, delete, and archive feature specifications. |
| argument-hint | <subcommand> [args] — create|interview|list|get|update|delete|archive |
| allowed-tools | Glob, Read, Write, Edit, Bash |
Brain Spec — Spec Lifecycle Management
Create, interview, view, update, delete, and archive feature specifications stored in .brain-spec/specs/.
Usage
/brain-spec <subcommand> [arguments]
Subcommands:
create <name> — Create a blank spec or start an interview
interview <name> — Start/resume a guided interview for a spec
list [--status <status>] — List all specs with status and task counts
get <slug> — Display a spec's content and metadata
update <slug> — Interactively update spec content or status
delete <slug> — Delete a spec (requires confirmation)
archive <slug> — Move a spec to the archive
Instructions
Parse $ARGUMENTS to determine the subcommand and its parameters. The first word is the subcommand; remaining words are arguments.
Reference: Slug Rules
Slugs are generated from spec names:
- Lowercase the name
- Replace any sequence of non-alphanumeric characters with a single hyphen
- Strip leading/trailing hyphens
- Truncate to 100 characters
- Valid slug pattern:
^[a-z0-9]([a-z0-9-]*[a-z0-9])?$
Example: "User Authentication Flow" → user-authentication-flow
Reference: SpecMeta Schema
Each spec has a {slug}.meta.json file in .brain-spec/specs/:
{
"specSlug": "string",
"name": "string (original name)",
"description": "string",
"status": "draft | active | completed | archived",
"interview": {
"currentCategory": "string (one of 8 categories)",
"questionsAsked": "number",
"answers": [
{
"category": "string",
"question": "string",
"answer": "string"
}
],
"coverageMap": {
"functional": 0.0,
"technical": 0.0,
"data-model": 0.0,
"edge-cases": 0.0,
"security": 0.0,
"testing": 0.0,
"nonfunctional": 0.0,
"implementation": 0.0
}
},
"createdAt": "ISO 8601 timestamp",
"updatedAt": "ISO 8601 timestamp"
}
Reference: Interview Question Bank
8 categories, 5 questions each (40 total):
Functional Requirements:
- What is the primary purpose of this feature/system? What problem does it solve?
- Who are the target users? Describe the key user personas.
- What are the main user flows? Walk through the critical path.
- What inputs does the system accept and what outputs does it produce?
- What business rules or constraints govern the behavior?
Technical Constraints:
- What programming language and framework will be used?
- Are there existing codebase patterns or conventions that must be followed?
- What external dependencies or third-party services are required?
- What are the version requirements or compatibility constraints?
- How will this integrate with the existing system architecture?
Data Model:
- What are the core data entities and their relationships?
- How will data be stored (database type, schema structure)?
- How will the schema evolve over time? Migration strategy?
- What data validation rules apply?
- Are there data retention or cleanup requirements?
Edge Cases & Error Handling:
- What happens when the system receives invalid or unexpected input?
- How should the system handle network failures or timeouts?
- What are the rate limiting and throttling requirements?
- How should concurrent access or race conditions be handled?
- What are the failure modes and recovery strategies?
Security:
- What authentication and authorization mechanisms are needed?
- How will user input be sanitized to prevent injection attacks?
- What secrets management approach will be used?
- Are there OWASP concerns specific to this feature?
- What audit logging or compliance requirements exist?
Testing Strategy:
- What testing strategy will be used (unit, integration, e2e)?
- What are the critical test scenarios that must be covered?
- What is the target code coverage percentage?
- How will edge cases and error paths be tested?
- Are there performance or load testing requirements?
Non-Functional Requirements:
- What are the performance targets (response time, throughput)?
- What are the scalability expectations?
- Are there accessibility (a11y) requirements?
- Are there internationalization (i18n) requirements?
- What monitoring and observability is needed?
Implementation Approach:
- What is the suggested task breakdown for implementation?
- What is the dependency ordering between tasks?
- What is the estimated complexity (simple, moderate, complex)?
- Are there any tasks that should be parallelized?
- What are the key milestones or checkpoints?
Category display names:
- functional → "Functional Requirements"
- technical → "Technical Constraints"
- data-model → "Data Model"
- edge-cases → "Edge Cases & Error Handling"
- security → "Security Considerations"
- testing → "Testing Strategy"
- nonfunctional → "Non-Functional Requirements"
- implementation → "Implementation Approach"
Reference: Spec Template (blank)
# Spec: {{name}}
## Overview
{{description}}
## Functional Requirements
- [ ] TODO: Define functional requirements
## Technical Constraints
- TODO: Define technical constraints
## Data Model
TODO: Define data models and relationships
## Edge Cases & Error Handling
- TODO: Define edge cases
## Security Considerations
- TODO: Define security requirements
## Testing Strategy
- TODO: Define testing approach
## Non-Functional Requirements
- TODO: Define performance, scalability requirements
## Implementation Checklist
- [ ] TODO: Break down into tasks
## Acceptance Criteria
- [ ] TODO: Define acceptance criteria
Reference: Archive Metadata Schema
{
"specSlug": "string",
"archivedAt": "ISO 8601 timestamp",
"reason": "completed | deprecated | superseded",
"supersededBy": "string | null",
"summary": "string",
"finalStatus": {
"totalTasks": 0,
"completedTasks": 0,
"specStatus": "string"
}
}
Subcommand: create
Usage: /brain-spec create My Feature Name
- Verify
.brain-spec/specs/ directory exists. If not, tell the user to run /brain-init first.
- Generate the slug from the name (everything after "create ").
- Check if
.brain-spec/specs/{slug}.meta.json already exists. If so, error with "Spec '{slug}' already exists."
- Ask the user: "How do you want to create this spec?"
- Interview (recommended) — Guided Q&A that builds the spec interactively
- Blank template — Creates a spec with TODO placeholders to fill in manually
- If Blank template: Write
{slug}.meta.json and {slug}.md using the templates above, with status "draft". Display the file path and suggest next steps.
- If Interview: Write
{slug}.meta.json with status "draft" and empty interview state, then immediately begin the interview flow (see interview subcommand below).
Subcommand: interview
Usage: /brain-spec interview my-feature-name
Runs a guided interview to build a spec. Can be started fresh or resumed.
-
Read .brain-spec/specs/{slug}.meta.json. If not found, error.
-
Check the interview field:
- If null or missing: Initialize interview state with
currentCategory: "functional", questionsAsked: 0, empty answers, all coverage at 0.0. Save the meta file.
- If exists with
questionsAsked > 0: Resume from where we left off. Tell the user: "Resuming interview for '{name}' — {questionsAsked} questions answered so far."
-
Read steering context: If .brain-spec/steering/ has any documents, read them to provide context for the interview. Mention relevant steering context when asking questions.
-
Interview loop: For each question:
- Determine the current category and find the next unanswered question in that category.
- Present the question to the user, prefixed with the category name in brackets:
[Functional Requirements] What is the primary purpose...
- Wait for the user's response.
- Record the answer in the interview state:
{ category, question, answer }.
- Update
questionsAsked counter.
- Update coverage for the category:
categoryAnswers.length / 5 (5 questions per category).
- If coverage for current category >= 0.6 (3+ answers), advance to the next uncovered category.
- Save the meta file after each answer.
- After each answer, show a brief progress indicator:
[{questionsAsked} answered | {currentCategory} | coverage: {percentage}%]
- If
questionsAsked >= 3, offer the option to finish early: "You can continue answering or type 'done' to compile the spec now."
-
Category advancement: When advancing categories, go in order: functional → technical → data-model → edge-cases → security → testing → nonfunctional → implementation. Skip categories already at >= 0.6 coverage. If all categories are covered, tell the user all categories are covered and offer to compile.
-
Compiling the spec (when user says "done" or all categories covered):
- Build the spec markdown from interview answers:
- Title:
# Spec: {name}
- Description as blockquote if present
## Overview section using the first functional answer
- One
## {Category Display Name} section per category that has answers
- Within each section, one
### {question} subsection per answer
- Skip the first functional answer in the Functional Requirements section (already in Overview)
## Acceptance Criteria with a TODO checkbox
## Implementation Checklist with a TODO checkbox (only if implementation answers exist)
- Footer:
--- then italicized generation metadata (questions asked, categories covered)
- Write the compiled markdown to
.brain-spec/specs/{slug}.md
- Update meta: set
status to "active", update updatedAt
- Display: "Spec compiled and saved to .brain-spec/specs/{slug}.md" with a summary of coverage
Subcommand: list
Usage: /brain-spec list or /brain-spec list --status active
- Use Glob to find all
.brain-spec/specs/*.meta.json files.
- Read each meta file.
- If
--status is provided, filter by that status.
- For each spec, also check if
.brain-spec/tasks/{slug}/tasks.json exists and count tasks.
- Display a formatted table:
Slug Status Tasks Created
───────────────── ───────── ─────── ──────────
user-auth-flow active 3/5 2025-01-15
api-redesign draft 0/0 2025-01-20
If no specs exist, display: "No specs found. Create one with /brain-spec create <name>"
Subcommand: get
Usage: /brain-spec get my-feature-name
- Read
.brain-spec/specs/{slug}.meta.json. If not found, error.
- Read
.brain-spec/specs/{slug}.md. If not found, show metadata only.
- Display metadata summary (status, created, updated, interview coverage if present).
- Display the full spec markdown content.
Subcommand: update
Usage: /brain-spec update my-feature-name
- Read
.brain-spec/specs/{slug}.meta.json. If not found, error.
- Ask the user what they want to update. Present these choices and wait for their response:
- Status — Change spec status (draft/active/completed)
- Content — Edit the spec markdown
- Description — Update the spec description
- For Status: Ask which status to set. Update meta, save.
- For Content: Read current
.brain-spec/specs/{slug}.md, show it, ask what to change. Apply edits using the Edit tool. Update updatedAt in meta.
- For Description: Ask for the new description, update meta, save.
Subcommand: delete
Usage: /brain-spec delete my-feature-name
- Read
.brain-spec/specs/{slug}.meta.json. If not found, error.
- Ask for confirmation: "Are you sure you want to delete spec '{name}' ({slug})? This will remove the spec file, metadata, and all associated tasks. This cannot be undone."
- If confirmed:
- Delete
.brain-spec/specs/{slug}.md
- Delete
.brain-spec/specs/{slug}.meta.json
- Delete
.brain-spec/tasks/{slug}/ directory if it exists
- Confirm deletion: "Spec '{slug}' deleted."
- If not confirmed: "Deletion cancelled."
Subcommand: archive
Usage: /brain-spec archive my-feature-name
- Read
.brain-spec/specs/{slug}.meta.json. If not found, error.
- Ask the user for:
- Reason: completed / deprecated / superseded (ask the user to choose)
- Summary: Brief summary of what was accomplished
- If superseded: Superseded by: slug of the replacement spec
- Count tasks from
.brain-spec/tasks/{slug}/tasks.json if it exists.
- Create archive directory:
.brain-spec/archive/{slug}/
- Write
.brain-spec/archive/{slug}/archive-metadata.json using the Archive Metadata Schema.
- Move (copy then delete) these files into the archive directory:
.brain-spec/specs/{slug}.md → .brain-spec/archive/{slug}/{slug}.md
.brain-spec/specs/{slug}.meta.json → .brain-spec/archive/{slug}/{slug}.meta.json
.brain-spec/tasks/{slug}/ → .brain-spec/archive/{slug}/tasks/ (if exists)
- Confirm: "Spec '{slug}' archived to .brain-spec/archive/{slug}/"