|
1 | 1 | # OpenSpec |
2 | 2 |
|
3 | | -A specification-driven development system for maintaining living documentation alongside your code. |
| 3 | +AI-native system for spec-driven development. Keep living specifications alongside code, propose changes as deltas, and archive once reality matches the spec. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +- Specs are the current truth stored in `openspec/specs/<capability>/spec.md`. |
| 8 | +- Changes are proposals stored in `openspec/changes/<name>/` with delta-formatted spec updates. |
| 9 | +- The CLI favors verb-first commands: `list`, `show`, `validate`, `diff`, `archive`. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +- Node.js >= 20.19.0 |
| 14 | +- pnpm (project standard) |
4 | 15 |
|
5 | 16 | ## Installation |
6 | 17 |
|
7 | | -```bash |
8 | | -npm install -g openspec |
9 | | -``` |
| 18 | +- Global: `pnpm add -g @fission-ai/openspec` |
| 19 | +- Local (per project): |
| 20 | + - `pnpm add -D @fission-ai/openspec` |
| 21 | + - Run with `pnpm exec openspec ...` |
10 | 22 |
|
11 | 23 | ## Quick Start |
12 | 24 |
|
13 | 25 | ```bash |
14 | 26 | # Initialize OpenSpec in your project |
15 | 27 | openspec init |
16 | 28 |
|
17 | | -# Update existing OpenSpec instructions (team-friendly) |
| 29 | +# Update OpenSpec instructions (team-friendly) |
18 | 30 | openspec update |
19 | 31 |
|
20 | | -# List specs or changes |
21 | | -openspec spec list # specs (IDs by default; use --long for details) |
22 | | -openspec change list # changes (IDs by default; use --long for details) |
| 32 | +# List items (IDs only). Use --specs to list specs |
| 33 | +openspec list # defaults to changes |
| 34 | +openspec list --specs |
| 35 | + |
| 36 | +# Show an item (raw text by default) |
| 37 | +openspec show <item> |
| 38 | +openspec show <item> --json # automation-friendly output |
23 | 39 |
|
24 | | -# Show differences between specs and proposed changes |
25 | | -openspec diff [change-name] |
| 40 | +# Validate |
| 41 | +openspec validate --changes --strict |
| 42 | +openspec validate --specs --json |
26 | 43 |
|
27 | | -# Archive completed changes |
28 | | -openspec archive [change-name] |
| 44 | +# See diffs between a change and current specs |
| 45 | +openspec diff <change-id> |
| 46 | + |
| 47 | +# Archive a completed change |
| 48 | +openspec archive <change-id> [--skip-specs] |
29 | 49 | ``` |
30 | 50 |
|
31 | | -## Commands |
| 51 | +## Minimal Example |
32 | 52 |
|
33 | | -### `openspec init` |
| 53 | +Directory structure: |
34 | 54 |
|
35 | | -Initializes OpenSpec in your project by creating: |
36 | | -- `openspec/` directory structure |
37 | | -- `openspec/README.md` with OpenSpec instructions |
38 | | -- AI tool configuration files (based on your selection) |
| 55 | +``` |
| 56 | +openspec/ |
| 57 | +├── specs/ |
| 58 | +│ └── auth/ |
| 59 | +│ └── spec.md |
| 60 | +└── changes/ |
| 61 | + └── add-2fa/ |
| 62 | + ├── proposal.md |
| 63 | + └── specs/ |
| 64 | + └── auth/ |
| 65 | + └── spec.md # delta format |
| 66 | +``` |
39 | 67 |
|
40 | | -### `openspec update` |
| 68 | +Spec format (`openspec/specs/auth/spec.md`): |
41 | 69 |
|
42 | | -Updates OpenSpec instructions to the latest version. This command is **team-friendly** and only updates files that already exist: |
| 70 | +```markdown |
| 71 | +# Auth Specification |
43 | 72 |
|
44 | | -- Always updates `openspec/README.md` with the latest OpenSpec instructions |
45 | | -- **Only updates existing AI tool configuration files** (e.g., CLAUDE.md, CURSOR.md) |
46 | | -- **Never creates new AI tool configuration files** |
47 | | -- Preserves content outside of OpenSpec markers in AI tool files |
| 73 | +## Purpose |
| 74 | +Authentication and session management. |
48 | 75 |
|
49 | | -This allows team members to use different AI tools without conflicts. Each developer can maintain their preferred AI tool configuration file, and `openspec update` will respect their choice. |
| 76 | +## Requirements |
| 77 | +### Requirement: User Authentication |
| 78 | +The system SHALL issue a JWT on successful login. |
50 | 79 |
|
51 | | -### `openspec spec` |
| 80 | +#### Scenario: Valid credentials |
| 81 | +- WHEN a user submits valid credentials |
| 82 | +- THEN a JWT is returned |
| 83 | +``` |
52 | 84 |
|
53 | | -Manage and view specifications. |
| 85 | +Change delta format (`openspec/changes/add-2fa/specs/auth/spec.md`): |
54 | 86 |
|
55 | | -Examples: |
56 | | -- `openspec spec show <spec-id>` |
57 | | - - Text mode: prints raw `spec.md` content |
58 | | - - JSON mode (`--json`): returns minimal, stable shape |
59 | | - - Filters are JSON-only: `--requirements`, `--no-scenarios`, `-r/--requirement <1-based>` |
60 | | -- `openspec spec list` |
61 | | - - Prints IDs only by default |
62 | | - - Use `--long` to include `title` and `[requirements N]` |
63 | | -- `openspec spec validate <spec-id>` |
64 | | - - Text: human-readable summary to stdout/stderr |
65 | | - - `--json` for structured report |
| 87 | +```markdown |
| 88 | +# Delta for Auth |
66 | 89 |
|
67 | | -### `openspec change` |
| 90 | +## ADDED Requirements |
| 91 | +### Requirement: Two-Factor Authentication |
| 92 | +The system MUST require a second factor during login. |
68 | 93 |
|
69 | | -Manage and view change proposals. |
| 94 | +#### Scenario: OTP required |
| 95 | +- WHEN a user submits valid credentials |
| 96 | +- THEN an OTP challenge is required |
| 97 | +``` |
70 | 98 |
|
71 | | -Examples: |
72 | | -- `openspec change show <change-id>` |
73 | | - - Text mode: prints raw `proposal.md` content |
74 | | - - JSON mode (`--json`): `{ id, title, deltaCount, deltas }` |
75 | | - - Filtering is JSON-only: `--deltas-only` (alias: `--requirements-only`, deprecated) |
76 | | -- `openspec change list` |
77 | | - - Prints IDs only by default |
78 | | - - Use `--long` to include `title` and counts `[deltas N] [tasks x/y]` |
79 | | -- `openspec change validate <change-id>` |
80 | | - - Text: human-readable result |
81 | | - - `--json` for structured report |
| 99 | +Critical formatting rules: |
| 100 | +- Use `### Requirement: <name>` for requirement headers. |
| 101 | +- Every requirement MUST include at least one `#### Scenario:` block. |
| 102 | +- Use SHALL/MUST in ADDED/MODIFIED requirement text. |
82 | 103 |
|
83 | | -### `openspec diff [change-name]` |
| 104 | +## Core Commands |
84 | 105 |
|
85 | | -Shows the differences between current specs and proposed changes: |
86 | | -- Displays a unified diff format |
87 | | -- Helps review what will change before implementation |
88 | | -- Useful for pull request reviews |
| 106 | +- init: Initialize OpenSpec in the project. |
| 107 | +- update: Update OpenSpec instructions (team-friendly; only updates existing files, always refreshes `openspec/README.md`). |
| 108 | +- list: List changes (default) or specs with `--specs`. |
| 109 | +- show: Show a change or spec (raw text). Use `--json` for structured output; pass `--type change|spec` if ambiguous. |
| 110 | +- validate: Validate changes/specs. Supports `--changes`, `--specs`, `--all`, `--strict`, `--json`. |
| 111 | +- diff: Show unified diff between a change’s deltas and current specs. |
| 112 | +- archive: Apply deltas to specs and move the change to `openspec/changes/archive/`. Supports `--skip-specs`. |
89 | 113 |
|
90 | | -### `openspec archive [change-name]` |
| 114 | +## JSON for Automation |
91 | 115 |
|
92 | | -Archives a completed change: |
93 | | -- Moves change from `openspec/changes/` to `openspec/changes/archive/` |
94 | | -- Adds a date prefix to the archived change |
95 | | -- Updates specs to reflect the new state |
96 | | -- Use `--skip-specs` to archive without updating specs (for abandoned changes) |
| 116 | +Specs: |
97 | 117 |
|
98 | | -## Team Collaboration |
| 118 | +```bash |
| 119 | +openspec show auth --json --no-scenarios |
| 120 | +``` |
99 | 121 |
|
100 | | -OpenSpec is designed for team collaboration: |
| 122 | +Outputs shape: |
| 123 | + |
| 124 | +```json |
| 125 | +{ |
| 126 | + "id": "auth", |
| 127 | + "title": "Auth Specification", |
| 128 | + "overview": "...", |
| 129 | + "requirementCount": 1, |
| 130 | + "requirements": [{ "text": "...", "scenarios": [] }], |
| 131 | + "metadata": { "version": "1.0.0", "format": "openspec" } |
| 132 | +} |
| 133 | +``` |
101 | 134 |
|
102 | | -1. **AI Tool Flexibility**: Each team member can use their preferred AI assistant (Claude, Cursor, etc.) |
103 | | -2. **Non-Invasive Updates**: The `update` command only modifies existing files, never forcing tools on team members |
104 | | -3. **Specification Sharing**: The `openspec/` directory contains shared specifications that all team members work from |
105 | | -4. **Change Tracking**: Proposed changes are visible to all team members for review before implementation |
| 135 | +Changes: |
106 | 136 |
|
107 | | -## Contributing |
| 137 | +```bash |
| 138 | +openspec show add-2fa --json --deltas-only |
| 139 | +``` |
| 140 | + |
| 141 | +Outputs shape: |
| 142 | + |
| 143 | +```json |
| 144 | +{ |
| 145 | + "id": "add-2fa", |
| 146 | + "title": "Add 2FA", |
| 147 | + "deltaCount": 1, |
| 148 | + "deltas": [{ "spec": "auth", "operation": "ADDED", "name": "Two-Factor Authentication", "raw": "..." }] |
| 149 | +} |
| 150 | +``` |
108 | 151 |
|
109 | | -See `openspec/specs/` for the current system specifications and `openspec/changes/` for pending improvements. |
| 152 | +## Team Workflow |
110 | 153 |
|
111 | | -## Notes |
| 154 | +- `openspec update` is team-friendly: it updates `openspec/README.md` and only modifies AI config files that already exist (e.g., CLAUDE.md), never forcing tools on teammates. |
| 155 | +- Multiple AI tools can co-exist without conflicts. |
| 156 | + |
| 157 | +## Deprecation Note |
| 158 | + |
| 159 | +Noun-first commands (`openspec spec ...`, `openspec change ...`) are available but deprecated. Prefer verb-first commands: `openspec list`, `openspec show`, `openspec validate`. |
| 160 | + |
| 161 | +## Troubleshooting |
| 162 | + |
| 163 | +- "Change must have at least one delta" → Ensure `## ADDED|MODIFIED|REMOVED|RENAMED Requirements` sections exist in `openspec/changes/<name>/specs/.../spec.md`. |
| 164 | +- "Requirement must have at least one scenario" → Add at least one `#### Scenario:` block under each requirement. |
| 165 | +- Missing SHALL/MUST in ADDED/MODIFIED → Add SHALL/MUST to requirement text. |
| 166 | +- Debug: |
| 167 | + - `openspec validate <change-id> --strict --json` |
| 168 | + - `openspec change show <change-id> --json --deltas-only` |
| 169 | + - `openspec spec show <spec-id> --json -r 1` |
| 170 | +- Output control: `--no-color` disables ANSI (respects `NO_COLOR`). |
| 171 | + |
| 172 | +## Contributing |
112 | 173 |
|
113 | | -- The legacy `openspec list` command is deprecated. Use `openspec spec list` and `openspec change list`. |
114 | | -- Text output is raw-first (no formatting or filtering). Prefer `--json` for tooling-friendly output. |
115 | | -- Global `--no-color` disables ANSI colors and respects `NO_COLOR`. |
| 174 | +- Use pnpm: `pnpm install`, `pnpm run build`, `pnpm test`. |
| 175 | +- Develop CLI locally: `pnpm dev` or `pnpm dev:cli`. |
| 176 | +- Conventional commits (one-line): `type(scope): subject`. |
116 | 177 |
|
117 | 178 | ## License |
118 | 179 |
|
119 | | -MIT |
| 180 | +MIT |
0 commit comments