|
| 1 | +--- |
| 2 | +name: "OPSX: Apply" |
| 3 | +description: "Implement tasks from an OpenSpec change (Experimental)" |
| 4 | +allowed-tools: Bash(openspec:*) |
| 5 | +category: "Workflow" |
| 6 | +tags: ["workflow", "artifacts", "experimental"] |
| 7 | +--- |
| 8 | + |
| 9 | +Implement tasks from an OpenSpec change. |
| 10 | + |
| 11 | +**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `schemas`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root. |
| 12 | + |
| 13 | +**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. |
| 14 | + |
| 15 | +**Steps** |
| 16 | + |
| 17 | +1. **Select the change** |
| 18 | + |
| 19 | + If a name is provided, use it. Otherwise: |
| 20 | + - Infer from conversation context if the user mentioned a change |
| 21 | + - Auto-select if only one active change exists |
| 22 | + - If ambiguous, run `openspec list --json` to get available changes and ask the user to select one |
| 23 | + |
| 24 | + Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`). |
| 25 | + |
| 26 | +2. **Check status to understand the schema** |
| 27 | + ```bash |
| 28 | + openspec status --change "<name>" --json |
| 29 | + ``` |
| 30 | + Parse the JSON to understand: |
| 31 | + - `schemaName`: The workflow being used (e.g., "spec-driven") |
| 32 | + - `planningHome`, `changeRoot`, and `actionContext`: planning scope and edit constraints |
| 33 | + - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others) |
| 34 | + |
| 35 | +3. **Get apply instructions** |
| 36 | + |
| 37 | + ```bash |
| 38 | + openspec instructions apply --change "<name>" --json |
| 39 | + ``` |
| 40 | + |
| 41 | + This returns: |
| 42 | + - `contextFiles`: artifact ID -> array of concrete file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs) |
| 43 | + - Progress (total, complete, remaining) |
| 44 | + - Task list with status |
| 45 | + - Dynamic instruction based on current state |
| 46 | + - Optional `context`: current required project instruction input from the selected root |
| 47 | + - Optional `operationGuidance`: current advisory guidance for apply |
| 48 | + |
| 49 | + **Handle states:** |
| 50 | + - If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue` (if it is not installed, run `openspec status --change "<name>" --json` to see the next artifact and `openspec instructions <artifact-id> --change "<name>" --json` for how to create it) |
| 51 | + - If `state: "all_done"`: congratulate, suggest archive |
| 52 | + - Otherwise: proceed to implementation |
| 53 | + |
| 54 | + Treat `context` as a required prompt-level input. Read and consider it, and |
| 55 | + apply relevant project facts, conventions, and constraints while implementing. |
| 56 | + Treat `operationGuidance` as optional additive advice. Read and consider every |
| 57 | + entry, and follow entries that are applicable and compatible with the built-in |
| 58 | + workflow. |
| 59 | + |
| 60 | + Keep both fields separate from CLI-returned state, missing artifacts, tasks, |
| 61 | + progress, `contextFiles`, and the built-in `instruction`. They are not |
| 62 | + evidence of task completion, do not replace the built-in instruction, and do |
| 63 | + not permit bypassing a blocked state. If context conflicts with the built-in |
| 64 | + instruction, an explicit user choice, or a CLI-controlled value, report the |
| 65 | + conflict and preserve the controlling value. If guidance is inapplicable or |
| 66 | + conflicts with those controlling inputs, do not follow it and explain why. |
| 67 | + These are prompt-level behavior contracts, not enforceable checks. |
| 68 | + |
| 69 | +4. **Read context files** |
| 70 | + |
| 71 | + Read every file path listed under `contextFiles` from the apply instructions output. |
| 72 | + The files depend on the schema being used: |
| 73 | + - **spec-driven**: proposal, specs, design, tasks |
| 74 | + - Other schemas: follow the contextFiles from CLI output |
| 75 | + |
| 76 | + Do not copy `context` or `operationGuidance` verbatim into implementation |
| 77 | + files or planning artifacts unless the user separately asks for that content. |
| 78 | + |
| 79 | +5. **Show current progress** |
| 80 | + |
| 81 | + Display: |
| 82 | + - Schema being used |
| 83 | + - Progress: "N/M tasks complete" |
| 84 | + - Remaining tasks overview |
| 85 | + - Dynamic instruction from CLI |
| 86 | + |
| 87 | +6. **Implement tasks (loop until done or blocked)** |
| 88 | + |
| 89 | + For each pending task: |
| 90 | + - Show which task is being worked on |
| 91 | + - Make the code changes required |
| 92 | + - Keep changes minimal and focused |
| 93 | + - Mark task complete in the tasks file: `- [ ]` → `- [x]` |
| 94 | + - Continue to next task |
| 95 | + |
| 96 | + **Pause if:** |
| 97 | + - Task is unclear → ask for clarification |
| 98 | + - Implementation reveals a design issue → suggest updating artifacts |
| 99 | + - A task needs work beyond what the spec and tasks describe, or you are tempted to drop, narrow, defer, or accept exceptions to specified behavior to make it fit → surface the added scope and ask; do not absorb it silently |
| 100 | + - Error or blocker encountered → report and wait for guidance |
| 101 | + - User interrupts |
| 102 | + |
| 103 | +7. **On completion or pause, show status** |
| 104 | + |
| 105 | + Display: |
| 106 | + - Tasks completed this session |
| 107 | + - Overall progress: "N/M tasks complete" |
| 108 | + - If all done: suggest archive |
| 109 | + - If paused: explain why and wait for guidance |
| 110 | + |
| 111 | +**Output During Implementation** |
| 112 | + |
| 113 | +``` |
| 114 | +## Implementing: <change-name> (schema: <schema-name>) |
| 115 | +
|
| 116 | +Working on task 3/7: <task description> |
| 117 | +[...implementation happening...] |
| 118 | +✓ Task complete |
| 119 | +
|
| 120 | +Working on task 4/7: <task description> |
| 121 | +[...implementation happening...] |
| 122 | +✓ Task complete |
| 123 | +``` |
| 124 | + |
| 125 | +**Output On Completion** |
| 126 | + |
| 127 | +``` |
| 128 | +## Implementation Complete |
| 129 | +
|
| 130 | +**Change:** <change-name> |
| 131 | +**Schema:** <schema-name> |
| 132 | +**Progress:** 7/7 tasks complete ✓ |
| 133 | +
|
| 134 | +### Completed This Session |
| 135 | +- [x] Task 1 |
| 136 | +- [x] Task 2 |
| 137 | +... |
| 138 | +
|
| 139 | +All tasks complete! You can archive this change with `/opsx:archive`. |
| 140 | +``` |
| 141 | + |
| 142 | +**Output On Pause (Issue Encountered)** |
| 143 | + |
| 144 | +``` |
| 145 | +## Implementation Paused |
| 146 | +
|
| 147 | +**Change:** <change-name> |
| 148 | +**Schema:** <schema-name> |
| 149 | +**Progress:** 4/7 tasks complete |
| 150 | +
|
| 151 | +### Issue Encountered |
| 152 | +<description of the issue> |
| 153 | +
|
| 154 | +**Options:** |
| 155 | +1. <option 1> |
| 156 | +2. <option 2> |
| 157 | +3. Other approach |
| 158 | +
|
| 159 | +What would you like to do? |
| 160 | +``` |
| 161 | + |
| 162 | +**Guardrails** |
| 163 | +- Keep going through tasks until done or blocked |
| 164 | +- Always read context files before starting (from the apply instructions output) |
| 165 | +- If task is ambiguous, pause and ask before implementing |
| 166 | +- If implementation reveals issues, pause and suggest artifact updates |
| 167 | +- Keep code changes minimal and scoped to each task |
| 168 | +- Update task checkbox immediately after completing each task |
| 169 | +- Pause on errors, blockers, or unclear requirements - don't guess |
| 170 | +- When a task needs work beyond what the spec describes, surface the added scope and pause - never silently narrow, defer, or simplify away specified behavior |
| 171 | +- Only mark a task `- [x]` when its specified behavior is fully implemented, not when it is partially done or deferred |
| 172 | +- Use contextFiles from CLI output, don't assume specific file names |
| 173 | +- Do not use context or operation guidance as proof that a task is complete |
| 174 | +- Apply relevant project context; report conflicts with controlling workflow inputs |
| 175 | +- Consider every guidance entry; explain any inapplicable or conflicting advice |
| 176 | +- Do not copy runtime context or operation guidance into implementation files or planning artifacts |
| 177 | +- Preserve CLI-controlled blocked/ready/all-done behavior and completion criteria |
| 178 | + |
| 179 | +**Fluid Workflow Integration** |
| 180 | + |
| 181 | +This skill supports the "actions on a change" model: |
| 182 | + |
| 183 | +- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions |
| 184 | +- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly |
0 commit comments