@fission-ai/openspec 1.1.0 → 1.2.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.
Files changed (73) hide show
  1. package/dist/cli/index.js +2 -0
  2. package/dist/commands/config.d.ts +28 -0
  3. package/dist/commands/config.js +359 -5
  4. package/dist/core/available-tools.d.ts +16 -0
  5. package/dist/core/available-tools.js +30 -0
  6. package/dist/core/command-generation/adapters/index.d.ts +2 -0
  7. package/dist/core/command-generation/adapters/index.js +2 -0
  8. package/dist/core/command-generation/adapters/kiro.d.ts +13 -0
  9. package/dist/core/command-generation/adapters/kiro.js +26 -0
  10. package/dist/core/command-generation/adapters/opencode.js +4 -1
  11. package/dist/core/command-generation/adapters/pi.d.ts +14 -0
  12. package/dist/core/command-generation/adapters/pi.js +41 -0
  13. package/dist/core/command-generation/registry.js +4 -0
  14. package/dist/core/completions/command-registry.js +5 -0
  15. package/dist/core/config-schema.d.ts +10 -0
  16. package/dist/core/config-schema.js +14 -1
  17. package/dist/core/config.js +2 -0
  18. package/dist/core/global-config.d.ts +5 -0
  19. package/dist/core/global-config.js +12 -2
  20. package/dist/core/init.d.ts +5 -0
  21. package/dist/core/init.js +206 -42
  22. package/dist/core/legacy-cleanup.js +1 -0
  23. package/dist/core/migration.d.ts +23 -0
  24. package/dist/core/migration.js +108 -0
  25. package/dist/core/profile-sync-drift.d.ts +38 -0
  26. package/dist/core/profile-sync-drift.js +200 -0
  27. package/dist/core/profiles.d.ts +26 -0
  28. package/dist/core/profiles.js +40 -0
  29. package/dist/core/shared/index.d.ts +1 -1
  30. package/dist/core/shared/index.js +1 -1
  31. package/dist/core/shared/skill-generation.d.ts +16 -8
  32. package/dist/core/shared/skill-generation.js +42 -22
  33. package/dist/core/shared/tool-detection.d.ts +8 -3
  34. package/dist/core/shared/tool-detection.js +18 -0
  35. package/dist/core/templates/index.d.ts +1 -1
  36. package/dist/core/templates/index.js +2 -2
  37. package/dist/core/templates/skill-templates.d.ts +15 -118
  38. package/dist/core/templates/skill-templates.js +14 -3424
  39. package/dist/core/templates/types.d.ts +19 -0
  40. package/dist/core/templates/types.js +5 -0
  41. package/dist/core/templates/workflows/apply-change.d.ts +10 -0
  42. package/dist/core/templates/workflows/apply-change.js +308 -0
  43. package/dist/core/templates/workflows/archive-change.d.ts +10 -0
  44. package/dist/core/templates/workflows/archive-change.js +271 -0
  45. package/dist/core/templates/workflows/bulk-archive-change.d.ts +10 -0
  46. package/dist/core/templates/workflows/bulk-archive-change.js +488 -0
  47. package/dist/core/templates/workflows/continue-change.d.ts +10 -0
  48. package/dist/core/templates/workflows/continue-change.js +232 -0
  49. package/dist/core/templates/workflows/explore.d.ts +10 -0
  50. package/dist/core/templates/workflows/explore.js +461 -0
  51. package/dist/core/templates/workflows/feedback.d.ts +9 -0
  52. package/dist/core/templates/workflows/feedback.js +108 -0
  53. package/dist/core/templates/workflows/ff-change.d.ts +10 -0
  54. package/dist/core/templates/workflows/ff-change.js +198 -0
  55. package/dist/core/templates/workflows/new-change.d.ts +10 -0
  56. package/dist/core/templates/workflows/new-change.js +143 -0
  57. package/dist/core/templates/workflows/onboard.d.ts +10 -0
  58. package/dist/core/templates/workflows/onboard.js +565 -0
  59. package/dist/core/templates/workflows/propose.d.ts +10 -0
  60. package/dist/core/templates/workflows/propose.js +216 -0
  61. package/dist/core/templates/workflows/sync-specs.d.ts +10 -0
  62. package/dist/core/templates/workflows/sync-specs.js +272 -0
  63. package/dist/core/templates/workflows/verify-change.d.ts +10 -0
  64. package/dist/core/templates/workflows/verify-change.js +332 -0
  65. package/dist/core/update.d.ts +36 -1
  66. package/dist/core/update.js +292 -61
  67. package/dist/prompts/searchable-multi-select.d.ts +3 -2
  68. package/dist/prompts/searchable-multi-select.js +22 -12
  69. package/dist/utils/command-references.d.ts +18 -0
  70. package/dist/utils/command-references.js +20 -0
  71. package/dist/utils/index.d.ts +1 -0
  72. package/dist/utils/index.js +2 -0
  73. package/package.json +1 -1
@@ -1,3428 +1,18 @@
1
1
  /**
2
2
  * Agent Skill Templates
3
3
  *
4
- * Templates for generating Agent Skills compatible with:
5
- * - Claude Code
6
- * - Cursor (Settings Rules → Import Settings)
7
- * - Windsurf
8
- * - Other Agent Skills-compatible editors
9
- */
10
- /**
11
- * Template for openspec-explore skill
12
- * Explore mode - adaptive thinking partner for exploring ideas and problems
13
- */
14
- export function getExploreSkillTemplate() {
15
- return {
16
- name: 'openspec-explore',
17
- description: 'Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.',
18
- instructions: `Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
19
-
20
- **IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first (e.g., start a change with \`/opsx:new\` or \`/opsx:ff\`). You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing.
21
-
22
- **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore.
23
-
24
- ---
25
-
26
- ## The Stance
27
-
28
- - **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
29
- - **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
30
- - **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
31
- - **Adaptive** - Follow interesting threads, pivot when new information emerges
32
- - **Patient** - Don't rush to conclusions, let the shape of the problem emerge
33
- - **Grounded** - Explore the actual codebase when relevant, don't just theorize
34
-
35
- ---
36
-
37
- ## What You Might Do
38
-
39
- Depending on what the user brings, you might:
40
-
41
- **Explore the problem space**
42
- - Ask clarifying questions that emerge from what they said
43
- - Challenge assumptions
44
- - Reframe the problem
45
- - Find analogies
46
-
47
- **Investigate the codebase**
48
- - Map existing architecture relevant to the discussion
49
- - Find integration points
50
- - Identify patterns already in use
51
- - Surface hidden complexity
52
-
53
- **Compare options**
54
- - Brainstorm multiple approaches
55
- - Build comparison tables
56
- - Sketch tradeoffs
57
- - Recommend a path (if asked)
58
-
59
- **Visualize**
60
- \`\`\`
61
- ┌─────────────────────────────────────────┐
62
- │ Use ASCII diagrams liberally │
63
- ├─────────────────────────────────────────┤
64
- │ │
65
- │ ┌────────┐ ┌────────┐ │
66
- │ │ State │────────▶│ State │ │
67
- │ │ A │ │ B │ │
68
- │ └────────┘ └────────┘ │
69
- │ │
70
- │ System diagrams, state machines, │
71
- │ data flows, architecture sketches, │
72
- │ dependency graphs, comparison tables │
73
- │ │
74
- └─────────────────────────────────────────┘
75
- \`\`\`
76
-
77
- **Surface risks and unknowns**
78
- - Identify what could go wrong
79
- - Find gaps in understanding
80
- - Suggest spikes or investigations
81
-
82
- ---
83
-
84
- ## OpenSpec Awareness
85
-
86
- You have full context of the OpenSpec system. Use it naturally, don't force it.
87
-
88
- ### Check for context
89
-
90
- At the start, quickly check what exists:
91
- \`\`\`bash
92
- openspec list --json
93
- \`\`\`
94
-
95
- This tells you:
96
- - If there are active changes
97
- - Their names, schemas, and status
98
- - What the user might be working on
99
-
100
- ### When no change exists
101
-
102
- Think freely. When insights crystallize, you might offer:
103
-
104
- - "This feels solid enough to start a change. Want me to create one?"
105
- → Can transition to \`/opsx:new\` or \`/opsx:ff\`
106
- - Or keep exploring - no pressure to formalize
107
-
108
- ### When a change exists
109
-
110
- If the user mentions a change or you detect one is relevant:
111
-
112
- 1. **Read existing artifacts for context**
113
- - \`openspec/changes/<name>/proposal.md\`
114
- - \`openspec/changes/<name>/design.md\`
115
- - \`openspec/changes/<name>/tasks.md\`
116
- - etc.
117
-
118
- 2. **Reference them naturally in conversation**
119
- - "Your design mentions using Redis, but we just realized SQLite fits better..."
120
- - "The proposal scopes this to premium users, but we're now thinking everyone..."
121
-
122
- 3. **Offer to capture when decisions are made**
123
-
124
- | Insight Type | Where to Capture |
125
- |--------------|------------------|
126
- | New requirement discovered | \`specs/<capability>/spec.md\` |
127
- | Requirement changed | \`specs/<capability>/spec.md\` |
128
- | Design decision made | \`design.md\` |
129
- | Scope changed | \`proposal.md\` |
130
- | New work identified | \`tasks.md\` |
131
- | Assumption invalidated | Relevant artifact |
132
-
133
- Example offers:
134
- - "That's a design decision. Capture it in design.md?"
135
- - "This is a new requirement. Add it to specs?"
136
- - "This changes scope. Update the proposal?"
137
-
138
- 4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
139
-
140
- ---
141
-
142
- ## What You Don't Have To Do
143
-
144
- - Follow a script
145
- - Ask the same questions every time
146
- - Produce a specific artifact
147
- - Reach a conclusion
148
- - Stay on topic if a tangent is valuable
149
- - Be brief (this is thinking time)
150
-
151
- ---
152
-
153
- ## Handling Different Entry Points
154
-
155
- **User brings a vague idea:**
156
- \`\`\`
157
- User: I'm thinking about adding real-time collaboration
158
-
159
- You: Real-time collab is a big space. Let me think about this...
160
-
161
- COLLABORATION SPECTRUM
162
- ════════════════════════════════════════════
163
-
164
- Awareness Coordination Sync
165
- │ │ │
166
- ▼ ▼ ▼
167
- ┌────────┐ ┌────────┐ ┌────────┐
168
- │Presence│ │Cursors │ │ CRDT │
169
- │ "3 │ │ Multi │ │Conflict│
170
- │online" │ │ select │ │ free │
171
- └────────┘ └────────┘ └────────┘
172
- │ │ │
173
- trivial moderate complex
174
-
175
- Where's your head at?
176
- \`\`\`
177
-
178
- **User brings a specific problem:**
179
- \`\`\`
180
- User: The auth system is a mess
181
-
182
- You: [reads codebase]
183
-
184
- ┌─────────────────────────────────────────────┐
185
- │ CURRENT AUTH FLOW │
186
- └─────────────────────────────────────────────┘
187
-
188
- ┌─────────────┼─────────────┐
189
- ▼ ▼ ▼
190
- ┌─────────┐ ┌─────────┐ ┌─────────┐
191
- │ Google │ │ GitHub │ │ Email │
192
- │ OAuth │ │ OAuth │ │ Magic │
193
- └────┬────┘ └────┬────┘ └────┬────┘
194
- │ │ │
195
- └─────────────┼─────────────┘
196
-
197
- ┌───────────┐
198
- │ Session │
199
- └─────┬─────┘
200
-
201
-
202
- ┌───────────┐
203
- │ Perms │
204
- └───────────┘
205
-
206
- I see three tangles. Which one's burning?
207
- \`\`\`
208
-
209
- **User is stuck mid-implementation:**
210
- \`\`\`
211
- User: /opsx:explore add-auth-system
212
- The OAuth integration is more complex than expected
213
-
214
- You: [reads change artifacts]
215
-
216
- You're on task 4: "Implement OAuth flow"
217
-
218
- Let me trace what's involved...
219
-
220
- [draws diagram, explores options, suggests paths]
221
-
222
- Want to update the design to reflect this?
223
- Or add a spike task to investigate?
224
- \`\`\`
225
-
226
- **User wants to compare options:**
227
- \`\`\`
228
- User: Should we use Postgres or SQLite?
229
-
230
- You: Generic answer is boring. What's the context?
231
-
232
- User: A CLI tool that tracks local dev environments
233
-
234
- You: That changes everything.
235
-
236
- ┌─────────────────────────────────────────────────┐
237
- │ CLI TOOL DATA STORAGE │
238
- └─────────────────────────────────────────────────┘
239
-
240
- Key constraints:
241
- • No daemon running
242
- • Must work offline
243
- • Single user
244
-
245
- SQLite Postgres
246
- Deployment embedded ✓ needs server ✗
247
- Offline yes ✓ no ✗
248
- Single file yes ✓ no ✗
249
-
250
- SQLite. Not even close.
251
-
252
- Unless... is there a sync component?
253
- \`\`\`
254
-
255
- ---
256
-
257
- ## Ending Discovery
258
-
259
- There's no required ending. Discovery might:
260
-
261
- - **Flow into action**: "Ready to start? /opsx:new or /opsx:ff"
262
- - **Result in artifact updates**: "Updated design.md with these decisions"
263
- - **Just provide clarity**: User has what they need, moves on
264
- - **Continue later**: "We can pick this up anytime"
265
-
266
- When it feels like things are crystallizing, you might summarize:
267
-
268
- \`\`\`
269
- ## What We Figured Out
270
-
271
- **The problem**: [crystallized understanding]
272
-
273
- **The approach**: [if one emerged]
274
-
275
- **Open questions**: [if any remain]
276
-
277
- **Next steps** (if ready):
278
- - Create a change: /opsx:new <name>
279
- - Fast-forward to tasks: /opsx:ff <name>
280
- - Keep exploring: just keep talking
281
- \`\`\`
282
-
283
- But this summary is optional. Sometimes the thinking IS the value.
284
-
285
- ---
286
-
287
- ## Guardrails
288
-
289
- - **Don't implement** - Never write code or implement features. Creating OpenSpec artifacts is fine, writing application code is not.
290
- - **Don't fake understanding** - If something is unclear, dig deeper
291
- - **Don't rush** - Discovery is thinking time, not task time
292
- - **Don't force structure** - Let patterns emerge naturally
293
- - **Don't auto-capture** - Offer to save insights, don't just do it
294
- - **Do visualize** - A good diagram is worth many paragraphs
295
- - **Do explore the codebase** - Ground discussions in reality
296
- - **Do question assumptions** - Including the user's and your own`,
297
- license: 'MIT',
298
- compatibility: 'Requires openspec CLI.',
299
- metadata: { author: 'openspec', version: '1.0' },
300
- };
301
- }
302
- /**
303
- * Template for openspec-new-change skill
304
- * Based on /opsx:new command
305
- */
306
- export function getNewChangeSkillTemplate() {
307
- return {
308
- name: 'openspec-new-change',
309
- description: 'Start a new OpenSpec change using the experimental artifact workflow. Use when the user wants to create a new feature, fix, or modification with a structured step-by-step approach.',
310
- instructions: `Start a new change using the experimental artifact-driven approach.
311
-
312
- **Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
313
-
314
- **Steps**
315
-
316
- 1. **If no clear input provided, ask what they want to build**
317
-
318
- Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
319
- > "What change do you want to work on? Describe what you want to build or fix."
320
-
321
- From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
322
-
323
- **IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
324
-
325
- 2. **Determine the workflow schema**
326
-
327
- Use the default schema (omit \`--schema\`) unless the user explicitly requests a different workflow.
328
-
329
- **Use a different schema only if the user mentions:**
330
- - A specific schema name → use \`--schema <name>\`
331
- - "show workflows" or "what workflows" → run \`openspec schemas --json\` and let them choose
332
-
333
- **Otherwise**: Omit \`--schema\` to use the default.
334
-
335
- 3. **Create the change directory**
336
- \`\`\`bash
337
- openspec new change "<name>"
338
- \`\`\`
339
- Add \`--schema <name>\` only if the user requested a specific workflow.
340
- This creates a scaffolded change at \`openspec/changes/<name>/\` with the selected schema.
341
-
342
- 4. **Show the artifact status**
343
- \`\`\`bash
344
- openspec status --change "<name>"
345
- \`\`\`
346
- This shows which artifacts need to be created and which are ready (dependencies satisfied).
347
-
348
- 5. **Get instructions for the first artifact**
349
- The first artifact depends on the schema (e.g., \`proposal\` for spec-driven).
350
- Check the status output to find the first artifact with status "ready".
351
- \`\`\`bash
352
- openspec instructions <first-artifact-id> --change "<name>"
353
- \`\`\`
354
- This outputs the template and context for creating the first artifact.
355
-
356
- 6. **STOP and wait for user direction**
357
-
358
- **Output**
359
-
360
- After completing the steps, summarize:
361
- - Change name and location
362
- - Schema/workflow being used and its artifact sequence
363
- - Current status (0/N artifacts complete)
364
- - The template for the first artifact
365
- - Prompt: "Ready to create the first artifact? Just describe what this change is about and I'll draft it, or ask me to continue."
366
-
367
- **Guardrails**
368
- - Do NOT create any artifacts yet - just show the instructions
369
- - Do NOT advance beyond showing the first artifact template
370
- - If the name is invalid (not kebab-case), ask for a valid name
371
- - If a change with that name already exists, suggest continuing that change instead
372
- - Pass --schema if using a non-default workflow`,
373
- license: 'MIT',
374
- compatibility: 'Requires openspec CLI.',
375
- metadata: { author: 'openspec', version: '1.0' },
376
- };
377
- }
378
- /**
379
- * Template for openspec-continue-change skill
380
- * Based on /opsx:continue command
381
- */
382
- export function getContinueChangeSkillTemplate() {
383
- return {
384
- name: 'openspec-continue-change',
385
- description: 'Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow.',
386
- instructions: `Continue working on a change by creating the next artifact.
387
-
388
- **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
389
-
390
- **Steps**
391
-
392
- 1. **If no change name provided, prompt for selection**
393
-
394
- Run \`openspec list --json\` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on.
395
-
396
- Present the top 3-4 most recently modified changes as options, showing:
397
- - Change name
398
- - Schema (from \`schema\` field if present, otherwise "spec-driven")
399
- - Status (e.g., "0/5 tasks", "complete", "no tasks")
400
- - How recently it was modified (from \`lastModified\` field)
401
-
402
- Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue.
403
-
404
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
405
-
406
- 2. **Check current status**
407
- \`\`\`bash
408
- openspec status --change "<name>" --json
409
- \`\`\`
410
- Parse the JSON to understand current state. The response includes:
411
- - \`schemaName\`: The workflow schema being used (e.g., "spec-driven")
412
- - \`artifacts\`: Array of artifacts with their status ("done", "ready", "blocked")
413
- - \`isComplete\`: Boolean indicating if all artifacts are complete
414
-
415
- 3. **Act based on status**:
416
-
417
- ---
418
-
419
- **If all artifacts are complete (\`isComplete: true\`)**:
420
- - Congratulate the user
421
- - Show final status including the schema used
422
- - Suggest: "All artifacts created! You can now implement this change or archive it."
423
- - STOP
424
-
425
- ---
426
-
427
- **If artifacts are ready to create** (status shows artifacts with \`status: "ready"\`):
428
- - Pick the FIRST artifact with \`status: "ready"\` from the status output
429
- - Get its instructions:
430
- \`\`\`bash
431
- openspec instructions <artifact-id> --change "<name>" --json
432
- \`\`\`
433
- - Parse the JSON. The key fields are:
434
- - \`context\`: Project background (constraints for you - do NOT include in output)
435
- - \`rules\`: Artifact-specific rules (constraints for you - do NOT include in output)
436
- - \`template\`: The structure to use for your output file
437
- - \`instruction\`: Schema-specific guidance
438
- - \`outputPath\`: Where to write the artifact
439
- - \`dependencies\`: Completed artifacts to read for context
440
- - **Create the artifact file**:
441
- - Read any completed dependency files for context
442
- - Use \`template\` as the structure - fill in its sections
443
- - Apply \`context\` and \`rules\` as constraints when writing - but do NOT copy them into the file
444
- - Write to the output path specified in instructions
445
- - Show what was created and what's now unlocked
446
- - STOP after creating ONE artifact
447
-
448
- ---
449
-
450
- **If no artifacts are ready (all blocked)**:
451
- - This shouldn't happen with a valid schema
452
- - Show status and suggest checking for issues
453
-
454
- 4. **After creating an artifact, show progress**
455
- \`\`\`bash
456
- openspec status --change "<name>"
457
- \`\`\`
458
-
459
- **Output**
460
-
461
- After each invocation, show:
462
- - Which artifact was created
463
- - Schema workflow being used
464
- - Current progress (N/M complete)
465
- - What artifacts are now unlocked
466
- - Prompt: "Want to continue? Just ask me to continue or tell me what to do next."
467
-
468
- **Artifact Creation Guidelines**
469
-
470
- The artifact types and their purpose depend on the schema. Use the \`instruction\` field from the instructions output to understand what to create.
471
-
472
- Common artifact patterns:
473
-
474
- **spec-driven schema** (proposal → specs → design → tasks):
475
- - **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact.
476
- - The Capabilities section is critical - each capability listed will need a spec file.
477
- - **specs/<capability>/spec.md**: Create one spec per capability listed in the proposal's Capabilities section (use the capability name, not the change name).
478
- - **design.md**: Document technical decisions, architecture, and implementation approach.
479
- - **tasks.md**: Break down implementation into checkboxed tasks.
480
-
481
- For other schemas, follow the \`instruction\` field from the CLI output.
482
-
483
- **Guardrails**
484
- - Create ONE artifact per invocation
485
- - Always read dependency artifacts before creating a new one
486
- - Never skip artifacts or create out of order
487
- - If context is unclear, ask the user before creating
488
- - Verify the artifact file exists after writing before marking progress
489
- - Use the schema's artifact sequence, don't assume specific artifact names
490
- - **IMPORTANT**: \`context\` and \`rules\` are constraints for YOU, not content for the file
491
- - Do NOT copy \`<context>\`, \`<rules>\`, \`<project_context>\` blocks into the artifact
492
- - These guide what you write, but should never appear in the output`,
493
- license: 'MIT',
494
- compatibility: 'Requires openspec CLI.',
495
- metadata: { author: 'openspec', version: '1.0' },
496
- };
497
- }
498
- /**
499
- * Template for openspec-apply-change skill
500
- * For implementing tasks from a completed (or in-progress) change
501
- */
502
- export function getApplyChangeSkillTemplate() {
503
- return {
504
- name: 'openspec-apply-change',
505
- description: 'Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.',
506
- instructions: `Implement tasks from an OpenSpec change.
507
-
508
- **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
509
-
510
- **Steps**
511
-
512
- 1. **Select the change**
513
-
514
- If a name is provided, use it. Otherwise:
515
- - Infer from conversation context if the user mentioned a change
516
- - Auto-select if only one active change exists
517
- - If ambiguous, run \`openspec list --json\` to get available changes and use the **AskUserQuestion tool** to let the user select
518
-
519
- Always announce: "Using change: <name>" and how to override (e.g., \`/opsx:apply <other>\`).
520
-
521
- 2. **Check status to understand the schema**
522
- \`\`\`bash
523
- openspec status --change "<name>" --json
524
- \`\`\`
525
- Parse the JSON to understand:
526
- - \`schemaName\`: The workflow being used (e.g., "spec-driven")
527
- - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
528
-
529
- 3. **Get apply instructions**
530
-
531
- \`\`\`bash
532
- openspec instructions apply --change "<name>" --json
533
- \`\`\`
534
-
535
- This returns:
536
- - Context file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
537
- - Progress (total, complete, remaining)
538
- - Task list with status
539
- - Dynamic instruction based on current state
540
-
541
- **Handle states:**
542
- - If \`state: "blocked"\` (missing artifacts): show message, suggest using openspec-continue-change
543
- - If \`state: "all_done"\`: congratulate, suggest archive
544
- - Otherwise: proceed to implementation
545
-
546
- 4. **Read context files**
547
-
548
- Read the files listed in \`contextFiles\` from the apply instructions output.
549
- The files depend on the schema being used:
550
- - **spec-driven**: proposal, specs, design, tasks
551
- - Other schemas: follow the contextFiles from CLI output
552
-
553
- 5. **Show current progress**
554
-
555
- Display:
556
- - Schema being used
557
- - Progress: "N/M tasks complete"
558
- - Remaining tasks overview
559
- - Dynamic instruction from CLI
560
-
561
- 6. **Implement tasks (loop until done or blocked)**
562
-
563
- For each pending task:
564
- - Show which task is being worked on
565
- - Make the code changes required
566
- - Keep changes minimal and focused
567
- - Mark task complete in the tasks file: \`- [ ]\` → \`- [x]\`
568
- - Continue to next task
569
-
570
- **Pause if:**
571
- - Task is unclear → ask for clarification
572
- - Implementation reveals a design issue → suggest updating artifacts
573
- - Error or blocker encountered → report and wait for guidance
574
- - User interrupts
575
-
576
- 7. **On completion or pause, show status**
577
-
578
- Display:
579
- - Tasks completed this session
580
- - Overall progress: "N/M tasks complete"
581
- - If all done: suggest archive
582
- - If paused: explain why and wait for guidance
583
-
584
- **Output During Implementation**
585
-
586
- \`\`\`
587
- ## Implementing: <change-name> (schema: <schema-name>)
588
-
589
- Working on task 3/7: <task description>
590
- [...implementation happening...]
591
- ✓ Task complete
592
-
593
- Working on task 4/7: <task description>
594
- [...implementation happening...]
595
- ✓ Task complete
596
- \`\`\`
597
-
598
- **Output On Completion**
599
-
600
- \`\`\`
601
- ## Implementation Complete
602
-
603
- **Change:** <change-name>
604
- **Schema:** <schema-name>
605
- **Progress:** 7/7 tasks complete ✓
606
-
607
- ### Completed This Session
608
- - [x] Task 1
609
- - [x] Task 2
610
- ...
611
-
612
- All tasks complete! Ready to archive this change.
613
- \`\`\`
614
-
615
- **Output On Pause (Issue Encountered)**
616
-
617
- \`\`\`
618
- ## Implementation Paused
619
-
620
- **Change:** <change-name>
621
- **Schema:** <schema-name>
622
- **Progress:** 4/7 tasks complete
623
-
624
- ### Issue Encountered
625
- <description of the issue>
626
-
627
- **Options:**
628
- 1. <option 1>
629
- 2. <option 2>
630
- 3. Other approach
631
-
632
- What would you like to do?
633
- \`\`\`
634
-
635
- **Guardrails**
636
- - Keep going through tasks until done or blocked
637
- - Always read context files before starting (from the apply instructions output)
638
- - If task is ambiguous, pause and ask before implementing
639
- - If implementation reveals issues, pause and suggest artifact updates
640
- - Keep code changes minimal and scoped to each task
641
- - Update task checkbox immediately after completing each task
642
- - Pause on errors, blockers, or unclear requirements - don't guess
643
- - Use contextFiles from CLI output, don't assume specific file names
644
-
645
- **Fluid Workflow Integration**
646
-
647
- This skill supports the "actions on a change" model:
648
-
649
- - **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
650
- - **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly`,
651
- license: 'MIT',
652
- compatibility: 'Requires openspec CLI.',
653
- metadata: { author: 'openspec', version: '1.0' },
654
- };
655
- }
656
- /**
657
- * Template for openspec-ff-change skill
658
- * Fast-forward through artifact creation
659
- */
660
- export function getFfChangeSkillTemplate() {
661
- return {
662
- name: 'openspec-ff-change',
663
- description: 'Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually.',
664
- instructions: `Fast-forward through artifact creation - generate everything needed to start implementation in one go.
665
-
666
- **Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
667
-
668
- **Steps**
669
-
670
- 1. **If no clear input provided, ask what they want to build**
671
-
672
- Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
673
- > "What change do you want to work on? Describe what you want to build or fix."
674
-
675
- From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
676
-
677
- **IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
678
-
679
- 2. **Create the change directory**
680
- \`\`\`bash
681
- openspec new change "<name>"
682
- \`\`\`
683
- This creates a scaffolded change at \`openspec/changes/<name>/\`.
684
-
685
- 3. **Get the artifact build order**
686
- \`\`\`bash
687
- openspec status --change "<name>" --json
688
- \`\`\`
689
- Parse the JSON to get:
690
- - \`applyRequires\`: array of artifact IDs needed before implementation (e.g., \`["tasks"]\`)
691
- - \`artifacts\`: list of all artifacts with their status and dependencies
692
-
693
- 4. **Create artifacts in sequence until apply-ready**
694
-
695
- Use the **TodoWrite tool** to track progress through the artifacts.
696
-
697
- Loop through artifacts in dependency order (artifacts with no pending dependencies first):
698
-
699
- a. **For each artifact that is \`ready\` (dependencies satisfied)**:
700
- - Get instructions:
701
- \`\`\`bash
702
- openspec instructions <artifact-id> --change "<name>" --json
703
- \`\`\`
704
- - The instructions JSON includes:
705
- - \`context\`: Project background (constraints for you - do NOT include in output)
706
- - \`rules\`: Artifact-specific rules (constraints for you - do NOT include in output)
707
- - \`template\`: The structure to use for your output file
708
- - \`instruction\`: Schema-specific guidance for this artifact type
709
- - \`outputPath\`: Where to write the artifact
710
- - \`dependencies\`: Completed artifacts to read for context
711
- - Read any completed dependency files for context
712
- - Create the artifact file using \`template\` as the structure
713
- - Apply \`context\` and \`rules\` as constraints - but do NOT copy them into the file
714
- - Show brief progress: "✓ Created <artifact-id>"
715
-
716
- b. **Continue until all \`applyRequires\` artifacts are complete**
717
- - After creating each artifact, re-run \`openspec status --change "<name>" --json\`
718
- - Check if every artifact ID in \`applyRequires\` has \`status: "done"\` in the artifacts array
719
- - Stop when all \`applyRequires\` artifacts are done
720
-
721
- c. **If an artifact requires user input** (unclear context):
722
- - Use **AskUserQuestion tool** to clarify
723
- - Then continue with creation
724
-
725
- 5. **Show final status**
726
- \`\`\`bash
727
- openspec status --change "<name>"
728
- \`\`\`
729
-
730
- **Output**
731
-
732
- After completing all artifacts, summarize:
733
- - Change name and location
734
- - List of artifacts created with brief descriptions
735
- - What's ready: "All artifacts created! Ready for implementation."
736
- - Prompt: "Run \`/opsx:apply\` or ask me to implement to start working on the tasks."
737
-
738
- **Artifact Creation Guidelines**
739
-
740
- - Follow the \`instruction\` field from \`openspec instructions\` for each artifact type
741
- - The schema defines what each artifact should contain - follow it
742
- - Read dependency artifacts for context before creating new ones
743
- - Use \`template\` as the structure for your output file - fill in its sections
744
- - **IMPORTANT**: \`context\` and \`rules\` are constraints for YOU, not content for the file
745
- - Do NOT copy \`<context>\`, \`<rules>\`, \`<project_context>\` blocks into the artifact
746
- - These guide what you write, but should never appear in the output
747
-
748
- **Guardrails**
749
- - Create ALL artifacts needed for implementation (as defined by schema's \`apply.requires\`)
750
- - Always read dependency artifacts before creating a new one
751
- - If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
752
- - If a change with that name already exists, suggest continuing that change instead
753
- - Verify each artifact file exists after writing before proceeding to next`,
754
- license: 'MIT',
755
- compatibility: 'Requires openspec CLI.',
756
- metadata: { author: 'openspec', version: '1.0' },
757
- };
758
- }
759
- /**
760
- * Template for openspec-sync-specs skill
761
- * For syncing delta specs from a change to main specs (agent-driven)
762
- */
763
- export function getSyncSpecsSkillTemplate() {
764
- return {
765
- name: 'openspec-sync-specs',
766
- description: 'Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.',
767
- instructions: `Sync delta specs from a change to main specs.
768
-
769
- This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
770
-
771
- **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
772
-
773
- **Steps**
774
-
775
- 1. **If no change name provided, prompt for selection**
776
-
777
- Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
778
-
779
- Show changes that have delta specs (under \`specs/\` directory).
780
-
781
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
782
-
783
- 2. **Find delta specs**
784
-
785
- Look for delta spec files in \`openspec/changes/<name>/specs/*/spec.md\`.
786
-
787
- Each delta spec file contains sections like:
788
- - \`## ADDED Requirements\` - New requirements to add
789
- - \`## MODIFIED Requirements\` - Changes to existing requirements
790
- - \`## REMOVED Requirements\` - Requirements to remove
791
- - \`## RENAMED Requirements\` - Requirements to rename (FROM:/TO: format)
792
-
793
- If no delta specs found, inform user and stop.
794
-
795
- 3. **For each delta spec, apply changes to main specs**
796
-
797
- For each capability with a delta spec at \`openspec/changes/<name>/specs/<capability>/spec.md\`:
798
-
799
- a. **Read the delta spec** to understand the intended changes
800
-
801
- b. **Read the main spec** at \`openspec/specs/<capability>/spec.md\` (may not exist yet)
802
-
803
- c. **Apply changes intelligently**:
804
-
805
- **ADDED Requirements:**
806
- - If requirement doesn't exist in main spec → add it
807
- - If requirement already exists → update it to match (treat as implicit MODIFIED)
808
-
809
- **MODIFIED Requirements:**
810
- - Find the requirement in main spec
811
- - Apply the changes - this can be:
812
- - Adding new scenarios (don't need to copy existing ones)
813
- - Modifying existing scenarios
814
- - Changing the requirement description
815
- - Preserve scenarios/content not mentioned in the delta
816
-
817
- **REMOVED Requirements:**
818
- - Remove the entire requirement block from main spec
819
-
820
- **RENAMED Requirements:**
821
- - Find the FROM requirement, rename to TO
822
-
823
- d. **Create new main spec** if capability doesn't exist yet:
824
- - Create \`openspec/specs/<capability>/spec.md\`
825
- - Add Purpose section (can be brief, mark as TBD)
826
- - Add Requirements section with the ADDED requirements
827
-
828
- 4. **Show summary**
829
-
830
- After applying all changes, summarize:
831
- - Which capabilities were updated
832
- - What changes were made (requirements added/modified/removed/renamed)
833
-
834
- **Delta Spec Format Reference**
835
-
836
- \`\`\`markdown
837
- ## ADDED Requirements
838
-
839
- ### Requirement: New Feature
840
- The system SHALL do something new.
841
-
842
- #### Scenario: Basic case
843
- - **WHEN** user does X
844
- - **THEN** system does Y
845
-
846
- ## MODIFIED Requirements
847
-
848
- ### Requirement: Existing Feature
849
- #### Scenario: New scenario to add
850
- - **WHEN** user does A
851
- - **THEN** system does B
852
-
853
- ## REMOVED Requirements
854
-
855
- ### Requirement: Deprecated Feature
856
-
857
- ## RENAMED Requirements
858
-
859
- - FROM: \`### Requirement: Old Name\`
860
- - TO: \`### Requirement: New Name\`
861
- \`\`\`
862
-
863
- **Key Principle: Intelligent Merging**
864
-
865
- Unlike programmatic merging, you can apply **partial updates**:
866
- - To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios
867
- - The delta represents *intent*, not a wholesale replacement
868
- - Use your judgment to merge changes sensibly
869
-
870
- **Output On Success**
871
-
872
- \`\`\`
873
- ## Specs Synced: <change-name>
874
-
875
- Updated main specs:
876
-
877
- **<capability-1>**:
878
- - Added requirement: "New Feature"
879
- - Modified requirement: "Existing Feature" (added 1 scenario)
880
-
881
- **<capability-2>**:
882
- - Created new spec file
883
- - Added requirement: "Another Feature"
884
-
885
- Main specs are now updated. The change remains active - archive when implementation is complete.
886
- \`\`\`
887
-
888
- **Guardrails**
889
- - Read both delta and main specs before making changes
890
- - Preserve existing content not mentioned in delta
891
- - If something is unclear, ask for clarification
892
- - Show what you're changing as you go
893
- - The operation should be idempotent - running twice should give same result`,
894
- license: 'MIT',
895
- compatibility: 'Requires openspec CLI.',
896
- metadata: { author: 'openspec', version: '1.0' },
897
- };
898
- }
899
- /**
900
- * Template for openspec-onboard skill
901
- * Guided onboarding through the complete OpenSpec workflow
902
- */
903
- export function getOnboardSkillTemplate() {
904
- return {
905
- name: 'openspec-onboard',
906
- description: 'Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.',
907
- instructions: getOnboardInstructions(),
908
- license: 'MIT',
909
- compatibility: 'Requires openspec CLI.',
910
- metadata: { author: 'openspec', version: '1.0' },
911
- };
912
- }
913
- /**
914
- * Shared onboarding instructions used by both skill and command templates.
915
- */
916
- function getOnboardInstructions() {
917
- return `Guide the user through their first complete OpenSpec workflow cycle. This is a teaching experience—you'll do real work in their codebase while explaining each step.
918
-
919
- ---
920
-
921
- ## Preflight
922
-
923
- Before starting, check if OpenSpec is initialized:
924
-
925
- \`\`\`bash
926
- openspec status --json 2>&1 || echo "NOT_INITIALIZED"
927
- \`\`\`
928
-
929
- **If not initialized:**
930
- > OpenSpec isn't set up in this project yet. Run \`openspec init\` first, then come back to \`/opsx:onboard\`.
931
-
932
- Stop here if not initialized.
933
-
934
- ---
935
-
936
- ## Phase 1: Welcome
937
-
938
- Display:
939
-
940
- \`\`\`
941
- ## Welcome to OpenSpec!
942
-
943
- I'll walk you through a complete change cycle—from idea to implementation—using a real task in your codebase. Along the way, you'll learn the workflow by doing it.
944
-
945
- **What we'll do:**
946
- 1. Pick a small, real task in your codebase
947
- 2. Explore the problem briefly
948
- 3. Create a change (the container for our work)
949
- 4. Build the artifacts: proposal → specs → design → tasks
950
- 5. Implement the tasks
951
- 6. Archive the completed change
952
-
953
- **Time:** ~15-20 minutes
954
-
955
- Let's start by finding something to work on.
956
- \`\`\`
957
-
958
- ---
959
-
960
- ## Phase 2: Task Selection
961
-
962
- ### Codebase Analysis
963
-
964
- Scan the codebase for small improvement opportunities. Look for:
965
-
966
- 1. **TODO/FIXME comments** - Search for \`TODO\`, \`FIXME\`, \`HACK\`, \`XXX\` in code files
967
- 2. **Missing error handling** - \`catch\` blocks that swallow errors, risky operations without try-catch
968
- 3. **Functions without tests** - Cross-reference \`src/\` with test directories
969
- 4. **Type issues** - \`any\` types in TypeScript files (\`: any\`, \`as any\`)
970
- 5. **Debug artifacts** - \`console.log\`, \`console.debug\`, \`debugger\` statements in non-debug code
971
- 6. **Missing validation** - User input handlers without validation
972
-
973
- Also check recent git activity:
974
- \`\`\`bash
975
- git log --oneline -10 2>/dev/null || echo "No git history"
976
- \`\`\`
977
-
978
- ### Present Suggestions
979
-
980
- From your analysis, present 3-4 specific suggestions:
981
-
982
- \`\`\`
983
- ## Task Suggestions
984
-
985
- Based on scanning your codebase, here are some good starter tasks:
986
-
987
- **1. [Most promising task]**
988
- Location: \`src/path/to/file.ts:42\`
989
- Scope: ~1-2 files, ~20-30 lines
990
- Why it's good: [brief reason]
991
-
992
- **2. [Second task]**
993
- Location: \`src/another/file.ts\`
994
- Scope: ~1 file, ~15 lines
995
- Why it's good: [brief reason]
996
-
997
- **3. [Third task]**
998
- Location: [location]
999
- Scope: [estimate]
1000
- Why it's good: [brief reason]
1001
-
1002
- **4. Something else?**
1003
- Tell me what you'd like to work on.
1004
-
1005
- Which task interests you? (Pick a number or describe your own)
1006
- \`\`\`
1007
-
1008
- **If nothing found:** Fall back to asking what the user wants to build:
1009
- > I didn't find obvious quick wins in your codebase. What's something small you've been meaning to add or fix?
1010
-
1011
- ### Scope Guardrail
1012
-
1013
- If the user picks or describes something too large (major feature, multi-day work):
1014
-
1015
- \`\`\`
1016
- That's a valuable task, but it's probably larger than ideal for your first OpenSpec run-through.
1017
-
1018
- For learning the workflow, smaller is better—it lets you see the full cycle without getting stuck in implementation details.
1019
-
1020
- **Options:**
1021
- 1. **Slice it smaller** - What's the smallest useful piece of [their task]? Maybe just [specific slice]?
1022
- 2. **Pick something else** - One of the other suggestions, or a different small task?
1023
- 3. **Do it anyway** - If you really want to tackle this, we can. Just know it'll take longer.
1024
-
1025
- What would you prefer?
1026
- \`\`\`
1027
-
1028
- Let the user override if they insist—this is a soft guardrail.
1029
-
1030
- ---
1031
-
1032
- ## Phase 3: Explore Demo
1033
-
1034
- Once a task is selected, briefly demonstrate explore mode:
1035
-
1036
- \`\`\`
1037
- Before we create a change, let me quickly show you **explore mode**—it's how you think through problems before committing to a direction.
1038
- \`\`\`
1039
-
1040
- Spend 1-2 minutes investigating the relevant code:
1041
- - Read the file(s) involved
1042
- - Draw a quick ASCII diagram if it helps
1043
- - Note any considerations
1044
-
1045
- \`\`\`
1046
- ## Quick Exploration
1047
-
1048
- [Your brief analysis—what you found, any considerations]
1049
-
1050
- ┌─────────────────────────────────────────┐
1051
- │ [Optional: ASCII diagram if helpful] │
1052
- └─────────────────────────────────────────┘
1053
-
1054
- Explore mode (\`/opsx:explore\`) is for this kind of thinking—investigating before implementing. You can use it anytime you need to think through a problem.
1055
-
1056
- Now let's create a change to hold our work.
1057
- \`\`\`
1058
-
1059
- **PAUSE** - Wait for user acknowledgment before proceeding.
1060
-
1061
- ---
1062
-
1063
- ## Phase 4: Create the Change
1064
-
1065
- **EXPLAIN:**
1066
- \`\`\`
1067
- ## Creating a Change
1068
-
1069
- A "change" in OpenSpec is a container for all the thinking and planning around a piece of work. It lives in \`openspec/changes/<name>/\` and holds your artifacts—proposal, specs, design, tasks.
1070
-
1071
- Let me create one for our task.
1072
- \`\`\`
1073
-
1074
- **DO:** Create the change with a derived kebab-case name:
1075
- \`\`\`bash
1076
- openspec new change "<derived-name>"
1077
- \`\`\`
1078
-
1079
- **SHOW:**
1080
- \`\`\`
1081
- Created: \`openspec/changes/<name>/\`
1082
-
1083
- The folder structure:
1084
- \`\`\`
1085
- openspec/changes/<name>/
1086
- ├── proposal.md ← Why we're doing this (empty, we'll fill it)
1087
- ├── design.md ← How we'll build it (empty)
1088
- ├── specs/ ← Detailed requirements (empty)
1089
- └── tasks.md ← Implementation checklist (empty)
1090
- \`\`\`
1091
-
1092
- Now let's fill in the first artifact—the proposal.
1093
- \`\`\`
1094
-
1095
- ---
1096
-
1097
- ## Phase 5: Proposal
1098
-
1099
- **EXPLAIN:**
1100
- \`\`\`
1101
- ## The Proposal
1102
-
1103
- The proposal captures **why** we're making this change and **what** it involves at a high level. It's the "elevator pitch" for the work.
1104
-
1105
- I'll draft one based on our task.
1106
- \`\`\`
1107
-
1108
- **DO:** Draft the proposal content (don't save yet):
1109
-
1110
- \`\`\`
1111
- Here's a draft proposal:
1112
-
1113
- ---
1114
-
1115
- ## Why
1116
-
1117
- [1-2 sentences explaining the problem/opportunity]
1118
-
1119
- ## What Changes
1120
-
1121
- [Bullet points of what will be different]
1122
-
1123
- ## Capabilities
1124
-
1125
- ### New Capabilities
1126
- - \`<capability-name>\`: [brief description]
1127
-
1128
- ### Modified Capabilities
1129
- <!-- If modifying existing behavior -->
1130
-
1131
- ## Impact
1132
-
1133
- - \`src/path/to/file.ts\`: [what changes]
1134
- - [other files if applicable]
1135
-
1136
- ---
1137
-
1138
- Does this capture the intent? I can adjust before we save it.
1139
- \`\`\`
1140
-
1141
- **PAUSE** - Wait for user approval/feedback.
1142
-
1143
- After approval, save the proposal:
1144
- \`\`\`bash
1145
- openspec instructions proposal --change "<name>" --json
1146
- \`\`\`
1147
- Then write the content to \`openspec/changes/<name>/proposal.md\`.
1148
-
1149
- \`\`\`
1150
- Proposal saved. This is your "why" document—you can always come back and refine it as understanding evolves.
1151
-
1152
- Next up: specs.
1153
- \`\`\`
1154
-
1155
- ---
1156
-
1157
- ## Phase 6: Specs
1158
-
1159
- **EXPLAIN:**
1160
- \`\`\`
1161
- ## Specs
1162
-
1163
- Specs define **what** we're building in precise, testable terms. They use a requirement/scenario format that makes expected behavior crystal clear.
1164
-
1165
- For a small task like this, we might only need one spec file.
1166
- \`\`\`
1167
-
1168
- **DO:** Create the spec file:
1169
- \`\`\`bash
1170
- mkdir -p openspec/changes/<name>/specs/<capability-name>
1171
- \`\`\`
1172
-
1173
- Draft the spec content:
1174
-
1175
- \`\`\`
1176
- Here's the spec:
1177
-
1178
- ---
1179
-
1180
- ## ADDED Requirements
1181
-
1182
- ### Requirement: <Name>
1183
-
1184
- <Description of what the system should do>
1185
-
1186
- #### Scenario: <Scenario name>
1187
-
1188
- - **WHEN** <trigger condition>
1189
- - **THEN** <expected outcome>
1190
- - **AND** <additional outcome if needed>
1191
-
1192
- ---
1193
-
1194
- This format—WHEN/THEN/AND—makes requirements testable. You can literally read them as test cases.
1195
- \`\`\`
1196
-
1197
- Save to \`openspec/changes/<name>/specs/<capability>/spec.md\`.
1198
-
1199
- ---
1200
-
1201
- ## Phase 7: Design
1202
-
1203
- **EXPLAIN:**
1204
- \`\`\`
1205
- ## Design
1206
-
1207
- The design captures **how** we'll build it—technical decisions, tradeoffs, approach.
1208
-
1209
- For small changes, this might be brief. That's fine—not every change needs deep design discussion.
1210
- \`\`\`
1211
-
1212
- **DO:** Draft design.md:
1213
-
1214
- \`\`\`
1215
- Here's the design:
1216
-
1217
- ---
1218
-
1219
- ## Context
1220
-
1221
- [Brief context about the current state]
1222
-
1223
- ## Goals / Non-Goals
1224
-
1225
- **Goals:**
1226
- - [What we're trying to achieve]
1227
-
1228
- **Non-Goals:**
1229
- - [What's explicitly out of scope]
1230
-
1231
- ## Decisions
1232
-
1233
- ### Decision 1: [Key decision]
1234
-
1235
- [Explanation of approach and rationale]
1236
-
1237
- ---
1238
-
1239
- For a small task, this captures the key decisions without over-engineering.
1240
- \`\`\`
1241
-
1242
- Save to \`openspec/changes/<name>/design.md\`.
1243
-
1244
- ---
1245
-
1246
- ## Phase 8: Tasks
1247
-
1248
- **EXPLAIN:**
1249
- \`\`\`
1250
- ## Tasks
1251
-
1252
- Finally, we break the work into implementation tasks—checkboxes that drive the apply phase.
1253
-
1254
- These should be small, clear, and in logical order.
1255
- \`\`\`
1256
-
1257
- **DO:** Generate tasks based on specs and design:
1258
-
1259
- \`\`\`
1260
- Here are the implementation tasks:
1261
-
1262
- ---
1263
-
1264
- ## 1. [Category or file]
1265
-
1266
- - [ ] 1.1 [Specific task]
1267
- - [ ] 1.2 [Specific task]
1268
-
1269
- ## 2. Verify
1270
-
1271
- - [ ] 2.1 [Verification step]
1272
-
1273
- ---
1274
-
1275
- Each checkbox becomes a unit of work in the apply phase. Ready to implement?
1276
- \`\`\`
1277
-
1278
- **PAUSE** - Wait for user to confirm they're ready to implement.
1279
-
1280
- Save to \`openspec/changes/<name>/tasks.md\`.
1281
-
1282
- ---
1283
-
1284
- ## Phase 9: Apply (Implementation)
1285
-
1286
- **EXPLAIN:**
1287
- \`\`\`
1288
- ## Implementation
1289
-
1290
- Now we implement each task, checking them off as we go. I'll announce each one and occasionally note how the specs/design informed the approach.
1291
- \`\`\`
1292
-
1293
- **DO:** For each task:
1294
-
1295
- 1. Announce: "Working on task N: [description]"
1296
- 2. Implement the change in the codebase
1297
- 3. Reference specs/design naturally: "The spec says X, so I'm doing Y"
1298
- 4. Mark complete in tasks.md: \`- [ ]\` → \`- [x]\`
1299
- 5. Brief status: "✓ Task N complete"
1300
-
1301
- Keep narration light—don't over-explain every line of code.
1302
-
1303
- After all tasks:
1304
-
1305
- \`\`\`
1306
- ## Implementation Complete
1307
-
1308
- All tasks done:
1309
- - [x] Task 1
1310
- - [x] Task 2
1311
- - [x] ...
1312
-
1313
- The change is implemented! One more step—let's archive it.
1314
- \`\`\`
1315
-
1316
- ---
1317
-
1318
- ## Phase 10: Archive
1319
-
1320
- **EXPLAIN:**
1321
- \`\`\`
1322
- ## Archiving
1323
-
1324
- When a change is complete, we archive it. This moves it from \`openspec/changes/\` to \`openspec/changes/archive/YYYY-MM-DD-<name>/\`.
1325
-
1326
- Archived changes become your project's decision history—you can always find them later to understand why something was built a certain way.
1327
- \`\`\`
1328
-
1329
- **DO:**
1330
- \`\`\`bash
1331
- openspec archive "<name>"
1332
- \`\`\`
1333
-
1334
- **SHOW:**
1335
- \`\`\`
1336
- Archived to: \`openspec/changes/archive/YYYY-MM-DD-<name>/\`
1337
-
1338
- The change is now part of your project's history. The code is in your codebase, the decision record is preserved.
1339
- \`\`\`
1340
-
1341
- ---
1342
-
1343
- ## Phase 11: Recap & Next Steps
1344
-
1345
- \`\`\`
1346
- ## Congratulations!
1347
-
1348
- You just completed a full OpenSpec cycle:
1349
-
1350
- 1. **Explore** - Thought through the problem
1351
- 2. **New** - Created a change container
1352
- 3. **Proposal** - Captured WHY
1353
- 4. **Specs** - Defined WHAT in detail
1354
- 5. **Design** - Decided HOW
1355
- 6. **Tasks** - Broke it into steps
1356
- 7. **Apply** - Implemented the work
1357
- 8. **Archive** - Preserved the record
1358
-
1359
- This same rhythm works for any size change—a small fix or a major feature.
1360
-
1361
- ---
1362
-
1363
- ## Command Reference
1364
-
1365
- | Command | What it does |
1366
- |---------|--------------|
1367
- | \`/opsx:explore\` | Think through problems before/during work |
1368
- | \`/opsx:new\` | Start a new change, step through artifacts |
1369
- | \`/opsx:ff\` | Fast-forward: create all artifacts at once |
1370
- | \`/opsx:continue\` | Continue working on an existing change |
1371
- | \`/opsx:apply\` | Implement tasks from a change |
1372
- | \`/opsx:verify\` | Verify implementation matches artifacts |
1373
- | \`/opsx:archive\` | Archive a completed change |
1374
-
1375
- ---
1376
-
1377
- ## What's Next?
1378
-
1379
- Try \`/opsx:new\` or \`/opsx:ff\` on something you actually want to build. You've got the rhythm now!
1380
- \`\`\`
1381
-
1382
- ---
1383
-
1384
- ## Graceful Exit Handling
1385
-
1386
- ### User wants to stop mid-way
1387
-
1388
- If the user says they need to stop, want to pause, or seem disengaged:
1389
-
1390
- \`\`\`
1391
- No problem! Your change is saved at \`openspec/changes/<name>/\`.
1392
-
1393
- To pick up where we left off later:
1394
- - \`/opsx:continue <name>\` - Resume artifact creation
1395
- - \`/opsx:apply <name>\` - Jump to implementation (if tasks exist)
1396
-
1397
- The work won't be lost. Come back whenever you're ready.
1398
- \`\`\`
1399
-
1400
- Exit gracefully without pressure.
1401
-
1402
- ### User just wants command reference
1403
-
1404
- If the user says they just want to see the commands or skip the tutorial:
1405
-
1406
- \`\`\`
1407
- ## OpenSpec Quick Reference
1408
-
1409
- | Command | What it does |
1410
- |---------|--------------|
1411
- | \`/opsx:explore\` | Think through problems (no code changes) |
1412
- | \`/opsx:new <name>\` | Start a new change, step by step |
1413
- | \`/opsx:ff <name>\` | Fast-forward: all artifacts at once |
1414
- | \`/opsx:continue <name>\` | Continue an existing change |
1415
- | \`/opsx:apply <name>\` | Implement tasks |
1416
- | \`/opsx:verify <name>\` | Verify implementation |
1417
- | \`/opsx:archive <name>\` | Archive when done |
1418
-
1419
- Try \`/opsx:new\` to start your first change, or \`/opsx:ff\` if you want to move fast.
1420
- \`\`\`
1421
-
1422
- Exit gracefully.
1423
-
1424
- ---
1425
-
1426
- ## Guardrails
1427
-
1428
- - **Follow the EXPLAIN → DO → SHOW → PAUSE pattern** at key transitions (after explore, after proposal draft, after tasks, after archive)
1429
- - **Keep narration light** during implementation—teach without lecturing
1430
- - **Don't skip phases** even if the change is small—the goal is teaching the workflow
1431
- - **Pause for acknowledgment** at marked points, but don't over-pause
1432
- - **Handle exits gracefully**—never pressure the user to continue
1433
- - **Use real codebase tasks**—don't simulate or use fake examples
1434
- - **Adjust scope gently**—guide toward smaller tasks but respect user choice`;
1435
- }
1436
- /**
1437
- * Template for /opsx:explore slash command
1438
- * Explore mode - adaptive thinking partner
1439
- */
1440
- export function getOpsxExploreCommandTemplate() {
1441
- return {
1442
- name: 'OPSX: Explore',
1443
- description: 'Enter explore mode - think through ideas, investigate problems, clarify requirements',
1444
- category: 'Workflow',
1445
- tags: ['workflow', 'explore', 'experimental', 'thinking'],
1446
- content: `Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
1447
-
1448
- **IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first (e.g., start a change with \`/opsx:new\` or \`/opsx:ff\`). You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing.
1449
-
1450
- **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore.
1451
-
1452
- **Input**: The argument after \`/opsx:explore\` is whatever the user wants to think about. Could be:
1453
- - A vague idea: "real-time collaboration"
1454
- - A specific problem: "the auth system is getting unwieldy"
1455
- - A change name: "add-dark-mode" (to explore in context of that change)
1456
- - A comparison: "postgres vs sqlite for this"
1457
- - Nothing (just enter explore mode)
1458
-
1459
- ---
1460
-
1461
- ## The Stance
1462
-
1463
- - **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
1464
- - **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
1465
- - **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
1466
- - **Adaptive** - Follow interesting threads, pivot when new information emerges
1467
- - **Patient** - Don't rush to conclusions, let the shape of the problem emerge
1468
- - **Grounded** - Explore the actual codebase when relevant, don't just theorize
1469
-
1470
- ---
1471
-
1472
- ## What You Might Do
1473
-
1474
- Depending on what the user brings, you might:
1475
-
1476
- **Explore the problem space**
1477
- - Ask clarifying questions that emerge from what they said
1478
- - Challenge assumptions
1479
- - Reframe the problem
1480
- - Find analogies
1481
-
1482
- **Investigate the codebase**
1483
- - Map existing architecture relevant to the discussion
1484
- - Find integration points
1485
- - Identify patterns already in use
1486
- - Surface hidden complexity
1487
-
1488
- **Compare options**
1489
- - Brainstorm multiple approaches
1490
- - Build comparison tables
1491
- - Sketch tradeoffs
1492
- - Recommend a path (if asked)
1493
-
1494
- **Visualize**
1495
- \`\`\`
1496
- ┌─────────────────────────────────────────┐
1497
- │ Use ASCII diagrams liberally │
1498
- ├─────────────────────────────────────────┤
1499
- │ │
1500
- │ ┌────────┐ ┌────────┐ │
1501
- │ │ State │────────▶│ State │ │
1502
- │ │ A │ │ B │ │
1503
- │ └────────┘ └────────┘ │
1504
- │ │
1505
- │ System diagrams, state machines, │
1506
- │ data flows, architecture sketches, │
1507
- │ dependency graphs, comparison tables │
1508
- │ │
1509
- └─────────────────────────────────────────┘
1510
- \`\`\`
1511
-
1512
- **Surface risks and unknowns**
1513
- - Identify what could go wrong
1514
- - Find gaps in understanding
1515
- - Suggest spikes or investigations
1516
-
1517
- ---
1518
-
1519
- ## OpenSpec Awareness
1520
-
1521
- You have full context of the OpenSpec system. Use it naturally, don't force it.
1522
-
1523
- ### Check for context
1524
-
1525
- At the start, quickly check what exists:
1526
- \`\`\`bash
1527
- openspec list --json
1528
- \`\`\`
1529
-
1530
- This tells you:
1531
- - If there are active changes
1532
- - Their names, schemas, and status
1533
- - What the user might be working on
1534
-
1535
- If the user mentioned a specific change name, read its artifacts for context.
1536
-
1537
- ### When no change exists
1538
-
1539
- Think freely. When insights crystallize, you might offer:
1540
-
1541
- - "This feels solid enough to start a change. Want me to create one?"
1542
- → Can transition to \`/opsx:new\` or \`/opsx:ff\`
1543
- - Or keep exploring - no pressure to formalize
1544
-
1545
- ### When a change exists
1546
-
1547
- If the user mentions a change or you detect one is relevant:
1548
-
1549
- 1. **Read existing artifacts for context**
1550
- - \`openspec/changes/<name>/proposal.md\`
1551
- - \`openspec/changes/<name>/design.md\`
1552
- - \`openspec/changes/<name>/tasks.md\`
1553
- - etc.
1554
-
1555
- 2. **Reference them naturally in conversation**
1556
- - "Your design mentions using Redis, but we just realized SQLite fits better..."
1557
- - "The proposal scopes this to premium users, but we're now thinking everyone..."
1558
-
1559
- 3. **Offer to capture when decisions are made**
1560
-
1561
- | Insight Type | Where to Capture |
1562
- |--------------|------------------|
1563
- | New requirement discovered | \`specs/<capability>/spec.md\` |
1564
- | Requirement changed | \`specs/<capability>/spec.md\` |
1565
- | Design decision made | \`design.md\` |
1566
- | Scope changed | \`proposal.md\` |
1567
- | New work identified | \`tasks.md\` |
1568
- | Assumption invalidated | Relevant artifact |
1569
-
1570
- Example offers:
1571
- - "That's a design decision. Capture it in design.md?"
1572
- - "This is a new requirement. Add it to specs?"
1573
- - "This changes scope. Update the proposal?"
1574
-
1575
- 4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
1576
-
1577
- ---
1578
-
1579
- ## What You Don't Have To Do
1580
-
1581
- - Follow a script
1582
- - Ask the same questions every time
1583
- - Produce a specific artifact
1584
- - Reach a conclusion
1585
- - Stay on topic if a tangent is valuable
1586
- - Be brief (this is thinking time)
1587
-
1588
- ---
1589
-
1590
- ## Ending Discovery
1591
-
1592
- There's no required ending. Discovery might:
1593
-
1594
- - **Flow into action**: "Ready to start? \`/opsx:new\` or \`/opsx:ff\`"
1595
- - **Result in artifact updates**: "Updated design.md with these decisions"
1596
- - **Just provide clarity**: User has what they need, moves on
1597
- - **Continue later**: "We can pick this up anytime"
1598
-
1599
- When things crystallize, you might offer a summary - but it's optional. Sometimes the thinking IS the value.
1600
-
1601
- ---
1602
-
1603
- ## Guardrails
1604
-
1605
- - **Don't implement** - Never write code or implement features. Creating OpenSpec artifacts is fine, writing application code is not.
1606
- - **Don't fake understanding** - If something is unclear, dig deeper
1607
- - **Don't rush** - Discovery is thinking time, not task time
1608
- - **Don't force structure** - Let patterns emerge naturally
1609
- - **Don't auto-capture** - Offer to save insights, don't just do it
1610
- - **Do visualize** - A good diagram is worth many paragraphs
1611
- - **Do explore the codebase** - Ground discussions in reality
1612
- - **Do question assumptions** - Including the user's and your own`
1613
- };
1614
- }
1615
- /**
1616
- * Template for /opsx:new slash command
1617
- */
1618
- export function getOpsxNewCommandTemplate() {
1619
- return {
1620
- name: 'OPSX: New',
1621
- description: 'Start a new change using the experimental artifact workflow (OPSX)',
1622
- category: 'Workflow',
1623
- tags: ['workflow', 'artifacts', 'experimental'],
1624
- content: `Start a new change using the experimental artifact-driven approach.
1625
-
1626
- **Input**: The argument after \`/opsx:new\` is the change name (kebab-case), OR a description of what the user wants to build.
1627
-
1628
- **Steps**
1629
-
1630
- 1. **If no input provided, ask what they want to build**
1631
-
1632
- Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
1633
- > "What change do you want to work on? Describe what you want to build or fix."
1634
-
1635
- From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
1636
-
1637
- **IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
1638
-
1639
- 2. **Determine the workflow schema**
1640
-
1641
- Use the default schema (omit \`--schema\`) unless the user explicitly requests a different workflow.
1642
-
1643
- **Use a different schema only if the user mentions:**
1644
- - A specific schema name → use \`--schema <name>\`
1645
- - "show workflows" or "what workflows" → run \`openspec schemas --json\` and let them choose
1646
-
1647
- **Otherwise**: Omit \`--schema\` to use the default.
1648
-
1649
- 3. **Create the change directory**
1650
- \`\`\`bash
1651
- openspec new change "<name>"
1652
- \`\`\`
1653
- Add \`--schema <name>\` only if the user requested a specific workflow.
1654
- This creates a scaffolded change at \`openspec/changes/<name>/\` with the selected schema.
1655
-
1656
- 4. **Show the artifact status**
1657
- \`\`\`bash
1658
- openspec status --change "<name>"
1659
- \`\`\`
1660
- This shows which artifacts need to be created and which are ready (dependencies satisfied).
1661
-
1662
- 5. **Get instructions for the first artifact**
1663
- The first artifact depends on the schema. Check the status output to find the first artifact with status "ready".
1664
- \`\`\`bash
1665
- openspec instructions <first-artifact-id> --change "<name>"
1666
- \`\`\`
1667
- This outputs the template and context for creating the first artifact.
1668
-
1669
- 6. **STOP and wait for user direction**
1670
-
1671
- **Output**
1672
-
1673
- After completing the steps, summarize:
1674
- - Change name and location
1675
- - Schema/workflow being used and its artifact sequence
1676
- - Current status (0/N artifacts complete)
1677
- - The template for the first artifact
1678
- - Prompt: "Ready to create the first artifact? Run \`/opsx:continue\` or just describe what this change is about and I'll draft it."
1679
-
1680
- **Guardrails**
1681
- - Do NOT create any artifacts yet - just show the instructions
1682
- - Do NOT advance beyond showing the first artifact template
1683
- - If the name is invalid (not kebab-case), ask for a valid name
1684
- - If a change with that name already exists, suggest using \`/opsx:continue\` instead
1685
- - Pass --schema if using a non-default workflow`
1686
- };
1687
- }
1688
- /**
1689
- * Template for /opsx:continue slash command
1690
- */
1691
- export function getOpsxContinueCommandTemplate() {
1692
- return {
1693
- name: 'OPSX: Continue',
1694
- description: 'Continue working on a change - create the next artifact (Experimental)',
1695
- category: 'Workflow',
1696
- tags: ['workflow', 'artifacts', 'experimental'],
1697
- content: `Continue working on a change by creating the next artifact.
1698
-
1699
- **Input**: Optionally specify a change name after \`/opsx:continue\` (e.g., \`/opsx:continue add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
1700
-
1701
- **Steps**
1702
-
1703
- 1. **If no change name provided, prompt for selection**
1704
-
1705
- Run \`openspec list --json\` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on.
1706
-
1707
- Present the top 3-4 most recently modified changes as options, showing:
1708
- - Change name
1709
- - Schema (from \`schema\` field if present, otherwise "spec-driven")
1710
- - Status (e.g., "0/5 tasks", "complete", "no tasks")
1711
- - How recently it was modified (from \`lastModified\` field)
1712
-
1713
- Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue.
1714
-
1715
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
1716
-
1717
- 2. **Check current status**
1718
- \`\`\`bash
1719
- openspec status --change "<name>" --json
1720
- \`\`\`
1721
- Parse the JSON to understand current state. The response includes:
1722
- - \`schemaName\`: The workflow schema being used (e.g., "spec-driven")
1723
- - \`artifacts\`: Array of artifacts with their status ("done", "ready", "blocked")
1724
- - \`isComplete\`: Boolean indicating if all artifacts are complete
1725
-
1726
- 3. **Act based on status**:
1727
-
1728
- ---
1729
-
1730
- **If all artifacts are complete (\`isComplete: true\`)**:
1731
- - Congratulate the user
1732
- - Show final status including the schema used
1733
- - Suggest: "All artifacts created! You can now implement this change with \`/opsx:apply\` or archive it with \`/opsx:archive\`."
1734
- - STOP
1735
-
1736
- ---
1737
-
1738
- **If artifacts are ready to create** (status shows artifacts with \`status: "ready"\`):
1739
- - Pick the FIRST artifact with \`status: "ready"\` from the status output
1740
- - Get its instructions:
1741
- \`\`\`bash
1742
- openspec instructions <artifact-id> --change "<name>" --json
1743
- \`\`\`
1744
- - Parse the JSON. The key fields are:
1745
- - \`context\`: Project background (constraints for you - do NOT include in output)
1746
- - \`rules\`: Artifact-specific rules (constraints for you - do NOT include in output)
1747
- - \`template\`: The structure to use for your output file
1748
- - \`instruction\`: Schema-specific guidance
1749
- - \`outputPath\`: Where to write the artifact
1750
- - \`dependencies\`: Completed artifacts to read for context
1751
- - **Create the artifact file**:
1752
- - Read any completed dependency files for context
1753
- - Use \`template\` as the structure - fill in its sections
1754
- - Apply \`context\` and \`rules\` as constraints when writing - but do NOT copy them into the file
1755
- - Write to the output path specified in instructions
1756
- - Show what was created and what's now unlocked
1757
- - STOP after creating ONE artifact
1758
-
1759
- ---
1760
-
1761
- **If no artifacts are ready (all blocked)**:
1762
- - This shouldn't happen with a valid schema
1763
- - Show status and suggest checking for issues
1764
-
1765
- 4. **After creating an artifact, show progress**
1766
- \`\`\`bash
1767
- openspec status --change "<name>"
1768
- \`\`\`
1769
-
1770
- **Output**
1771
-
1772
- After each invocation, show:
1773
- - Which artifact was created
1774
- - Schema workflow being used
1775
- - Current progress (N/M complete)
1776
- - What artifacts are now unlocked
1777
- - Prompt: "Run \`/opsx:continue\` to create the next artifact"
1778
-
1779
- **Artifact Creation Guidelines**
1780
-
1781
- The artifact types and their purpose depend on the schema. Use the \`instruction\` field from the instructions output to understand what to create.
1782
-
1783
- Common artifact patterns:
1784
-
1785
- **spec-driven schema** (proposal → specs → design → tasks):
1786
- - **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact.
1787
- - The Capabilities section is critical - each capability listed will need a spec file.
1788
- - **specs/<capability>/spec.md**: Create one spec per capability listed in the proposal's Capabilities section (use the capability name, not the change name).
1789
- - **design.md**: Document technical decisions, architecture, and implementation approach.
1790
- - **tasks.md**: Break down implementation into checkboxed tasks.
1791
-
1792
- For other schemas, follow the \`instruction\` field from the CLI output.
1793
-
1794
- **Guardrails**
1795
- - Create ONE artifact per invocation
1796
- - Always read dependency artifacts before creating a new one
1797
- - Never skip artifacts or create out of order
1798
- - If context is unclear, ask the user before creating
1799
- - Verify the artifact file exists after writing before marking progress
1800
- - Use the schema's artifact sequence, don't assume specific artifact names
1801
- - **IMPORTANT**: \`context\` and \`rules\` are constraints for YOU, not content for the file
1802
- - Do NOT copy \`<context>\`, \`<rules>\`, \`<project_context>\` blocks into the artifact
1803
- - These guide what you write, but should never appear in the output`
1804
- };
1805
- }
1806
- /**
1807
- * Template for /opsx:apply slash command
1808
- */
1809
- export function getOpsxApplyCommandTemplate() {
1810
- return {
1811
- name: 'OPSX: Apply',
1812
- description: 'Implement tasks from an OpenSpec change (Experimental)',
1813
- category: 'Workflow',
1814
- tags: ['workflow', 'artifacts', 'experimental'],
1815
- content: `Implement tasks from an OpenSpec change.
1816
-
1817
- **Input**: Optionally specify a change name (e.g., \`/opsx:apply add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
1818
-
1819
- **Steps**
1820
-
1821
- 1. **Select the change**
1822
-
1823
- If a name is provided, use it. Otherwise:
1824
- - Infer from conversation context if the user mentioned a change
1825
- - Auto-select if only one active change exists
1826
- - If ambiguous, run \`openspec list --json\` to get available changes and use the **AskUserQuestion tool** to let the user select
1827
-
1828
- Always announce: "Using change: <name>" and how to override (e.g., \`/opsx:apply <other>\`).
1829
-
1830
- 2. **Check status to understand the schema**
1831
- \`\`\`bash
1832
- openspec status --change "<name>" --json
1833
- \`\`\`
1834
- Parse the JSON to understand:
1835
- - \`schemaName\`: The workflow being used (e.g., "spec-driven")
1836
- - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
1837
-
1838
- 3. **Get apply instructions**
1839
-
1840
- \`\`\`bash
1841
- openspec instructions apply --change "<name>" --json
1842
- \`\`\`
1843
-
1844
- This returns:
1845
- - Context file paths (varies by schema)
1846
- - Progress (total, complete, remaining)
1847
- - Task list with status
1848
- - Dynamic instruction based on current state
1849
-
1850
- **Handle states:**
1851
- - If \`state: "blocked"\` (missing artifacts): show message, suggest using \`/opsx:continue\`
1852
- - If \`state: "all_done"\`: congratulate, suggest archive
1853
- - Otherwise: proceed to implementation
1854
-
1855
- 4. **Read context files**
1856
-
1857
- Read the files listed in \`contextFiles\` from the apply instructions output.
1858
- The files depend on the schema being used:
1859
- - **spec-driven**: proposal, specs, design, tasks
1860
- - Other schemas: follow the contextFiles from CLI output
1861
-
1862
- 5. **Show current progress**
1863
-
1864
- Display:
1865
- - Schema being used
1866
- - Progress: "N/M tasks complete"
1867
- - Remaining tasks overview
1868
- - Dynamic instruction from CLI
1869
-
1870
- 6. **Implement tasks (loop until done or blocked)**
1871
-
1872
- For each pending task:
1873
- - Show which task is being worked on
1874
- - Make the code changes required
1875
- - Keep changes minimal and focused
1876
- - Mark task complete in the tasks file: \`- [ ]\` → \`- [x]\`
1877
- - Continue to next task
1878
-
1879
- **Pause if:**
1880
- - Task is unclear → ask for clarification
1881
- - Implementation reveals a design issue → suggest updating artifacts
1882
- - Error or blocker encountered → report and wait for guidance
1883
- - User interrupts
1884
-
1885
- 7. **On completion or pause, show status**
1886
-
1887
- Display:
1888
- - Tasks completed this session
1889
- - Overall progress: "N/M tasks complete"
1890
- - If all done: suggest archive
1891
- - If paused: explain why and wait for guidance
1892
-
1893
- **Output During Implementation**
1894
-
1895
- \`\`\`
1896
- ## Implementing: <change-name> (schema: <schema-name>)
1897
-
1898
- Working on task 3/7: <task description>
1899
- [...implementation happening...]
1900
- ✓ Task complete
1901
-
1902
- Working on task 4/7: <task description>
1903
- [...implementation happening...]
1904
- ✓ Task complete
1905
- \`\`\`
1906
-
1907
- **Output On Completion**
1908
-
1909
- \`\`\`
1910
- ## Implementation Complete
1911
-
1912
- **Change:** <change-name>
1913
- **Schema:** <schema-name>
1914
- **Progress:** 7/7 tasks complete ✓
1915
-
1916
- ### Completed This Session
1917
- - [x] Task 1
1918
- - [x] Task 2
1919
- ...
1920
-
1921
- All tasks complete! You can archive this change with \`/opsx:archive\`.
1922
- \`\`\`
1923
-
1924
- **Output On Pause (Issue Encountered)**
1925
-
1926
- \`\`\`
1927
- ## Implementation Paused
1928
-
1929
- **Change:** <change-name>
1930
- **Schema:** <schema-name>
1931
- **Progress:** 4/7 tasks complete
1932
-
1933
- ### Issue Encountered
1934
- <description of the issue>
1935
-
1936
- **Options:**
1937
- 1. <option 1>
1938
- 2. <option 2>
1939
- 3. Other approach
1940
-
1941
- What would you like to do?
1942
- \`\`\`
1943
-
1944
- **Guardrails**
1945
- - Keep going through tasks until done or blocked
1946
- - Always read context files before starting (from the apply instructions output)
1947
- - If task is ambiguous, pause and ask before implementing
1948
- - If implementation reveals issues, pause and suggest artifact updates
1949
- - Keep code changes minimal and scoped to each task
1950
- - Update task checkbox immediately after completing each task
1951
- - Pause on errors, blockers, or unclear requirements - don't guess
1952
- - Use contextFiles from CLI output, don't assume specific file names
1953
-
1954
- **Fluid Workflow Integration**
1955
-
1956
- This skill supports the "actions on a change" model:
1957
-
1958
- - **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
1959
- - **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly`
1960
- };
1961
- }
1962
- /**
1963
- * Template for /opsx:ff slash command
1964
- */
1965
- export function getOpsxFfCommandTemplate() {
1966
- return {
1967
- name: 'OPSX: Fast Forward',
1968
- description: 'Create a change and generate all artifacts needed for implementation in one go',
1969
- category: 'Workflow',
1970
- tags: ['workflow', 'artifacts', 'experimental'],
1971
- content: `Fast-forward through artifact creation - generate everything needed to start implementation.
1972
-
1973
- **Input**: The argument after \`/opsx:ff\` is the change name (kebab-case), OR a description of what the user wants to build.
1974
-
1975
- **Steps**
1976
-
1977
- 1. **If no input provided, ask what they want to build**
1978
-
1979
- Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
1980
- > "What change do you want to work on? Describe what you want to build or fix."
1981
-
1982
- From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
1983
-
1984
- **IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
1985
-
1986
- 2. **Create the change directory**
1987
- \`\`\`bash
1988
- openspec new change "<name>"
1989
- \`\`\`
1990
- This creates a scaffolded change at \`openspec/changes/<name>/\`.
1991
-
1992
- 3. **Get the artifact build order**
1993
- \`\`\`bash
1994
- openspec status --change "<name>" --json
1995
- \`\`\`
1996
- Parse the JSON to get:
1997
- - \`applyRequires\`: array of artifact IDs needed before implementation (e.g., \`["tasks"]\`)
1998
- - \`artifacts\`: list of all artifacts with their status and dependencies
1999
-
2000
- 4. **Create artifacts in sequence until apply-ready**
2001
-
2002
- Use the **TodoWrite tool** to track progress through the artifacts.
2003
-
2004
- Loop through artifacts in dependency order (artifacts with no pending dependencies first):
2005
-
2006
- a. **For each artifact that is \`ready\` (dependencies satisfied)**:
2007
- - Get instructions:
2008
- \`\`\`bash
2009
- openspec instructions <artifact-id> --change "<name>" --json
2010
- \`\`\`
2011
- - The instructions JSON includes:
2012
- - \`context\`: Project background (constraints for you - do NOT include in output)
2013
- - \`rules\`: Artifact-specific rules (constraints for you - do NOT include in output)
2014
- - \`template\`: The structure to use for your output file
2015
- - \`instruction\`: Schema-specific guidance for this artifact type
2016
- - \`outputPath\`: Where to write the artifact
2017
- - \`dependencies\`: Completed artifacts to read for context
2018
- - Read any completed dependency files for context
2019
- - Create the artifact file using \`template\` as the structure
2020
- - Apply \`context\` and \`rules\` as constraints - but do NOT copy them into the file
2021
- - Show brief progress: "✓ Created <artifact-id>"
2022
-
2023
- b. **Continue until all \`applyRequires\` artifacts are complete**
2024
- - After creating each artifact, re-run \`openspec status --change "<name>" --json\`
2025
- - Check if every artifact ID in \`applyRequires\` has \`status: "done"\` in the artifacts array
2026
- - Stop when all \`applyRequires\` artifacts are done
2027
-
2028
- c. **If an artifact requires user input** (unclear context):
2029
- - Use **AskUserQuestion tool** to clarify
2030
- - Then continue with creation
2031
-
2032
- 5. **Show final status**
2033
- \`\`\`bash
2034
- openspec status --change "<name>"
2035
- \`\`\`
2036
-
2037
- **Output**
2038
-
2039
- After completing all artifacts, summarize:
2040
- - Change name and location
2041
- - List of artifacts created with brief descriptions
2042
- - What's ready: "All artifacts created! Ready for implementation."
2043
- - Prompt: "Run \`/opsx:apply\` to start implementing."
2044
-
2045
- **Artifact Creation Guidelines**
2046
-
2047
- - Follow the \`instruction\` field from \`openspec instructions\` for each artifact type
2048
- - The schema defines what each artifact should contain - follow it
2049
- - Read dependency artifacts for context before creating new ones
2050
- - Use the \`template\` as a starting point, filling in based on context
2051
-
2052
- **Guardrails**
2053
- - Create ALL artifacts needed for implementation (as defined by schema's \`apply.requires\`)
2054
- - Always read dependency artifacts before creating a new one
2055
- - If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
2056
- - If a change with that name already exists, ask if user wants to continue it or create a new one
2057
- - Verify each artifact file exists after writing before proceeding to next`
2058
- };
2059
- }
2060
- /**
2061
- * Template for openspec-archive-change skill
2062
- * For archiving completed changes in the experimental workflow
2063
- */
2064
- export function getArchiveChangeSkillTemplate() {
2065
- return {
2066
- name: 'openspec-archive-change',
2067
- description: 'Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.',
2068
- instructions: `Archive a completed change in the experimental workflow.
2069
-
2070
- **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
2071
-
2072
- **Steps**
2073
-
2074
- 1. **If no change name provided, prompt for selection**
2075
-
2076
- Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
2077
-
2078
- Show only active changes (not already archived).
2079
- Include the schema used for each change if available.
2080
-
2081
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
2082
-
2083
- 2. **Check artifact completion status**
2084
-
2085
- Run \`openspec status --change "<name>" --json\` to check artifact completion.
2086
-
2087
- Parse the JSON to understand:
2088
- - \`schemaName\`: The workflow being used
2089
- - \`artifacts\`: List of artifacts with their status (\`done\` or other)
2090
-
2091
- **If any artifacts are not \`done\`:**
2092
- - Display warning listing incomplete artifacts
2093
- - Use **AskUserQuestion tool** to confirm user wants to proceed
2094
- - Proceed if user confirms
2095
-
2096
- 3. **Check task completion status**
2097
-
2098
- Read the tasks file (typically \`tasks.md\`) to check for incomplete tasks.
2099
-
2100
- Count tasks marked with \`- [ ]\` (incomplete) vs \`- [x]\` (complete).
2101
-
2102
- **If incomplete tasks found:**
2103
- - Display warning showing count of incomplete tasks
2104
- - Use **AskUserQuestion tool** to confirm user wants to proceed
2105
- - Proceed if user confirms
2106
-
2107
- **If no tasks file exists:** Proceed without task-related warning.
2108
-
2109
- 4. **Assess delta spec sync state**
2110
-
2111
- Check for delta specs at \`openspec/changes/<name>/specs/\`. If none exist, proceed without sync prompt.
2112
-
2113
- **If delta specs exist:**
2114
- - Compare each delta spec with its corresponding main spec at \`openspec/specs/<capability>/spec.md\`
2115
- - Determine what changes would be applied (adds, modifications, removals, renames)
2116
- - Show a combined summary before prompting
2117
-
2118
- **Prompt options:**
2119
- - If changes needed: "Sync now (recommended)", "Archive without syncing"
2120
- - If already synced: "Archive now", "Sync anyway", "Cancel"
2121
-
2122
- If user chooses sync, execute /opsx:sync logic (use the openspec-sync-specs skill). Proceed to archive regardless of choice.
2123
-
2124
- 5. **Perform the archive**
2125
-
2126
- Create the archive directory if it doesn't exist:
2127
- \`\`\`bash
2128
- mkdir -p openspec/changes/archive
2129
- \`\`\`
2130
-
2131
- Generate target name using current date: \`YYYY-MM-DD-<change-name>\`
2132
-
2133
- **Check if target already exists:**
2134
- - If yes: Fail with error, suggest renaming existing archive or using different date
2135
- - If no: Move the change directory to archive
2136
-
2137
- \`\`\`bash
2138
- mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
2139
- \`\`\`
2140
-
2141
- 6. **Display summary**
2142
-
2143
- Show archive completion summary including:
2144
- - Change name
2145
- - Schema that was used
2146
- - Archive location
2147
- - Whether specs were synced (if applicable)
2148
- - Note about any warnings (incomplete artifacts/tasks)
2149
-
2150
- **Output On Success**
2151
-
2152
- \`\`\`
2153
- ## Archive Complete
2154
-
2155
- **Change:** <change-name>
2156
- **Schema:** <schema-name>
2157
- **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
2158
- **Specs:** ✓ Synced to main specs (or "No delta specs" or "Sync skipped")
2159
-
2160
- All artifacts complete. All tasks complete.
2161
- \`\`\`
2162
-
2163
- **Guardrails**
2164
- - Always prompt for change selection if not provided
2165
- - Use artifact graph (openspec status --json) for completion checking
2166
- - Don't block archive on warnings - just inform and confirm
2167
- - Preserve .openspec.yaml when moving to archive (it moves with the directory)
2168
- - Show clear summary of what happened
2169
- - If sync is requested, use openspec-sync-specs approach (agent-driven)
2170
- - If delta specs exist, always run the sync assessment and show the combined summary before prompting`,
2171
- license: 'MIT',
2172
- compatibility: 'Requires openspec CLI.',
2173
- metadata: { author: 'openspec', version: '1.0' },
2174
- };
2175
- }
2176
- /**
2177
- * Template for openspec-bulk-archive-change skill
2178
- * For archiving multiple completed changes at once
2179
- */
2180
- export function getBulkArchiveChangeSkillTemplate() {
2181
- return {
2182
- name: 'openspec-bulk-archive-change',
2183
- description: 'Archive multiple completed changes at once. Use when archiving several parallel changes.',
2184
- instructions: `Archive multiple completed changes in a single operation.
2185
-
2186
- This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented.
2187
-
2188
- **Input**: None required (prompts for selection)
2189
-
2190
- **Steps**
2191
-
2192
- 1. **Get active changes**
2193
-
2194
- Run \`openspec list --json\` to get all active changes.
2195
-
2196
- If no active changes exist, inform user and stop.
2197
-
2198
- 2. **Prompt for change selection**
2199
-
2200
- Use **AskUserQuestion tool** with multi-select to let user choose changes:
2201
- - Show each change with its schema
2202
- - Include an option for "All changes"
2203
- - Allow any number of selections (1+ works, 2+ is the typical use case)
2204
-
2205
- **IMPORTANT**: Do NOT auto-select. Always let the user choose.
2206
-
2207
- 3. **Batch validation - gather status for all selected changes**
2208
-
2209
- For each selected change, collect:
2210
-
2211
- a. **Artifact status** - Run \`openspec status --change "<name>" --json\`
2212
- - Parse \`schemaName\` and \`artifacts\` list
2213
- - Note which artifacts are \`done\` vs other states
2214
-
2215
- b. **Task completion** - Read \`openspec/changes/<name>/tasks.md\`
2216
- - Count \`- [ ]\` (incomplete) vs \`- [x]\` (complete)
2217
- - If no tasks file exists, note as "No tasks"
2218
-
2219
- c. **Delta specs** - Check \`openspec/changes/<name>/specs/\` directory
2220
- - List which capability specs exist
2221
- - For each, extract requirement names (lines matching \`### Requirement: <name>\`)
2222
-
2223
- 4. **Detect spec conflicts**
2224
-
2225
- Build a map of \`capability -> [changes that touch it]\`:
2226
-
2227
- \`\`\`
2228
- auth -> [change-a, change-b] <- CONFLICT (2+ changes)
2229
- api -> [change-c] <- OK (only 1 change)
2230
- \`\`\`
2231
-
2232
- A conflict exists when 2+ selected changes have delta specs for the same capability.
2233
-
2234
- 5. **Resolve conflicts agentically**
2235
-
2236
- **For each conflict**, investigate the codebase:
2237
-
2238
- a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify
2239
-
2240
- b. **Search the codebase** for implementation evidence:
2241
- - Look for code implementing requirements from each delta spec
2242
- - Check for related files, functions, or tests
2243
-
2244
- c. **Determine resolution**:
2245
- - If only one change is actually implemented -> sync that one's specs
2246
- - If both implemented -> apply in chronological order (older first, newer overwrites)
2247
- - If neither implemented -> skip spec sync, warn user
2248
-
2249
- d. **Record resolution** for each conflict:
2250
- - Which change's specs to apply
2251
- - In what order (if both)
2252
- - Rationale (what was found in codebase)
2253
-
2254
- 6. **Show consolidated status table**
2255
-
2256
- Display a table summarizing all changes:
2257
-
2258
- \`\`\`
2259
- | Change | Artifacts | Tasks | Specs | Conflicts | Status |
2260
- |---------------------|-----------|-------|---------|-----------|--------|
2261
- | schema-management | Done | 5/5 | 2 delta | None | Ready |
2262
- | project-config | Done | 3/3 | 1 delta | None | Ready |
2263
- | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* |
2264
- | add-verify-skill | 1 left | 2/5 | None | None | Warn |
2265
- \`\`\`
2266
-
2267
- For conflicts, show the resolution:
2268
- \`\`\`
2269
- * Conflict resolution:
2270
- - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order)
2271
- \`\`\`
2272
-
2273
- For incomplete changes, show warnings:
2274
- \`\`\`
2275
- Warnings:
2276
- - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks
2277
- \`\`\`
2278
-
2279
- 7. **Confirm batch operation**
2280
-
2281
- Use **AskUserQuestion tool** with a single confirmation:
2282
-
2283
- - "Archive N changes?" with options based on status
2284
- - Options might include:
2285
- - "Archive all N changes"
2286
- - "Archive only N ready changes (skip incomplete)"
2287
- - "Cancel"
2288
-
2289
- If there are incomplete changes, make clear they'll be archived with warnings.
2290
-
2291
- 8. **Execute archive for each confirmed change**
2292
-
2293
- Process changes in the determined order (respecting conflict resolution):
2294
-
2295
- a. **Sync specs** if delta specs exist:
2296
- - Use the openspec-sync-specs approach (agent-driven intelligent merge)
2297
- - For conflicts, apply in resolved order
2298
- - Track if sync was done
2299
-
2300
- b. **Perform the archive**:
2301
- \`\`\`bash
2302
- mkdir -p openspec/changes/archive
2303
- mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
2304
- \`\`\`
2305
-
2306
- c. **Track outcome** for each change:
2307
- - Success: archived successfully
2308
- - Failed: error during archive (record error)
2309
- - Skipped: user chose not to archive (if applicable)
2310
-
2311
- 9. **Display summary**
2312
-
2313
- Show final results:
2314
-
2315
- \`\`\`
2316
- ## Bulk Archive Complete
2317
-
2318
- Archived 3 changes:
2319
- - schema-management-cli -> archive/2026-01-19-schema-management-cli/
2320
- - project-config -> archive/2026-01-19-project-config/
2321
- - add-oauth -> archive/2026-01-19-add-oauth/
2322
-
2323
- Skipped 1 change:
2324
- - add-verify-skill (user chose not to archive incomplete)
2325
-
2326
- Spec sync summary:
2327
- - 4 delta specs synced to main specs
2328
- - 1 conflict resolved (auth: applied both in chronological order)
2329
- \`\`\`
2330
-
2331
- If any failures:
2332
- \`\`\`
2333
- Failed 1 change:
2334
- - some-change: Archive directory already exists
2335
- \`\`\`
2336
-
2337
- **Conflict Resolution Examples**
2338
-
2339
- Example 1: Only one implemented
2340
- \`\`\`
2341
- Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt]
2342
-
2343
- Checking add-oauth:
2344
- - Delta adds "OAuth Provider Integration" requirement
2345
- - Searching codebase... found src/auth/oauth.ts implementing OAuth flow
2346
-
2347
- Checking add-jwt:
2348
- - Delta adds "JWT Token Handling" requirement
2349
- - Searching codebase... no JWT implementation found
2350
-
2351
- Resolution: Only add-oauth is implemented. Will sync add-oauth specs only.
2352
- \`\`\`
2353
-
2354
- Example 2: Both implemented
2355
- \`\`\`
2356
- Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql]
2357
-
2358
- Checking add-rest-api (created 2026-01-10):
2359
- - Delta adds "REST Endpoints" requirement
2360
- - Searching codebase... found src/api/rest.ts
2361
-
2362
- Checking add-graphql (created 2026-01-15):
2363
- - Delta adds "GraphQL Schema" requirement
2364
- - Searching codebase... found src/api/graphql.ts
2365
-
2366
- Resolution: Both implemented. Will apply add-rest-api specs first,
2367
- then add-graphql specs (chronological order, newer takes precedence).
2368
- \`\`\`
2369
-
2370
- **Output On Success**
2371
-
2372
- \`\`\`
2373
- ## Bulk Archive Complete
2374
-
2375
- Archived N changes:
2376
- - <change-1> -> archive/YYYY-MM-DD-<change-1>/
2377
- - <change-2> -> archive/YYYY-MM-DD-<change-2>/
2378
-
2379
- Spec sync summary:
2380
- - N delta specs synced to main specs
2381
- - No conflicts (or: M conflicts resolved)
2382
- \`\`\`
2383
-
2384
- **Output On Partial Success**
2385
-
2386
- \`\`\`
2387
- ## Bulk Archive Complete (partial)
2388
-
2389
- Archived N changes:
2390
- - <change-1> -> archive/YYYY-MM-DD-<change-1>/
2391
-
2392
- Skipped M changes:
2393
- - <change-2> (user chose not to archive incomplete)
2394
-
2395
- Failed K changes:
2396
- - <change-3>: Archive directory already exists
2397
- \`\`\`
2398
-
2399
- **Output When No Changes**
2400
-
2401
- \`\`\`
2402
- ## No Changes to Archive
2403
-
2404
- No active changes found. Use \`/opsx:new\` to create a new change.
2405
- \`\`\`
2406
-
2407
- **Guardrails**
2408
- - Allow any number of changes (1+ is fine, 2+ is the typical use case)
2409
- - Always prompt for selection, never auto-select
2410
- - Detect spec conflicts early and resolve by checking codebase
2411
- - When both changes are implemented, apply specs in chronological order
2412
- - Skip spec sync only when implementation is missing (warn user)
2413
- - Show clear per-change status before confirming
2414
- - Use single confirmation for entire batch
2415
- - Track and report all outcomes (success/skip/fail)
2416
- - Preserve .openspec.yaml when moving to archive
2417
- - Archive directory target uses current date: YYYY-MM-DD-<name>
2418
- - If archive target exists, fail that change but continue with others`,
2419
- license: 'MIT',
2420
- compatibility: 'Requires openspec CLI.',
2421
- metadata: { author: 'openspec', version: '1.0' },
2422
- };
2423
- }
2424
- /**
2425
- * Template for /opsx:sync slash command
2426
- */
2427
- export function getOpsxSyncCommandTemplate() {
2428
- return {
2429
- name: 'OPSX: Sync',
2430
- description: 'Sync delta specs from a change to main specs',
2431
- category: 'Workflow',
2432
- tags: ['workflow', 'specs', 'experimental'],
2433
- content: `Sync delta specs from a change to main specs.
2434
-
2435
- This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
2436
-
2437
- **Input**: Optionally specify a change name after \`/opsx:sync\` (e.g., \`/opsx:sync add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
2438
-
2439
- **Steps**
2440
-
2441
- 1. **If no change name provided, prompt for selection**
2442
-
2443
- Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
2444
-
2445
- Show changes that have delta specs (under \`specs/\` directory).
2446
-
2447
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
2448
-
2449
- 2. **Find delta specs**
2450
-
2451
- Look for delta spec files in \`openspec/changes/<name>/specs/*/spec.md\`.
2452
-
2453
- Each delta spec file contains sections like:
2454
- - \`## ADDED Requirements\` - New requirements to add
2455
- - \`## MODIFIED Requirements\` - Changes to existing requirements
2456
- - \`## REMOVED Requirements\` - Requirements to remove
2457
- - \`## RENAMED Requirements\` - Requirements to rename (FROM:/TO: format)
2458
-
2459
- If no delta specs found, inform user and stop.
2460
-
2461
- 3. **For each delta spec, apply changes to main specs**
2462
-
2463
- For each capability with a delta spec at \`openspec/changes/<name>/specs/<capability>/spec.md\`:
2464
-
2465
- a. **Read the delta spec** to understand the intended changes
2466
-
2467
- b. **Read the main spec** at \`openspec/specs/<capability>/spec.md\` (may not exist yet)
2468
-
2469
- c. **Apply changes intelligently**:
2470
-
2471
- **ADDED Requirements:**
2472
- - If requirement doesn't exist in main spec → add it
2473
- - If requirement already exists → update it to match (treat as implicit MODIFIED)
2474
-
2475
- **MODIFIED Requirements:**
2476
- - Find the requirement in main spec
2477
- - Apply the changes - this can be:
2478
- - Adding new scenarios (don't need to copy existing ones)
2479
- - Modifying existing scenarios
2480
- - Changing the requirement description
2481
- - Preserve scenarios/content not mentioned in the delta
2482
-
2483
- **REMOVED Requirements:**
2484
- - Remove the entire requirement block from main spec
2485
-
2486
- **RENAMED Requirements:**
2487
- - Find the FROM requirement, rename to TO
2488
-
2489
- d. **Create new main spec** if capability doesn't exist yet:
2490
- - Create \`openspec/specs/<capability>/spec.md\`
2491
- - Add Purpose section (can be brief, mark as TBD)
2492
- - Add Requirements section with the ADDED requirements
2493
-
2494
- 4. **Show summary**
2495
-
2496
- After applying all changes, summarize:
2497
- - Which capabilities were updated
2498
- - What changes were made (requirements added/modified/removed/renamed)
2499
-
2500
- **Delta Spec Format Reference**
2501
-
2502
- \`\`\`markdown
2503
- ## ADDED Requirements
2504
-
2505
- ### Requirement: New Feature
2506
- The system SHALL do something new.
2507
-
2508
- #### Scenario: Basic case
2509
- - **WHEN** user does X
2510
- - **THEN** system does Y
2511
-
2512
- ## MODIFIED Requirements
2513
-
2514
- ### Requirement: Existing Feature
2515
- #### Scenario: New scenario to add
2516
- - **WHEN** user does A
2517
- - **THEN** system does B
2518
-
2519
- ## REMOVED Requirements
2520
-
2521
- ### Requirement: Deprecated Feature
2522
-
2523
- ## RENAMED Requirements
2524
-
2525
- - FROM: \`### Requirement: Old Name\`
2526
- - TO: \`### Requirement: New Name\`
2527
- \`\`\`
2528
-
2529
- **Key Principle: Intelligent Merging**
2530
-
2531
- Unlike programmatic merging, you can apply **partial updates**:
2532
- - To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios
2533
- - The delta represents *intent*, not a wholesale replacement
2534
- - Use your judgment to merge changes sensibly
2535
-
2536
- **Output On Success**
2537
-
2538
- \`\`\`
2539
- ## Specs Synced: <change-name>
2540
-
2541
- Updated main specs:
2542
-
2543
- **<capability-1>**:
2544
- - Added requirement: "New Feature"
2545
- - Modified requirement: "Existing Feature" (added 1 scenario)
2546
-
2547
- **<capability-2>**:
2548
- - Created new spec file
2549
- - Added requirement: "Another Feature"
2550
-
2551
- Main specs are now updated. The change remains active - archive when implementation is complete.
2552
- \`\`\`
2553
-
2554
- **Guardrails**
2555
- - Read both delta and main specs before making changes
2556
- - Preserve existing content not mentioned in delta
2557
- - If something is unclear, ask for clarification
2558
- - Show what you're changing as you go
2559
- - The operation should be idempotent - running twice should give same result`
2560
- };
2561
- }
2562
- /**
2563
- * Template for openspec-verify-change skill
2564
- * For verifying implementation matches change artifacts before archiving
2565
- */
2566
- export function getVerifyChangeSkillTemplate() {
2567
- return {
2568
- name: 'openspec-verify-change',
2569
- description: 'Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving.',
2570
- instructions: `Verify that an implementation matches the change artifacts (specs, tasks, design).
2571
-
2572
- **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
2573
-
2574
- **Steps**
2575
-
2576
- 1. **If no change name provided, prompt for selection**
2577
-
2578
- Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
2579
-
2580
- Show changes that have implementation tasks (tasks artifact exists).
2581
- Include the schema used for each change if available.
2582
- Mark changes with incomplete tasks as "(In Progress)".
2583
-
2584
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
2585
-
2586
- 2. **Check status to understand the schema**
2587
- \`\`\`bash
2588
- openspec status --change "<name>" --json
2589
- \`\`\`
2590
- Parse the JSON to understand:
2591
- - \`schemaName\`: The workflow being used (e.g., "spec-driven")
2592
- - Which artifacts exist for this change
2593
-
2594
- 3. **Get the change directory and load artifacts**
2595
-
2596
- \`\`\`bash
2597
- openspec instructions apply --change "<name>" --json
2598
- \`\`\`
2599
-
2600
- This returns the change directory and context files. Read all available artifacts from \`contextFiles\`.
2601
-
2602
- 4. **Initialize verification report structure**
2603
-
2604
- Create a report structure with three dimensions:
2605
- - **Completeness**: Track tasks and spec coverage
2606
- - **Correctness**: Track requirement implementation and scenario coverage
2607
- - **Coherence**: Track design adherence and pattern consistency
2608
-
2609
- Each dimension can have CRITICAL, WARNING, or SUGGESTION issues.
2610
-
2611
- 5. **Verify Completeness**
2612
-
2613
- **Task Completion**:
2614
- - If tasks.md exists in contextFiles, read it
2615
- - Parse checkboxes: \`- [ ]\` (incomplete) vs \`- [x]\` (complete)
2616
- - Count complete vs total tasks
2617
- - If incomplete tasks exist:
2618
- - Add CRITICAL issue for each incomplete task
2619
- - Recommendation: "Complete task: <description>" or "Mark as done if already implemented"
2620
-
2621
- **Spec Coverage**:
2622
- - If delta specs exist in \`openspec/changes/<name>/specs/\`:
2623
- - Extract all requirements (marked with "### Requirement:")
2624
- - For each requirement:
2625
- - Search codebase for keywords related to the requirement
2626
- - Assess if implementation likely exists
2627
- - If requirements appear unimplemented:
2628
- - Add CRITICAL issue: "Requirement not found: <requirement name>"
2629
- - Recommendation: "Implement requirement X: <description>"
2630
-
2631
- 6. **Verify Correctness**
2632
-
2633
- **Requirement Implementation Mapping**:
2634
- - For each requirement from delta specs:
2635
- - Search codebase for implementation evidence
2636
- - If found, note file paths and line ranges
2637
- - Assess if implementation matches requirement intent
2638
- - If divergence detected:
2639
- - Add WARNING: "Implementation may diverge from spec: <details>"
2640
- - Recommendation: "Review <file>:<lines> against requirement X"
2641
-
2642
- **Scenario Coverage**:
2643
- - For each scenario in delta specs (marked with "#### Scenario:"):
2644
- - Check if conditions are handled in code
2645
- - Check if tests exist covering the scenario
2646
- - If scenario appears uncovered:
2647
- - Add WARNING: "Scenario not covered: <scenario name>"
2648
- - Recommendation: "Add test or implementation for scenario: <description>"
2649
-
2650
- 7. **Verify Coherence**
2651
-
2652
- **Design Adherence**:
2653
- - If design.md exists in contextFiles:
2654
- - Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:")
2655
- - Verify implementation follows those decisions
2656
- - If contradiction detected:
2657
- - Add WARNING: "Design decision not followed: <decision>"
2658
- - Recommendation: "Update implementation or revise design.md to match reality"
2659
- - If no design.md: Skip design adherence check, note "No design.md to verify against"
2660
-
2661
- **Code Pattern Consistency**:
2662
- - Review new code for consistency with project patterns
2663
- - Check file naming, directory structure, coding style
2664
- - If significant deviations found:
2665
- - Add SUGGESTION: "Code pattern deviation: <details>"
2666
- - Recommendation: "Consider following project pattern: <example>"
2667
-
2668
- 8. **Generate Verification Report**
2669
-
2670
- **Summary Scorecard**:
2671
- \`\`\`
2672
- ## Verification Report: <change-name>
2673
-
2674
- ### Summary
2675
- | Dimension | Status |
2676
- |--------------|------------------|
2677
- | Completeness | X/Y tasks, N reqs|
2678
- | Correctness | M/N reqs covered |
2679
- | Coherence | Followed/Issues |
2680
- \`\`\`
2681
-
2682
- **Issues by Priority**:
2683
-
2684
- 1. **CRITICAL** (Must fix before archive):
2685
- - Incomplete tasks
2686
- - Missing requirement implementations
2687
- - Each with specific, actionable recommendation
2688
-
2689
- 2. **WARNING** (Should fix):
2690
- - Spec/design divergences
2691
- - Missing scenario coverage
2692
- - Each with specific recommendation
2693
-
2694
- 3. **SUGGESTION** (Nice to fix):
2695
- - Pattern inconsistencies
2696
- - Minor improvements
2697
- - Each with specific recommendation
2698
-
2699
- **Final Assessment**:
2700
- - If CRITICAL issues: "X critical issue(s) found. Fix before archiving."
2701
- - If only warnings: "No critical issues. Y warning(s) to consider. Ready for archive (with noted improvements)."
2702
- - If all clear: "All checks passed. Ready for archive."
2703
-
2704
- **Verification Heuristics**
2705
-
2706
- - **Completeness**: Focus on objective checklist items (checkboxes, requirements list)
2707
- - **Correctness**: Use keyword search, file path analysis, reasonable inference - don't require perfect certainty
2708
- - **Coherence**: Look for glaring inconsistencies, don't nitpick style
2709
- - **False Positives**: When uncertain, prefer SUGGESTION over WARNING, WARNING over CRITICAL
2710
- - **Actionability**: Every issue must have a specific recommendation with file/line references where applicable
2711
-
2712
- **Graceful Degradation**
2713
-
2714
- - If only tasks.md exists: verify task completion only, skip spec/design checks
2715
- - If tasks + specs exist: verify completeness and correctness, skip design
2716
- - If full artifacts: verify all three dimensions
2717
- - Always note which checks were skipped and why
2718
-
2719
- **Output Format**
2720
-
2721
- Use clear markdown with:
2722
- - Table for summary scorecard
2723
- - Grouped lists for issues (CRITICAL/WARNING/SUGGESTION)
2724
- - Code references in format: \`file.ts:123\`
2725
- - Specific, actionable recommendations
2726
- - No vague suggestions like "consider reviewing"`,
2727
- license: 'MIT',
2728
- compatibility: 'Requires openspec CLI.',
2729
- metadata: { author: 'openspec', version: '1.0' },
2730
- };
2731
- }
2732
- /**
2733
- * Template for /opsx:archive slash command
2734
- */
2735
- export function getOpsxArchiveCommandTemplate() {
2736
- return {
2737
- name: 'OPSX: Archive',
2738
- description: 'Archive a completed change in the experimental workflow',
2739
- category: 'Workflow',
2740
- tags: ['workflow', 'archive', 'experimental'],
2741
- content: `Archive a completed change in the experimental workflow.
2742
-
2743
- **Input**: Optionally specify a change name after \`/opsx:archive\` (e.g., \`/opsx:archive add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
2744
-
2745
- **Steps**
2746
-
2747
- 1. **If no change name provided, prompt for selection**
2748
-
2749
- Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
2750
-
2751
- Show only active changes (not already archived).
2752
- Include the schema used for each change if available.
2753
-
2754
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
2755
-
2756
- 2. **Check artifact completion status**
2757
-
2758
- Run \`openspec status --change "<name>" --json\` to check artifact completion.
2759
-
2760
- Parse the JSON to understand:
2761
- - \`schemaName\`: The workflow being used
2762
- - \`artifacts\`: List of artifacts with their status (\`done\` or other)
2763
-
2764
- **If any artifacts are not \`done\`:**
2765
- - Display warning listing incomplete artifacts
2766
- - Prompt user for confirmation to continue
2767
- - Proceed if user confirms
2768
-
2769
- 3. **Check task completion status**
2770
-
2771
- Read the tasks file (typically \`tasks.md\`) to check for incomplete tasks.
2772
-
2773
- Count tasks marked with \`- [ ]\` (incomplete) vs \`- [x]\` (complete).
2774
-
2775
- **If incomplete tasks found:**
2776
- - Display warning showing count of incomplete tasks
2777
- - Prompt user for confirmation to continue
2778
- - Proceed if user confirms
2779
-
2780
- **If no tasks file exists:** Proceed without task-related warning.
2781
-
2782
- 4. **Assess delta spec sync state**
2783
-
2784
- Check for delta specs at \`openspec/changes/<name>/specs/\`. If none exist, proceed without sync prompt.
2785
-
2786
- **If delta specs exist:**
2787
- - Compare each delta spec with its corresponding main spec at \`openspec/specs/<capability>/spec.md\`
2788
- - Determine what changes would be applied (adds, modifications, removals, renames)
2789
- - Show a combined summary before prompting
2790
-
2791
- **Prompt options:**
2792
- - If changes needed: "Sync now (recommended)", "Archive without syncing"
2793
- - If already synced: "Archive now", "Sync anyway", "Cancel"
2794
-
2795
- If user chooses sync, execute \`/opsx:sync\` logic. Proceed to archive regardless of choice.
2796
-
2797
- 5. **Perform the archive**
2798
-
2799
- Create the archive directory if it doesn't exist:
2800
- \`\`\`bash
2801
- mkdir -p openspec/changes/archive
2802
- \`\`\`
2803
-
2804
- Generate target name using current date: \`YYYY-MM-DD-<change-name>\`
2805
-
2806
- **Check if target already exists:**
2807
- - If yes: Fail with error, suggest renaming existing archive or using different date
2808
- - If no: Move the change directory to archive
2809
-
2810
- \`\`\`bash
2811
- mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
2812
- \`\`\`
2813
-
2814
- 6. **Display summary**
2815
-
2816
- Show archive completion summary including:
2817
- - Change name
2818
- - Schema that was used
2819
- - Archive location
2820
- - Spec sync status (synced / sync skipped / no delta specs)
2821
- - Note about any warnings (incomplete artifacts/tasks)
2822
-
2823
- **Output On Success**
2824
-
2825
- \`\`\`
2826
- ## Archive Complete
2827
-
2828
- **Change:** <change-name>
2829
- **Schema:** <schema-name>
2830
- **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
2831
- **Specs:** ✓ Synced to main specs
2832
-
2833
- All artifacts complete. All tasks complete.
2834
- \`\`\`
2835
-
2836
- **Output On Success (No Delta Specs)**
2837
-
2838
- \`\`\`
2839
- ## Archive Complete
2840
-
2841
- **Change:** <change-name>
2842
- **Schema:** <schema-name>
2843
- **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
2844
- **Specs:** No delta specs
2845
-
2846
- All artifacts complete. All tasks complete.
2847
- \`\`\`
2848
-
2849
- **Output On Success With Warnings**
2850
-
2851
- \`\`\`
2852
- ## Archive Complete (with warnings)
2853
-
2854
- **Change:** <change-name>
2855
- **Schema:** <schema-name>
2856
- **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
2857
- **Specs:** Sync skipped (user chose to skip)
2858
-
2859
- **Warnings:**
2860
- - Archived with 2 incomplete artifacts
2861
- - Archived with 3 incomplete tasks
2862
- - Delta spec sync was skipped (user chose to skip)
2863
-
2864
- Review the archive if this was not intentional.
2865
- \`\`\`
2866
-
2867
- **Output On Error (Archive Exists)**
2868
-
2869
- \`\`\`
2870
- ## Archive Failed
2871
-
2872
- **Change:** <change-name>
2873
- **Target:** openspec/changes/archive/YYYY-MM-DD-<name>/
2874
-
2875
- Target archive directory already exists.
2876
-
2877
- **Options:**
2878
- 1. Rename the existing archive
2879
- 2. Delete the existing archive if it's a duplicate
2880
- 3. Wait until a different date to archive
2881
- \`\`\`
2882
-
2883
- **Guardrails**
2884
- - Always prompt for change selection if not provided
2885
- - Use artifact graph (openspec status --json) for completion checking
2886
- - Don't block archive on warnings - just inform and confirm
2887
- - Preserve .openspec.yaml when moving to archive (it moves with the directory)
2888
- - Show clear summary of what happened
2889
- - If sync is requested, use /opsx:sync approach (agent-driven)
2890
- - If delta specs exist, always run the sync assessment and show the combined summary before prompting`
2891
- };
2892
- }
2893
- /**
2894
- * Template for /opsx:onboard slash command
2895
- * Guided onboarding through the complete OpenSpec workflow
2896
- */
2897
- export function getOpsxOnboardCommandTemplate() {
2898
- return {
2899
- name: 'OPSX: Onboard',
2900
- description: 'Guided onboarding - walk through a complete OpenSpec workflow cycle with narration',
2901
- category: 'Workflow',
2902
- tags: ['workflow', 'onboarding', 'tutorial', 'learning'],
2903
- content: getOnboardInstructions(),
2904
- };
2905
- }
2906
- /**
2907
- * Template for /opsx:bulk-archive slash command
2908
- */
2909
- export function getOpsxBulkArchiveCommandTemplate() {
2910
- return {
2911
- name: 'OPSX: Bulk Archive',
2912
- description: 'Archive multiple completed changes at once',
2913
- category: 'Workflow',
2914
- tags: ['workflow', 'archive', 'experimental', 'bulk'],
2915
- content: `Archive multiple completed changes in a single operation.
2916
-
2917
- This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented.
2918
-
2919
- **Input**: None required (prompts for selection)
2920
-
2921
- **Steps**
2922
-
2923
- 1. **Get active changes**
2924
-
2925
- Run \`openspec list --json\` to get all active changes.
2926
-
2927
- If no active changes exist, inform user and stop.
2928
-
2929
- 2. **Prompt for change selection**
2930
-
2931
- Use **AskUserQuestion tool** with multi-select to let user choose changes:
2932
- - Show each change with its schema
2933
- - Include an option for "All changes"
2934
- - Allow any number of selections (1+ works, 2+ is the typical use case)
2935
-
2936
- **IMPORTANT**: Do NOT auto-select. Always let the user choose.
2937
-
2938
- 3. **Batch validation - gather status for all selected changes**
2939
-
2940
- For each selected change, collect:
2941
-
2942
- a. **Artifact status** - Run \`openspec status --change "<name>" --json\`
2943
- - Parse \`schemaName\` and \`artifacts\` list
2944
- - Note which artifacts are \`done\` vs other states
2945
-
2946
- b. **Task completion** - Read \`openspec/changes/<name>/tasks.md\`
2947
- - Count \`- [ ]\` (incomplete) vs \`- [x]\` (complete)
2948
- - If no tasks file exists, note as "No tasks"
2949
-
2950
- c. **Delta specs** - Check \`openspec/changes/<name>/specs/\` directory
2951
- - List which capability specs exist
2952
- - For each, extract requirement names (lines matching \`### Requirement: <name>\`)
2953
-
2954
- 4. **Detect spec conflicts**
2955
-
2956
- Build a map of \`capability -> [changes that touch it]\`:
2957
-
2958
- \`\`\`
2959
- auth -> [change-a, change-b] <- CONFLICT (2+ changes)
2960
- api -> [change-c] <- OK (only 1 change)
2961
- \`\`\`
2962
-
2963
- A conflict exists when 2+ selected changes have delta specs for the same capability.
2964
-
2965
- 5. **Resolve conflicts agentically**
2966
-
2967
- **For each conflict**, investigate the codebase:
2968
-
2969
- a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify
2970
-
2971
- b. **Search the codebase** for implementation evidence:
2972
- - Look for code implementing requirements from each delta spec
2973
- - Check for related files, functions, or tests
2974
-
2975
- c. **Determine resolution**:
2976
- - If only one change is actually implemented -> sync that one's specs
2977
- - If both implemented -> apply in chronological order (older first, newer overwrites)
2978
- - If neither implemented -> skip spec sync, warn user
2979
-
2980
- d. **Record resolution** for each conflict:
2981
- - Which change's specs to apply
2982
- - In what order (if both)
2983
- - Rationale (what was found in codebase)
2984
-
2985
- 6. **Show consolidated status table**
2986
-
2987
- Display a table summarizing all changes:
2988
-
2989
- \`\`\`
2990
- | Change | Artifacts | Tasks | Specs | Conflicts | Status |
2991
- |---------------------|-----------|-------|---------|-----------|--------|
2992
- | schema-management | Done | 5/5 | 2 delta | None | Ready |
2993
- | project-config | Done | 3/3 | 1 delta | None | Ready |
2994
- | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* |
2995
- | add-verify-skill | 1 left | 2/5 | None | None | Warn |
2996
- \`\`\`
2997
-
2998
- For conflicts, show the resolution:
2999
- \`\`\`
3000
- * Conflict resolution:
3001
- - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order)
3002
- \`\`\`
3003
-
3004
- For incomplete changes, show warnings:
3005
- \`\`\`
3006
- Warnings:
3007
- - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks
3008
- \`\`\`
3009
-
3010
- 7. **Confirm batch operation**
3011
-
3012
- Use **AskUserQuestion tool** with a single confirmation:
3013
-
3014
- - "Archive N changes?" with options based on status
3015
- - Options might include:
3016
- - "Archive all N changes"
3017
- - "Archive only N ready changes (skip incomplete)"
3018
- - "Cancel"
3019
-
3020
- If there are incomplete changes, make clear they'll be archived with warnings.
3021
-
3022
- 8. **Execute archive for each confirmed change**
3023
-
3024
- Process changes in the determined order (respecting conflict resolution):
3025
-
3026
- a. **Sync specs** if delta specs exist:
3027
- - Use the openspec-sync-specs approach (agent-driven intelligent merge)
3028
- - For conflicts, apply in resolved order
3029
- - Track if sync was done
3030
-
3031
- b. **Perform the archive**:
3032
- \`\`\`bash
3033
- mkdir -p openspec/changes/archive
3034
- mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
3035
- \`\`\`
3036
-
3037
- c. **Track outcome** for each change:
3038
- - Success: archived successfully
3039
- - Failed: error during archive (record error)
3040
- - Skipped: user chose not to archive (if applicable)
3041
-
3042
- 9. **Display summary**
3043
-
3044
- Show final results:
3045
-
3046
- \`\`\`
3047
- ## Bulk Archive Complete
3048
-
3049
- Archived 3 changes:
3050
- - schema-management-cli -> archive/2026-01-19-schema-management-cli/
3051
- - project-config -> archive/2026-01-19-project-config/
3052
- - add-oauth -> archive/2026-01-19-add-oauth/
3053
-
3054
- Skipped 1 change:
3055
- - add-verify-skill (user chose not to archive incomplete)
3056
-
3057
- Spec sync summary:
3058
- - 4 delta specs synced to main specs
3059
- - 1 conflict resolved (auth: applied both in chronological order)
3060
- \`\`\`
3061
-
3062
- If any failures:
3063
- \`\`\`
3064
- Failed 1 change:
3065
- - some-change: Archive directory already exists
3066
- \`\`\`
3067
-
3068
- **Conflict Resolution Examples**
3069
-
3070
- Example 1: Only one implemented
3071
- \`\`\`
3072
- Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt]
3073
-
3074
- Checking add-oauth:
3075
- - Delta adds "OAuth Provider Integration" requirement
3076
- - Searching codebase... found src/auth/oauth.ts implementing OAuth flow
3077
-
3078
- Checking add-jwt:
3079
- - Delta adds "JWT Token Handling" requirement
3080
- - Searching codebase... no JWT implementation found
3081
-
3082
- Resolution: Only add-oauth is implemented. Will sync add-oauth specs only.
3083
- \`\`\`
3084
-
3085
- Example 2: Both implemented
3086
- \`\`\`
3087
- Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql]
3088
-
3089
- Checking add-rest-api (created 2026-01-10):
3090
- - Delta adds "REST Endpoints" requirement
3091
- - Searching codebase... found src/api/rest.ts
3092
-
3093
- Checking add-graphql (created 2026-01-15):
3094
- - Delta adds "GraphQL Schema" requirement
3095
- - Searching codebase... found src/api/graphql.ts
3096
-
3097
- Resolution: Both implemented. Will apply add-rest-api specs first,
3098
- then add-graphql specs (chronological order, newer takes precedence).
3099
- \`\`\`
3100
-
3101
- **Output On Success**
3102
-
3103
- \`\`\`
3104
- ## Bulk Archive Complete
3105
-
3106
- Archived N changes:
3107
- - <change-1> -> archive/YYYY-MM-DD-<change-1>/
3108
- - <change-2> -> archive/YYYY-MM-DD-<change-2>/
3109
-
3110
- Spec sync summary:
3111
- - N delta specs synced to main specs
3112
- - No conflicts (or: M conflicts resolved)
3113
- \`\`\`
3114
-
3115
- **Output On Partial Success**
3116
-
3117
- \`\`\`
3118
- ## Bulk Archive Complete (partial)
3119
-
3120
- Archived N changes:
3121
- - <change-1> -> archive/YYYY-MM-DD-<change-1>/
3122
-
3123
- Skipped M changes:
3124
- - <change-2> (user chose not to archive incomplete)
3125
-
3126
- Failed K changes:
3127
- - <change-3>: Archive directory already exists
3128
- \`\`\`
3129
-
3130
- **Output When No Changes**
3131
-
3132
- \`\`\`
3133
- ## No Changes to Archive
3134
-
3135
- No active changes found. Use \`/opsx:new\` to create a new change.
3136
- \`\`\`
3137
-
3138
- **Guardrails**
3139
- - Allow any number of changes (1+ is fine, 2+ is the typical use case)
3140
- - Always prompt for selection, never auto-select
3141
- - Detect spec conflicts early and resolve by checking codebase
3142
- - When both changes are implemented, apply specs in chronological order
3143
- - Skip spec sync only when implementation is missing (warn user)
3144
- - Show clear per-change status before confirming
3145
- - Use single confirmation for entire batch
3146
- - Track and report all outcomes (success/skip/fail)
3147
- - Preserve .openspec.yaml when moving to archive
3148
- - Archive directory target uses current date: YYYY-MM-DD-<name>
3149
- - If archive target exists, fail that change but continue with others`
3150
- };
3151
- }
3152
- /**
3153
- * Template for /opsx:verify slash command
3154
- */
3155
- export function getOpsxVerifyCommandTemplate() {
3156
- return {
3157
- name: 'OPSX: Verify',
3158
- description: 'Verify implementation matches change artifacts before archiving',
3159
- category: 'Workflow',
3160
- tags: ['workflow', 'verify', 'experimental'],
3161
- content: `Verify that an implementation matches the change artifacts (specs, tasks, design).
3162
-
3163
- **Input**: Optionally specify a change name after \`/opsx:verify\` (e.g., \`/opsx:verify add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
3164
-
3165
- **Steps**
3166
-
3167
- 1. **If no change name provided, prompt for selection**
3168
-
3169
- Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
3170
-
3171
- Show changes that have implementation tasks (tasks artifact exists).
3172
- Include the schema used for each change if available.
3173
- Mark changes with incomplete tasks as "(In Progress)".
3174
-
3175
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
3176
-
3177
- 2. **Check status to understand the schema**
3178
- \`\`\`bash
3179
- openspec status --change "<name>" --json
3180
- \`\`\`
3181
- Parse the JSON to understand:
3182
- - \`schemaName\`: The workflow being used (e.g., "spec-driven")
3183
- - Which artifacts exist for this change
3184
-
3185
- 3. **Get the change directory and load artifacts**
3186
-
3187
- \`\`\`bash
3188
- openspec instructions apply --change "<name>" --json
3189
- \`\`\`
3190
-
3191
- This returns the change directory and context files. Read all available artifacts from \`contextFiles\`.
3192
-
3193
- 4. **Initialize verification report structure**
3194
-
3195
- Create a report structure with three dimensions:
3196
- - **Completeness**: Track tasks and spec coverage
3197
- - **Correctness**: Track requirement implementation and scenario coverage
3198
- - **Coherence**: Track design adherence and pattern consistency
3199
-
3200
- Each dimension can have CRITICAL, WARNING, or SUGGESTION issues.
3201
-
3202
- 5. **Verify Completeness**
3203
-
3204
- **Task Completion**:
3205
- - If tasks.md exists in contextFiles, read it
3206
- - Parse checkboxes: \`- [ ]\` (incomplete) vs \`- [x]\` (complete)
3207
- - Count complete vs total tasks
3208
- - If incomplete tasks exist:
3209
- - Add CRITICAL issue for each incomplete task
3210
- - Recommendation: "Complete task: <description>" or "Mark as done if already implemented"
3211
-
3212
- **Spec Coverage**:
3213
- - If delta specs exist in \`openspec/changes/<name>/specs/\`:
3214
- - Extract all requirements (marked with "### Requirement:")
3215
- - For each requirement:
3216
- - Search codebase for keywords related to the requirement
3217
- - Assess if implementation likely exists
3218
- - If requirements appear unimplemented:
3219
- - Add CRITICAL issue: "Requirement not found: <requirement name>"
3220
- - Recommendation: "Implement requirement X: <description>"
3221
-
3222
- 6. **Verify Correctness**
3223
-
3224
- **Requirement Implementation Mapping**:
3225
- - For each requirement from delta specs:
3226
- - Search codebase for implementation evidence
3227
- - If found, note file paths and line ranges
3228
- - Assess if implementation matches requirement intent
3229
- - If divergence detected:
3230
- - Add WARNING: "Implementation may diverge from spec: <details>"
3231
- - Recommendation: "Review <file>:<lines> against requirement X"
3232
-
3233
- **Scenario Coverage**:
3234
- - For each scenario in delta specs (marked with "#### Scenario:"):
3235
- - Check if conditions are handled in code
3236
- - Check if tests exist covering the scenario
3237
- - If scenario appears uncovered:
3238
- - Add WARNING: "Scenario not covered: <scenario name>"
3239
- - Recommendation: "Add test or implementation for scenario: <description>"
3240
-
3241
- 7. **Verify Coherence**
3242
-
3243
- **Design Adherence**:
3244
- - If design.md exists in contextFiles:
3245
- - Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:")
3246
- - Verify implementation follows those decisions
3247
- - If contradiction detected:
3248
- - Add WARNING: "Design decision not followed: <decision>"
3249
- - Recommendation: "Update implementation or revise design.md to match reality"
3250
- - If no design.md: Skip design adherence check, note "No design.md to verify against"
3251
-
3252
- **Code Pattern Consistency**:
3253
- - Review new code for consistency with project patterns
3254
- - Check file naming, directory structure, coding style
3255
- - If significant deviations found:
3256
- - Add SUGGESTION: "Code pattern deviation: <details>"
3257
- - Recommendation: "Consider following project pattern: <example>"
3258
-
3259
- 8. **Generate Verification Report**
3260
-
3261
- **Summary Scorecard**:
3262
- \`\`\`
3263
- ## Verification Report: <change-name>
3264
-
3265
- ### Summary
3266
- | Dimension | Status |
3267
- |--------------|------------------|
3268
- | Completeness | X/Y tasks, N reqs|
3269
- | Correctness | M/N reqs covered |
3270
- | Coherence | Followed/Issues |
3271
- \`\`\`
3272
-
3273
- **Issues by Priority**:
3274
-
3275
- 1. **CRITICAL** (Must fix before archive):
3276
- - Incomplete tasks
3277
- - Missing requirement implementations
3278
- - Each with specific, actionable recommendation
3279
-
3280
- 2. **WARNING** (Should fix):
3281
- - Spec/design divergences
3282
- - Missing scenario coverage
3283
- - Each with specific recommendation
3284
-
3285
- 3. **SUGGESTION** (Nice to fix):
3286
- - Pattern inconsistencies
3287
- - Minor improvements
3288
- - Each with specific recommendation
3289
-
3290
- **Final Assessment**:
3291
- - If CRITICAL issues: "X critical issue(s) found. Fix before archiving."
3292
- - If only warnings: "No critical issues. Y warning(s) to consider. Ready for archive (with noted improvements)."
3293
- - If all clear: "All checks passed. Ready for archive."
3294
-
3295
- **Verification Heuristics**
3296
-
3297
- - **Completeness**: Focus on objective checklist items (checkboxes, requirements list)
3298
- - **Correctness**: Use keyword search, file path analysis, reasonable inference - don't require perfect certainty
3299
- - **Coherence**: Look for glaring inconsistencies, don't nitpick style
3300
- - **False Positives**: When uncertain, prefer SUGGESTION over WARNING, WARNING over CRITICAL
3301
- - **Actionability**: Every issue must have a specific recommendation with file/line references where applicable
3302
-
3303
- **Graceful Degradation**
3304
-
3305
- - If only tasks.md exists: verify task completion only, skip spec/design checks
3306
- - If tasks + specs exist: verify completeness and correctness, skip design
3307
- - If full artifacts: verify all three dimensions
3308
- - Always note which checks were skipped and why
3309
-
3310
- **Output Format**
3311
-
3312
- Use clear markdown with:
3313
- - Table for summary scorecard
3314
- - Grouped lists for issues (CRITICAL/WARNING/SUGGESTION)
3315
- - Code references in format: \`file.ts:123\`
3316
- - Specific, actionable recommendations
3317
- - No vague suggestions like "consider reviewing"`
3318
- };
3319
- }
3320
- /**
3321
- * Template for feedback skill
3322
- * For collecting and submitting user feedback with context enrichment
3323
- */
3324
- export function getFeedbackSkillTemplate() {
3325
- return {
3326
- name: 'feedback',
3327
- description: 'Collect and submit user feedback about OpenSpec with context enrichment and anonymization.',
3328
- instructions: `Help the user submit feedback about OpenSpec.
3329
-
3330
- **Goal**: Guide the user through collecting, enriching, and submitting feedback while ensuring privacy through anonymization.
3331
-
3332
- **Process**
3333
-
3334
- 1. **Gather context from the conversation**
3335
- - Review recent conversation history for context
3336
- - Identify what task was being performed
3337
- - Note what worked well or poorly
3338
- - Capture specific friction points or praise
3339
-
3340
- 2. **Draft enriched feedback**
3341
- - Create a clear, descriptive title (single sentence, no "Feedback:" prefix needed)
3342
- - Write a body that includes:
3343
- - What the user was trying to do
3344
- - What happened (good or bad)
3345
- - Relevant context from the conversation
3346
- - Any specific suggestions or requests
3347
-
3348
- 3. **Anonymize sensitive information**
3349
- - Replace file paths with \`<path>\` or generic descriptions
3350
- - Replace API keys, tokens, secrets with \`<redacted>\`
3351
- - Replace company/organization names with \`<company>\`
3352
- - Replace personal names with \`<user>\`
3353
- - Replace specific URLs with \`<url>\` unless public/relevant
3354
- - Keep technical details that help understand the issue
3355
-
3356
- 4. **Present draft for approval**
3357
- - Show the complete draft to the user
3358
- - Display both title and body clearly
3359
- - Ask for explicit approval before submitting
3360
- - Allow the user to request modifications
3361
-
3362
- 5. **Submit on confirmation**
3363
- - Use the \`openspec feedback\` command to submit
3364
- - Format: \`openspec feedback "title" --body "body content"\`
3365
- - The command will automatically add metadata (version, platform, timestamp)
3366
-
3367
- **Example Draft**
3368
-
3369
- \`\`\`
3370
- Title: Error handling in artifact workflow needs improvement
3371
-
3372
- Body:
3373
- I was working on creating a new change and encountered an issue with
3374
- the artifact workflow. When I tried to continue after creating the
3375
- proposal, the system didn't clearly indicate that I needed to complete
3376
- the specs first.
3377
-
3378
- Suggestion: Add clearer error messages that explain dependency chains
3379
- in the artifact workflow. Something like "Cannot create design.md
3380
- because specs are not complete (0/2 done)."
3381
-
3382
- Context: Using the spec-driven schema with <path>/my-project
3383
- \`\`\`
3384
-
3385
- **Anonymization Examples**
3386
-
3387
- Before:
3388
- \`\`\`
3389
- Working on /Users/john/mycompany/auth-service/src/oauth.ts
3390
- Failed with API key: sk_live_abc123xyz
3391
- Working at Acme Corp
3392
- \`\`\`
3393
-
3394
- After:
3395
- \`\`\`
3396
- Working on <path>/oauth.ts
3397
- Failed with API key: <redacted>
3398
- Working at <company>
3399
- \`\`\`
3400
-
3401
- **Guardrails**
3402
-
3403
- - MUST show complete draft before submitting
3404
- - MUST ask for explicit approval
3405
- - MUST anonymize sensitive information
3406
- - ALLOW user to modify draft before submitting
3407
- - DO NOT submit without user confirmation
3408
- - DO include relevant technical context
3409
- - DO keep conversation-specific insights
3410
-
3411
- **User Confirmation Required**
3412
-
3413
- Always ask:
3414
- \`\`\`
3415
- Here's the feedback I've drafted:
3416
-
3417
- Title: [title]
3418
-
3419
- Body:
3420
- [body]
3421
-
3422
- Does this look good? I can modify it if you'd like, or submit it as-is.
3423
- \`\`\`
3424
-
3425
- Only proceed with submission after user confirms.`
3426
- };
3427
- }
4
+ * Compatibility facade that re-exports split workflow template modules.
5
+ */
6
+ export { getExploreSkillTemplate, getOpsxExploreCommandTemplate } from './workflows/explore.js';
7
+ export { getNewChangeSkillTemplate, getOpsxNewCommandTemplate } from './workflows/new-change.js';
8
+ export { getContinueChangeSkillTemplate, getOpsxContinueCommandTemplate } from './workflows/continue-change.js';
9
+ export { getApplyChangeSkillTemplate, getOpsxApplyCommandTemplate } from './workflows/apply-change.js';
10
+ export { getFfChangeSkillTemplate, getOpsxFfCommandTemplate } from './workflows/ff-change.js';
11
+ export { getSyncSpecsSkillTemplate, getOpsxSyncCommandTemplate } from './workflows/sync-specs.js';
12
+ export { getArchiveChangeSkillTemplate, getOpsxArchiveCommandTemplate } from './workflows/archive-change.js';
13
+ export { getBulkArchiveChangeSkillTemplate, getOpsxBulkArchiveCommandTemplate } from './workflows/bulk-archive-change.js';
14
+ export { getVerifyChangeSkillTemplate, getOpsxVerifyCommandTemplate } from './workflows/verify-change.js';
15
+ export { getOnboardSkillTemplate, getOpsxOnboardCommandTemplate } from './workflows/onboard.js';
16
+ export { getOpsxProposeSkillTemplate, getOpsxProposeCommandTemplate } from './workflows/propose.js';
17
+ export { getFeedbackSkillTemplate } from './workflows/feedback.js';
3428
18
  //# sourceMappingURL=skill-templates.js.map