This guide explains how to add new speckit commands to res_spec. Speckit commands are Claude Code slash commands that guide researchers through specification-driven workflows.
Speckit commands are markdown files in .claude/commands/ that Claude Code executes as slash commands. When a user types /speckit.specify, Claude Code:
- Loads
.claude/commands/speckit.specify.md - Interprets the markdown as instructions
- Executes the workflow defined within
- Produces output artifacts (typically in
specs/)
A typical speckit command involves:
.claude/commands/speckit.commandname.md ← Command definition
│
├──→ .specify/templates/*.md ← Document templates
│
├──→ .specify/memory/ ← Constitution checks
│
└──→ .specify/scripts/bash/ ← Helper scripts (optional)
Create .claude/commands/speckit.yourcommand.md:
# /speckit.yourcommand
[Brief description of what this command does]
## Prerequisites
- [What must exist before running this command]
- [Required files or prior commands]
## Process
1. [First step the agent should take]
2. [Second step]
3. [Third step]
## Input
- [What the user provides]
- [Expected format]
## Output
- [What files are generated]
- [Where they are placed]
## Template
Use the template at `.specify/templates/yourcommand-template.md`
## Validation
- [Quality checks to perform]
- [Constitution principles to verify]If your command generates structured documents, create .specify/templates/yourcommand-template.md:
# {{TITLE}}
**Branch**: `{{BRANCH_NAME}}`
**Created**: {{DATE}}
## Section 1
{{CONTENT_1}}
## Section 2
{{CONTENT_2}}Placeholders use {{PLACEHOLDER_NAME}} syntax and are filled by the agent during execution.
For commands that need validation or complex logic, add .specify/scripts/bash/yourcommand-helper.sh:
#!/usr/bin/env bash
# Description: Helper for speckit.yourcommand
# Usage: ./yourcommand-helper.sh [OPTIONS]
set -euo pipefail
# Your helper logic hereIf the command should be discoverable, add it to CLAUDE.md:
## Available Commands
- `/speckit.yourcommand` - Brief descriptionA command to review specifications for completeness:
.claude/commands/speckit.review.md:
# /speckit.review
Review a completed feature specification for constitution compliance and quality.
## Prerequisites
- Feature specification exists in `specs/NNN-feature-name/`
- spec.md and plan.md are complete
## Process
1. Read the feature specification from the provided path
2. Check each constitution principle:
- Research-First Development: Does feature serve scientific goals?
- Reproducibility: Is environment documented?
- Documentation: Is "why" explained before "how"?
- Incremental: Is MVP defined?
- Library Integration: Are standard tools used?
3. Review acceptance criteria for testability
4. Generate review report
## Input
Provide the feature path: `specs/NNN-feature-name/`
## Output
- `specs/NNN-feature-name/review.md` - Review findings
## Validation Checklist
- [ ] All 5 constitution principles addressed
- [ ] Acceptance criteria are measurable
- [ ] Dependencies are documented
- [ ] No out-of-scope items in implementationA command to export specification summaries:
.claude/commands/speckit.export.md:
# /speckit.export
Export feature specification summary for external sharing.
## Prerequisites
- Feature specification is complete (spec.md, plan.md, tasks.md exist)
## Process
1. Read the complete feature specification
2. Generate a summary document with:
- Feature overview (from spec.md)
- Key decisions (from plan.md)
- Task count and status (from tasks.md)
3. Format for external audience (no internal references)
## Input
- Feature path: `specs/NNN-feature-name/`
- Format: markdown (default) or plain text
## Output
- `specs/NNN-feature-name/summary.md` - Exportable summaryUse double curly braces for placeholders:
| Placeholder | Description |
|---|---|
{{FEATURE_NAME}} |
Human-readable feature name |
{{BRANCH_NAME}} |
Git branch name (NNN-feature-slug) |
{{DATE}} |
Current date (YYYY-MM-DD) |
{{USER_STORIES}} |
Generated user stories section |
{{REQUIREMENTS}} |
Requirements list |
Templates can include optional sections with comments:
## Optional Section
<!-- Include if: condition description -->
{{OPTIONAL_CONTENT}}
<!-- End optional -->Templates can reference other templates:
## Constitution Check
<!-- See: .specify/templates/constitution-check.md -->
{{CONSTITUTION_CHECK}}Commands that create plans should include constitution validation:
## Constitution Check
Before proceeding, verify this feature aligns with research principles:
### Principle I: Research-First Development
- Does this feature serve a scientific research goal?
- Is the purpose clearly documented?
### Principle II: Reproducibility
- Is the environment specified?
- Are dependencies documented?
[Continue for all 5 principles]
**Gate**: All principles must pass to proceed with planning.In command definitions, reference the constitution:
## Validation
Verify against constitution at `.specify/memory/constitution.md`:
- Check all applicable principles
- Document any principle-specific considerations
- Flag potential violations for user review- Single responsibility - Each command does one thing well
- Clear prerequisites - State what must exist before running
- Defined outputs - Specify exactly what gets created
- Validation steps - Include quality checks
- Consistent structure - Follow patterns from existing templates
- Meaningful placeholders - Names should be self-documenting
- Include examples - Show expected content format
- Link to guides - Reference relevant documentation
- Update CONTRIBUTING.md - Add command to developer docs
- Add to README if user-facing - Include in command list
- Include examples - Show realistic usage
-
Create a test feature:
# Run your command /speckit.yourcommand "Test feature"
-
Verify output:
- Check generated files exist
- Validate content structure
- Ensure links work
-
Test edge cases:
- Missing prerequisites
- Invalid input
- Large inputs
Run through the full workflow:
# 1. Create specification
/speckit.specify "Test feature"
# 2. Run your new command
/speckit.yourcommand specs/NNN-test-feature/
# 3. Verify it integrates with existing commands
/speckit.plan- Verify file is in
.claude/commands/ - Check filename matches
speckit.commandname.md - Ensure Claude Code has access to the directory
- Verify template path is correct
- Check template file exists
- Ensure markdown syntax is valid
- Check prerequisites are met
- Verify output path is writable
- Review command process steps
- Architecture - System overview
- Testing Guide - Validation procedures
- CONTRIBUTING.md - Contribution guidelines