aboutsummaryrefslogtreecommitdiffstats
path: root/.claude/commands/opsx/apply.md
diff options
context:
space:
mode:
Diffstat (limited to '.claude/commands/opsx/apply.md')
-rw-r--r--.claude/commands/opsx/apply.md184
1 files changed, 184 insertions, 0 deletions
diff --git a/.claude/commands/opsx/apply.md b/.claude/commands/opsx/apply.md
new file mode 100644
index 0000000..731c789
--- /dev/null
+++ b/.claude/commands/opsx/apply.md
@@ -0,0 +1,184 @@
1---
2name: "OPSX: Apply"
3description: "Implement tasks from an OpenSpec change (Experimental)"
4allowed-tools: Bash(openspec:*)
5category: "Workflow"
6tags: ["workflow", "artifacts", "experimental"]
7---
8
9Implement 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
171. **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
262. **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
353. **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
694. **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
795. **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
876. **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
1037. **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
116Working on task 3/7: <task description>
117[...implementation happening...]
118✓ Task complete
119
120Working 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
139All 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:**
1551. <option 1>
1562. <option 2>
1573. Other approach
158
159What 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
181This 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