spec-ctx 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,301 +0,0 @@
1
- name: spec-driven-ids
2
- version: 1
3
- description: OpenSpec spec-driven workflow with stable IDs from spec-ctx - proposal → specs → design → tasks
4
- artifacts:
5
- - id: proposal
6
- generates: proposal.md
7
- description: Initial proposal document outlining the change
8
- template: proposal.md
9
- instruction: |
10
- Create the proposal document that establishes WHY this change is needed.
11
-
12
- Sections:
13
- - **Why**: 1-2 sentences on the problem or opportunity. What problem does this solve? Why now?
14
- - **What Changes**: Bullet list of changes. Be specific about new capabilities, modifications, or removals. Mark breaking changes with **BREAKING**.
15
- - **Capabilities**: Identify which specs will be created or modified:
16
- - **New Capabilities**: List capabilities being introduced. Each becomes a new `specs/<capability-path>/spec.md`. Name each capability for a durable system behavior (for example, `user-auth`), not the work in this change (for example, `add-login-endpoint`). Choose a cohesive boundary that can own related requirements as the system evolves; avoid broad catch-all capabilities. Use kebab-case for path segments you introduce (e.g., `user-auth` or `identity/user-auth`) and follow the project's existing spec organization.
17
- - **Modified Capabilities**: List existing capabilities whose REQUIREMENTS are changing. Only include if spec-level behavior changes (not just implementation details). Each needs a delta spec file. Use the exact existing path under `openspec/specs/`. Leave empty if no requirement changes.
18
- - **Impact**: Affected code, APIs, dependencies, or systems.
19
-
20
- IMPORTANT: The Capabilities section is critical. It creates the contract between
21
- proposal and specs phases. Research existing specs before filling this in:
22
- run `openspec list --specs` for the project's capability inventory, then
23
- `openspec show "<spec-id>" --type spec --json --no-scenarios` for any that
24
- look related - that returns a capability's purpose and requirement texts
25
- without pulling whole spec files into context. Append `--store "<id>"` to
26
- both commands only for a registered standalone store, and keep `--type
27
- spec`: a change and a spec sharing a name is otherwise an ambiguous-item
28
- error. `openspec list` without `--specs` lists in-flight changes, not
29
- specs - it never shows what the project already covers. Reuse an existing
30
- capability's exact path instead of introducing a near-duplicate name.
31
- The filtered read is only an overview. Before deciding what is already
32
- covered or what should change, read each relevant spec in full, including
33
- scenarios, with `openspec show "<spec-id>" --type spec` (same `--store` rule).
34
- Each capability listed here will need a corresponding spec file.
35
-
36
- Every change must either declare at least one capability (new or
37
- modified) or explicitly opt out of specs: `openspec validate` rejects a
38
- change with zero deltas unless the change's `.openspec.yaml` sets
39
- `skip_specs: true`. Use `skip_specs: true` only when no spec-level
40
- behavior changes (pure refactor, tooling, docs) - specs describe
41
- behavior, so if behavior does not change, no spec should change either.
42
- Do not invent a requirement just to satisfy validation.
43
-
44
- Keep it concise (1-2 pages). Focus on the "why" not the "how" -
45
- implementation details belong in design.md.
46
-
47
- This is the foundation - specs, design, and tasks all build on this.
48
- requires: []
49
-
50
- - id: specs
51
- generates: "specs/**/*.md"
52
- description: Detailed specifications for the change
53
- template: spec.md
54
- instruction: |
55
- Create specification files that define WHAT the system should do.
56
-
57
- A spec is a behavior contract, not an implementation plan.
58
-
59
- Good spec content:
60
- - Observable behavior users or downstream systems rely on
61
- - Inputs, outputs, and error conditions
62
- - External constraints (security, privacy, reliability, compatibility)
63
- - Scenarios that can be tested or explicitly validated
64
-
65
- Avoid in specs:
66
- - Internal class/function names
67
- - Library or framework choices
68
- - Step-by-step implementation details
69
- - Detailed execution plans (those belong in design.md or tasks.md)
70
-
71
- Quick test: if the implementation can change without changing externally
72
- visible behavior, it likely does not belong in the spec.
73
-
74
- Create one spec file per capability listed in the proposal's Capabilities section.
75
- `<capability-path>` is the spec directory relative to `specs/` (for example,
76
- `user-auth` or `identity/user-auth`). Preserve the full path:
77
- - New capabilities: use the exact path from the proposal at `specs/<capability-path>/spec.md`. Any path segment newly introduced in the proposal must be kebab-case. Follow the project's existing organization; do not add a new domain level when the project uses a flat layout.
78
- - Modified capabilities: use the exact existing path from `openspec/specs/<capability-path>/` when creating the delta at `specs/<capability-path>/spec.md`. Run `openspec list --specs` to confirm that path before writing the delta, appending `--store "<id>"` only for a registered standalone store - a mistyped or invented path targets a capability that does not exist rather than the one you meant. Do not move or rename the capability.
79
-
80
- Write the spec files one at a time, so the user sees progress and an
81
- interrupted run keeps the files it already wrote:
82
- - Before writing anything, compare the capabilities the proposal lists
83
- with the `specs/<capability-path>/spec.md` files that already exist,
84
- and start with the first capability that has no file. Do not rewrite
85
- an existing file unless the user asks you to.
86
- - Before each file, say in one line which capability you are writing.
87
- - Write each file as soon as you have drafted it. Do not plan every file
88
- before writing the first.
89
- - Stop when every capability the proposal lists has its file.
90
-
91
- There must be at least one spec file unless the change's `.openspec.yaml`
92
- sets `skip_specs: true` (no spec-level behavior change) - `openspec validate`
93
- rejects a zero-delta change without that marker. If the proposal lists no
94
- capabilities and `skip_specs` is not set, revisit the proposal first.
95
-
96
- Delta operations (use ## headers):
97
- - **ADDED Requirements**: New capabilities
98
- - **MODIFIED Requirements**: Changed behavior - MUST include full updated content
99
- - **REMOVED Requirements**: Deprecated features - MUST include **Reason** and **Migration**
100
- - **RENAMED Requirements**: Name changes only - use FROM:/TO: format
101
-
102
- Format requirements:
103
- - Each requirement: `### Requirement: <name>` followed by description
104
- - Use SHALL/MUST for normative requirements (avoid should/may)
105
- - Each scenario: `#### Scenario: <name>` with WHEN/THEN format
106
- - **CRITICAL**: Scenarios MUST use exactly 4 hashtags (`####`). Using 3 hashtags or bullets will fail silently.
107
- - Every requirement MUST have at least one scenario.
108
- - Keep each requirement's description (the text between `### Requirement:` and its first scenario) to 500 characters or fewer. `openspec validate` flags longer descriptions in ADDED requirements and in the main spec. This is a warning: normal validation still passes, but `openspec validate --strict` fails on it. When writing a new requirement, state one behavior per requirement: move examples and edge cases into scenarios, and split a requirement that covers several behaviors into separate `### Requirement:` blocks, each with its own scenarios. Under MODIFIED, keep the existing requirement block whole; never split, trim or rewrite existing text just to meet the length. Split an existing long requirement only when the user asks for it, in a change made for that purpose: under MODIFIED, keep its header and every scenario and cut its description down to one behavior without changing its meaning, then add each behavior you removed as its own ADDED requirement with its own scenarios.
109
-
110
- New capabilities only: the delta spec's first section is `## Purpose` -
111
- one or two sentences (50+ characters, or `openspec validate --strict`
112
- reports it as too brief) describing what the capability is for. Archive
113
- copies it into the main spec it creates; without it the new main spec is
114
- left with a `TBD ... Update Purpose after archive` placeholder to fill in
115
- by hand. Do NOT add `## Purpose` to a delta for an existing capability -
116
- that spec already has one and the delta's is ignored. To change an
117
- existing capability's Purpose - including a leftover `TBD` placeholder -
118
- edit `<planningHome.root>/openspec/specs/<capability-path>/spec.md`
119
- directly. `planningHome.root` comes from the `openspec instructions ...
120
- --json` response. Always use it rather than a repo-relative path: it
121
- resolves to the store whenever the change lives in one - whether that
122
- came from `--store`, a project `store:` pointer, or a global default
123
- store - and to the current repository otherwise. Do not try to work out
124
- which case applies; the field already has.
125
-
126
- MODIFIED requirements workflow:
127
- 1. Locate the existing requirement in `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (the same store-aware root as above)
128
- 2. Copy the ENTIRE requirement block (from `### Requirement:` through all scenarios)
129
- 3. Paste under `## MODIFIED Requirements` and edit to reflect new behavior
130
- 4. Ensure header text matches exactly (whitespace-insensitive)
131
-
132
- Common pitfall: Using MODIFIED with partial content loses detail at archive time.
133
- If adding new concerns without changing existing behavior, use ADDED instead.
134
-
135
- Example (a new capability, so its first section is `## Purpose`):
136
- ```
137
- # Spec Delta
138
-
139
- ## Purpose
140
-
141
- Lets users take their data out of the product in a portable format.
142
-
143
- ## ADDED Requirements
144
-
145
- ### Requirement: User can export data
146
- The system SHALL allow users to export their data in CSV format.
147
-
148
- #### Scenario: Successful export
149
- - **WHEN** user clicks "Export" button
150
- - **THEN** system downloads a CSV file with all user data
151
-
152
- ## REMOVED Requirements
153
-
154
- ### Requirement: Legacy export
155
- **Reason**: Replaced by new export system
156
- **Migration**: Use new export endpoint at /api/v2/export
157
- ```
158
-
159
-
160
- Stable IDs (spec-ctx):
161
- - Every requirement header starts with an ID: `### Requirement: REQ-<CAP>-NNN <name>`.
162
- Get a new ID from `specctx id new REQ <CAP>`. Never count numbers by hand.
163
- `<CAP>` is a capability code from `[ids] caps` in `spec-ctx.toml`.
164
- - Every scenario header starts with an ID: `#### Scenario: SCN-<CAP>-NNN-<n> <name>`.
165
- Get it from `specctx id new SCN <CAP> --for REQ-<CAP>-NNN`.
166
- - Under MODIFIED, REMOVED, or RENAMED, keep the existing ID. An ID never changes.
167
- - Link related IDs with one line `Refs: ID, ID` after the requirement text.
168
- - Replace every placeholder of the template. `specctx check` reports a header with
169
- no ID as `missing-id`.
170
-
171
- Specs should be testable - each scenario is a potential test case.
172
- requires:
173
- - proposal
174
-
175
- - id: design
176
- generates: design.md
177
- description: Technical design document with implementation details
178
- template: design.md
179
- instruction: |
180
- Create the design document that explains HOW to implement the change.
181
-
182
- When to include design.md (create only if any apply):
183
- - Cross-cutting change (multiple services/modules) or new architectural pattern
184
- - New external dependency or significant data model changes
185
- - Security, performance, or migration complexity
186
- - Ambiguity that benefits from technical decisions before coding
187
-
188
- Sections:
189
- - **Context**: Only the current state and constraints needed to explain the approach. Reference the proposal for motivation instead of restating it (e.g., "See proposal.md - Why").
190
- - **Goals / Non-Goals**: What this design achieves and explicitly excludes. Don't restate the proposal's scope - add only design-level boundaries.
191
- - **Decisions**: Key technical choices with rationale (why X over Y?). Include alternatives considered for each decision.
192
- - **Risks / Trade-offs**: Known limitations, things that could go wrong. Format: [Risk] → Mitigation
193
- - **Migration Plan**: Steps to deploy, rollback strategy (if applicable)
194
- - **Open Questions**: Unknowns that can safely be answered later without
195
- changing the specs, the approach, or the task breakdown. Omit if none.
196
-
197
- Open questions are for genuinely deferrable unknowns, not decisions you
198
- skipped. If a question would change the specs, the chosen approach, or
199
- the task breakdown, resolve it now - ask the user instead of guessing.
200
-
201
- Focus on architecture and approach, not line-by-line implementation.
202
- The proposal covers why and what; design covers how. Reference the
203
- proposal for motivation and, once written, the specs for requirements -
204
- if a section would only restate them, point to them instead.
205
-
206
-
207
- Stable IDs (spec-ctx):
208
- - Each bullet under `## Decisions` is one decision. Its ID is `<change number>/D<n>`
209
- by position, so add new decisions at the end and never reorder them.
210
- - End a decision with `Refs: ` and the REQ or ADR IDs it serves. Then `specctx bundle`
211
- prints the decision with those requirements.
212
-
213
- Good design docs explain the "why" behind technical decisions.
214
- requires:
215
- - proposal
216
-
217
- - id: tasks
218
- generates: tasks.md
219
- description: Implementation checklist with trackable tasks
220
- template: tasks.md
221
- instruction: |
222
- Create the task list that breaks down the implementation work.
223
-
224
- Before writing tasks, check design.md for Open Questions. If any of them
225
- would change what gets built, resolve them with the user first - do not
226
- bake an unstated assumption into the task list.
227
-
228
- **IMPORTANT: Follow the template below for tracked tasks.** The apply phase parses
229
- checkbox format to track progress. A box holding only `x` counts as done,
230
- upper or lower case and with any spacing, so `- [ x]` is done too. Every
231
- other marker, including `- [~]`, `- [-]` and an empty `- []`, reads as
232
- unfinished. A line with no checkbox is not tracked at all.
233
-
234
- Guidelines:
235
- - Group related tracked tasks under ## numbered headings
236
- - Each tracked task MUST be a checkbox: `- [ ] X.Y Task description`
237
- - Tasks should be small enough to complete in one session
238
- - Order tasks by dependency (what must be done first?)
239
- - Track implementation and verification work that can be completed before
240
- archive. If the requested workflow includes archive or work that requires
241
- this change to be archived, preserve those steps as plain bullets in an
242
- optional `## Workflow follow-up` section at the end of tasks.md. These
243
- bullets are reference information outside tracked task progress.
244
- - Each task MUST state how to verify completion (a test, command,
245
- observable behavior, or delivered artifact). Put the verification in
246
- that task's checkbox description. Use a separate verification task only
247
- when it checks broader integration or system behavior that spans
248
- multiple implementation tasks.
249
- - Each task group MUST land the tests and documentation its own work
250
- calls for. Do NOT collect testing or documentation into a final group -
251
- when a late group first exercises work from an early one, the failures
252
- cascade back through every group in between and force rework. A group
253
- whose work calls for neither, such as scaffolding or dependency setup,
254
- carries neither. A final group is for integration checks only, not for
255
- the tests and docs an earlier group owed.
256
-
257
- Example:
258
- ```
259
- # Tasks
260
-
261
- ## 1. Setup
262
-
263
- - [ ] 1.1 Create new module structure and verify expected files are present
264
- - [ ] 1.2 Add dependencies to package.json and verify package installation succeeds
265
-
266
- ## 2. Core Implementation
267
-
268
- - [ ] 2.1 Implement data export function and verify the export test passes
269
- - [ ] 2.2 Add CSV formatting utilities and verify unit tests cover quoting and delimiters
270
- - [ ] 2.3 Document the export API in docs/export.md and verify the documented command runs as written
271
- ```
272
-
273
- When applicable, append workflow follow-up as plain bullets, for example:
274
- ```
275
- ## Workflow follow-up
276
-
277
- - Archive the change after the project's review requirements are satisfied.
278
- - Verify the archived result.
279
- ```
280
-
281
-
282
- Stable IDs and Verify (spec-ctx):
283
- - Every task cites at least one requirement in square brackets: `[REQ-<CAP>-NNN]`.
284
- - Every task ends with `Verify:` and the command in a code span, for example
285
- ``Verify: `npm test -- tests/export.test.ts` ``. Two spans run joined with `&&`.
286
- - Use prose after `Verify:` only when no command can check the work. Then
287
- `specctx task done <id> --manual "<note>"` records it.
288
- - Close a task only with `specctx task done <id>`. It runs the command, writes
289
- evidence under `.ctx/evidence/`, and sets the checkbox.
290
-
291
- Reference specs for what needs to be built, design for how to build it.
292
- requires:
293
- - specs
294
- - design
295
-
296
- apply:
297
- requires: [ tasks ]
298
- tracks: tasks.md
299
- instruction: |
300
- Read context files, work through pending tasks, mark complete as you go.
301
- Pause if you hit blockers or need clarification.