Instructions for AI coding assistants using OpenSpec for spec-driven development.
openspec spec list --long, openspec list (use rg only for full-text search)change-id: kebab-case, verb-led (add-, update-, remove-, refactor-)proposal.md, tasks.md, design.md (only if needed), and delta specs per affected capability## ADDED|MODIFIED|REMOVED|RENAMED Requirements; include at least one #### Scenario: per requirementopenspec validate [change-id] --strict and fix issuesCreate proposal when you need to:
Triggers (examples):
Loose matching guidance:
proposal, change, speccreate, plan, make, start, helpSkip proposal for:
Workflow
openspec/project.md, openspec list, and openspec list --specs to understand current context.change-id and scaffold proposal.md, tasks.md, optional design.md, and spec deltas under openspec/changes/<id>/.## ADDED|MODIFIED|REMOVED Requirements with at least one #### Scenario: per requirement.openspec validate <id> --strict and resolve any issues before sharing the proposal.Track these steps as TODOs and complete them one by one.
tasks.md is finished before updating statuses- [x] so the list reflects realityAfter deployment, create separate PR to:
changes/[name]/ → changes/archive/YYYY-MM-DD-[name]/specs/ if capabilities changedopenspec archive <change-id> --skip-specs --yes for tooling-only changes (always pass the change ID explicitly)openspec validate --strict to confirm the archived change passes checksContext Checklist:
specs/[capability]/spec.mdchanges/ for conflictsopenspec/project.md for conventionsopenspec list to see active changesopenspec list --specs to see existing capabilitiesBefore Creating Specs:
openspec show [spec] to review current stateopenspec spec list --long (or --json for scripts)openspec list (or openspec change list --json - deprecated but available)openspec show <spec-id> --type spec (use --json for filters)openspec show <change-id> --json --deltas-onlyrg -n "Requirement:|Scenario:" openspec/specs# Essential commands
openspec list # List active changes
openspec list --specs # List specifications
openspec show [item] # Display change or spec
openspec validate [item] # Validate changes or specs
openspec archive <change-id> [--yes|-y] # Archive after deployment (add --yes for non-interactive runs)
# Project management
openspec init [path] # Initialize OpenSpec
openspec update [path] # Update instruction files
# Interactive mode
openspec show # Prompts for selection
openspec validate # Bulk validation mode
# Debugging
openspec show [change] --json --deltas-only
openspec validate [change] --strict
--json - Machine-readable output--type change|spec - Disambiguate items--strict - Comprehensive validation--no-interactive - Disable prompts--skip-specs - Archive without spec updates--yes/-y - Skip confirmation prompts (non-interactive archive)openspec/
├── project.md # Project conventions
├── specs/ # Current truth - what IS built
│ └── [capability]/ # Single focused capability
│ ├── spec.md # Requirements and scenarios
│ └── design.md # Technical patterns
├── changes/ # Proposals - what SHOULD change
│ ├── [change-name]/
│ │ ├── proposal.md # Why, what, impact
│ │ ├── tasks.md # Implementation checklist
│ │ ├── design.md # Technical decisions (optional; see criteria)
│ │ └── specs/ # Delta changes
│ │ └── [capability]/
│ │ └── spec.md # ADDED/MODIFIED/REMOVED
│ └── archive/ # Completed changes
New request?
├─ Bug fix restoring spec behavior? → Fix directly
├─ Typo/format/comment? → Fix directly
├─ New feature/capability? → Create proposal
├─ Breaking change? → Create proposal
├─ Architecture change? → Create proposal
└─ Unclear? → Create proposal (safer)
Create directory: changes/[change-id]/ (kebab-case, verb-led, unique)
Write proposal.md: ```markdown
[1-2 sentences on problem/opportunity]
specs/[capability]/spec.md
```markdown
The system SHALL provide…
[Complete modified requirement]
Reason: [Why removing] Migration: [How to handle]
If multiple capabilities are affected, create multiple delta files under `changes/[change-id]/specs/<capability>/spec.md`—one per capability.
4. **Create tasks.md:**
```markdown
## 1. Implementation
- [ ] 1.1 Create database schema
- [ ] 1.2 Implement API endpoint
- [ ] 1.3 Add frontend component
- [ ] 1.4 Write tests
design.md if any of the following apply; otherwise omit it:
Minimal design.md skeleton:
## Context
[Background, constraints, stakeholders]
## Goals / Non-Goals
- Goals: [...]
- Non-Goals: [...]
## Decisions
- Decision: [What and why]
- Alternatives considered: [Options + rationale]
## Risks / Trade-offs
- [Risk] → Mitigation
## Migration Plan
[Steps, rollback]
## Open Questions
- [...]
CORRECT (use #### headers):
#### Scenario: User login success
- **WHEN** valid credentials provided
- **THEN** return JWT token
WRONG (don’t use bullets or bold):
- **Scenario: User login** ❌
**Scenario**: User login ❌
### Scenario: User login ❌
Every requirement MUST have at least one scenario.
## ADDED Requirements - New capabilities## MODIFIED Requirements - Changed behavior## REMOVED Requirements - Deprecated features## RENAMED Requirements - Name changesHeaders matched with trim(header) - whitespace ignored.
Common pitfall: Using MODIFIED to add a new concern without including the previous text. This causes loss of detail at archive time. If you aren’t explicitly changing the existing requirement, add a new requirement under ADDED instead.
Authoring a MODIFIED requirement correctly:
1) Locate the existing requirement in openspec/specs/<capability>/spec.md.
2) Copy the entire requirement block (from ### Requirement: ... through its scenarios).
3) Paste it under ## MODIFIED Requirements and edit to reflect the new behavior.
4) Ensure the header text matches exactly (whitespace-insensitive) and keep at least one #### Scenario:.
Example for RENAMED:
## RENAMED Requirements
- FROM: `### Requirement: Login`
- TO: `### Requirement: User Authentication`
“Change must have at least one delta”
changes/[name]/specs/ exists with .md files“Requirement must have at least one scenario”
#### Scenario: format (4 hashtags)Silent scenario parsing failures
#### Scenario: Nameopenspec show [change] --json --deltas-only# Always use strict mode for comprehensive checks
openspec validate [change] --strict
# Debug delta parsing
openspec show [change] --json | jq '.deltas'
# Check specific requirement
openspec show [spec] --json -r 1
# 1) Explore current state
openspec spec list --long
openspec list
# Optional full-text search:
# rg -n "Requirement:|Scenario:" openspec/specs
# rg -n "^#|Requirement:" openspec/changes
# 2) Choose change id and scaffold
CHANGE=add-two-factor-auth
mkdir -p openspec/changes/$CHANGE/{specs/auth}
printf "## Why\n...\n\n## What Changes\n- ...\n\n## Impact\n- ...\n" > openspec/changes/$CHANGE/proposal.md
printf "## 1. Implementation\n- [ ] 1.1 ...\n" > openspec/changes/$CHANGE/tasks.md
# 3) Add deltas (example)
cat > openspec/changes/$CHANGE/specs/auth/spec.md << 'EOF'
## ADDED Requirements
### Requirement: Two-Factor Authentication
Users MUST provide a second factor during login.
#### Scenario: OTP required
- **WHEN** valid credentials are provided
- **THEN** an OTP challenge is required
EOF
# 4) Validate
openspec validate $CHANGE --strict
openspec/changes/add-2fa-notify/
├── proposal.md
├── tasks.md
└── specs/
├── auth/
│ └── spec.md # ADDED: Two-Factor Authentication
└── notifications/
└── spec.md # ADDED: OTP email notification
auth/spec.md
## ADDED Requirements
### Requirement: Two-Factor Authentication
...
notifications/spec.md
## ADDED Requirements
### Requirement: OTP Email Notification
...
Only add complexity with:
file.ts:42 format for code locationsspecs/auth/spec.mduser-auth, payment-captureadd-two-factor-authadd-, update-, remove-, refactor--2, -3, etc.| Task | Tool | Why |
|---|---|---|
| Find files by pattern | Glob | Fast pattern matching |
| Search code content | Grep | Optimized regex search |
| Read specific files | Read | Direct file access |
| Explore unknown scope | Task | Multi-step investigation |
openspec list to see active changes--strict flagchanges/ - Proposed, not yet builtspecs/ - Built and deployedarchive/ - Completed changesproposal.md - Why and whattasks.md - Implementation stepsdesign.md - Technical decisionsspec.md - Requirements and behavioropenspec list # What's in progress?
openspec show [item] # View details
openspec validate --strict # Is it correct?
openspec archive <change-id> [--yes|-y] # Mark complete (add --yes for automation)
Remember: Specs are truth. Changes are proposals. Keep them in sync.