@brunosps00/dev-workflow 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,374 +1,255 @@
1
1
  <system_instructions>
2
- You are a full pipeline orchestrator. This command receives a user's wish and automatically executes the entire development flow, from research to commit, stopping only at critical gates.
3
-
4
- <critical>This command MUST execute ALL applicable pipeline steps. Do NOT skip any step. If a step is conditional, evaluate the condition and execute if applicable.</critical>
5
- <critical>The ONLY pause moments are the 3 gates defined below. Between gates, execute everything automatically without asking for confirmation.</critical>
6
- <critical>Each step MUST follow the complete instructions from the corresponding command in `.dw/commands/`. Read and execute the full command, not a summarized version.</critical>
7
-
8
- <critical>FORMAL EXECUTION IS MANDATORY — READ BEFORE STARTING:
9
- A step that invokes a `/dw-xxx` command is ONLY considered complete when the artifacts produced by that command exist on disk. Manual validations (running tests, opening Playwright ad-hoc, eyeballing the code, writing a short qa-report by hand) DO NOT replace formal execution of the command.
10
- - BEFORE each step: announce to the user `→ Invoking /dw-[name] — executing full instructions`.
11
- - DURING: follow the instructions in `.dw/commands/[name].md` in full, without summarizing or substituting.
12
- - AFTER: run `ls` on the artifact paths listed in that step and confirm they exist before updating `autopilot-state.json`. If any artifact is missing, the step did NOT run — re-execute the command formally.</critical>
13
-
14
- <critical>FORBIDDEN RATIONALIZATIONS — if you think any of these, STOP and execute the command formally:
15
- | Thought | Reality |
16
- |---------|---------|
17
- | "I already ran the tests manually" | The command produces structured artifacts. Run the command. |
18
- | "I validated via ad-hoc Playwright" | `/dw-qa` requires RF matrix, bugs.md, screenshots, scripts, logs, checklist. Run the command. |
19
- | "The implementation is obviously correct" | `/dw-review --coverage-only` requires a compliance matrix per RF/endpoint/task. Run the command. |
20
- | "A strong manual validation is enough" | NO. Technical equivalence DOES NOT replace formal execution. |
21
- | "I already checked build and lint, that's enough" | Build/lint DO NOT replace review nor QA. Run the commands. |
22
- | "I wrote a summarized qa-report.md by hand" | A loose file IS NOT execution of `/dw-qa`. The full `QA/` tree is mandatory. |
23
- | "The autopilot already advanced, I don't need to go back" | If the artifact doesn't exist, the step didn't run. Go back and execute. |
24
- | "I fixed bugs along the way, so QA is already ok" | Fixing bugs does not replace running formal QA. Run `/dw-qa`. |</critical>
2
+ You are the full pipeline orchestrator. This command receives a user's wish and drives the PRD-to-PR workflow in two invocations:
3
+
4
+ 1. **Planning invocation:** research/brainstorm when needed, PRD, TechSpec, Tasks, then STOP.
5
+ 2. **Execution invocation:** resume from `autopilot-state.json`, run `/dw-goal --from-autopilot <prd-slug>`, then commit and PR gate.
6
+
7
+ <critical>The first invocation MUST stop after the planning artifacts are complete. Do not run implementation, QA, review, commit, or PR in the first invocation.</critical>
8
+ <critical>The second invocation MUST resume from the saved state and delegate Run → Review → QA/Fix → Review to `/dw-goal --from-autopilot <prd-slug>`.</critical>
9
+ <critical>Each step that invokes a `/dw-*` command MUST follow the complete instructions from `.dw/commands/`. Read and execute the full command, not a summarized version.</critical>
25
10
 
26
11
  ## When to Use
27
- - Use when you want to go from an idea to a PR with minimal manual intervention
28
- - Use for complete features that go through the entire pipeline (research, planning, execution, quality)
29
- - Do NOT use for small, well-scoped one-off tasks — use `/dw-run` directly with a quick PRD instead
30
- - Do NOT use to fix bugs (use `/dw-bugfix`)
31
- - Do NOT use when you want manual control between each phase (use individual commands)
12
+ - Use when you want to go from an idea to a PR with minimal manual intervention but a hard planning stop.
13
+ - Use for complete features that require planning, execution, quality gates, and PR readiness.
14
+ - Do NOT use for small, well-scoped one-off tasks; use `/dw-run` with an existing plan.
15
+ - Do NOT use for surgical bug fixes; use `/dw-bugfix`.
16
+ - Do NOT use when the user wants manual control between every phase; use individual commands.
32
17
 
33
18
  ## Pipeline Position
34
- **Predecessor:** (user's wish) | **Successor:** (PR merge)
19
+ **Predecessor:** user wish | **Successor:** `/dw-goal`, `/dw-commit`, `/dw-generate-pr`
35
20
 
36
- ## Complementary Skills
21
+ ## Complementary Skills / Commands
37
22
 
38
- | Skill | Trigger |
39
- |-------|---------|
40
- | `dw-memory` | **ALWAYS** — the memory thread runs through every phase (brainstorm -> PRD -> techspec -> tasks -> execution -> QA -> review -> PR). Decisions at one gate feed context into the next. |
41
- | `dw-verify` | **ALWAYS** — invoked at each gate (PRD, Tasks, PR) before asking user approval; and before the final commit + push. |
23
+ | Skill or command | Trigger |
24
+ |------------------|---------|
25
+ | `dw-memory` | ALWAYS — preserve decisions across planning, goal execution, QA, review, and PR. |
26
+ | `dw-verify` | ALWAYS — invoked by gates and downstream commands before approval/commit/PR claims. |
27
+ | `/dw-goal` | ALWAYS on the second invocation — durable execution-quality objective. |
42
28
 
43
29
  ## Input Variables
44
30
 
45
31
  | Variable | Description | Example |
46
32
  |----------|-------------|---------|
47
- | `{{WISH}}` | Description of what the user wants to build (default mode) | "push notification system with per-channel preferences" |
48
- | `{{PRD_SLUG}}` | Existing PRD slug to autopilot from (when `--from-prd` is used) | `prd-bugfix-stripe-webhook-retry` |
49
- | `{{MODE}}` | Optional invocation flag | `--from-prd <slug>` |
33
+ | `{{WISH}}` | Description of what the user wants to build in default mode. | `"push notification preferences"` |
34
+ | `{{PRD_SLUG}}` | Existing PRD slug when `--from-prd` is used. | `prd-bugfix-stripe-webhook-retry` |
35
+ | `{{MODE}}` | Optional invocation flag. | `--from-prd <slug>` |
50
36
 
51
37
  ## Invocation Modes
52
38
 
53
39
  | Invocation | Behavior |
54
40
  |------------|----------|
55
- | `/dw-autopilot "<wish>"` | **Default.** Full pipeline from scratch: Codebase Intelligence → Research → Brainstorm → PRD → TechSpec → Tasks → Run → QA → Review → Commit → PR. |
56
- | `/dw-autopilot --from-prd <slug>` | **Resume-from-PRD mode.** Skips Steps 1–4 (Intel, Research, Brainstorm, PRD). Starts at GATE 1 (presents the existing PRD for approval), then continues through TechSpec → Tasks → Run → QA → Review → Commit → PR. Used when `/dw-bugfix` has escalated via its safety valve and written a PRD to `.dw/spec/<slug>/`, or when the user previously authored a PRD by hand and wants the rest automated. |
41
+ | `/dw-autopilot "<wish>"` | Planning invocation from scratch. Runs Codebase Intelligence → optional Research → Brainstorm → PRD → TechSpec → Tasks, writes state, then stops. |
42
+ | `/dw-autopilot --from-prd <slug>` | Planning invocation from an existing PRD. Starts at PRD approval, then TechSpec → Tasks, writes state, then stops. |
43
+ | `/dw-autopilot` on a PRD with `autopilot-state.json status=plan_complete` | Execution invocation. Runs `/dw-goal --from-autopilot <slug>`, then commit and PR gate. |
57
44
 
58
- ## Approval Gates
45
+ ## Required Pause Points
59
46
 
60
- The autopilot stops ONLY at these 3 moments:
47
+ Autopilot pauses at:
61
48
 
62
- 1. **GATE 1 — PRD**: Presents the generated PRD (default mode) or the existing PRD (--from-prd mode) and awaits user approval before generating techspec/tasks
63
- 2. **GATE 2 — Tasks**: Presents the task list and awaits approval before starting execution
64
- 3. **GATE 3 — PR**: After automatic commit, asks if the user wants to generate the Pull Request
49
+ 1. **PRD approval** before TechSpec.
50
+ 2. **Tasks approval** before marking planning complete.
51
+ 3. **Mandatory planning stop** after Tasks are approved and state is saved.
52
+ 4. **PR gate** after the execution goal and commit complete.
65
53
 
66
- ## Session Resumption
54
+ Between these points, execute automatically while still respecting blocking questions required by the underlying command.
67
55
 
68
- If this command is re-invoked on the same PRD after interruption:
69
-
70
- <critical>Read the `autopilot-state.json` file in the PRD directory. Skip ALL steps listed in `completed_steps`. Resume execution from `current_step`. Gates already passed (listed in `gates_passed`) MUST NOT be re-presented.</critical>
56
+ ## Session Resumption
71
57
 
72
- 1. Read `.dw/spec/prd-[name]/autopilot-state.json`
73
- 2. Report: "Resuming autopilot from step [N] ([name]). Steps 1-[N-1] already completed."
74
- 3. Continue execution normally from the indicated step
58
+ If this command is re-invoked on the same PRD:
75
59
 
76
- ## Full Pipeline
60
+ <critical>Read `.dw/spec/<prd-slug>/autopilot-state.json` first. If `status` is `plan_complete`, do not repeat planning. Start the execution invocation by formally invoking `/dw-goal --from-autopilot <prd-slug>`.</critical>
77
61
 
78
- ### Step 0: Resolve invocation mode (MANDATORY first action)
62
+ State meanings:
79
63
 
80
- Before Step 1, decide which mode is in effect:
64
+ | Status | Action |
65
+ |--------|--------|
66
+ | missing state | Start normal planning invocation. |
67
+ | `planning` | Resume from `current_step`, respecting completed/skipped steps. |
68
+ | `plan_complete` | Start execution invocation via `/dw-goal --from-autopilot <prd-slug>`. |
69
+ | `goal_active` | Continue `/dw-goal resume` or `/dw-goal --from-autopilot <prd-slug>` according to `.dw/goals/autopilot-<prd-slug>/status.json`. |
70
+ | `goal_complete` | Continue to commit and PR gate. |
71
+ | `completed` | Report already completed and show PR/commit summary if available. |
81
72
 
82
- 1. **If `--from-prd <slug>` is present in the invocation:**
83
- - Resolve `{{PRD_SLUG}}` to `.dw/spec/<slug>/`.
84
- - Verify the directory exists and contains a `prd.md`. If either is missing, STOP and report: `--from-prd target .dw/spec/<slug>/prd.md not found. Run /dw-plan prd or fix the slug.`
85
- - Check whether `.dw/bugfixes/*/escalated.md` references this slug. If yes, note in the progress block: `Resuming from bugfix escalation: <NNN-bugfix-slug> → <slug>`.
86
- - Set `mode: "from-prd"` in `autopilot-state.json` and `skipped_steps: [1, 2, 3, 4]` with `skip_reason: "from-prd-mode"`.
87
- - Jump directly to **GATE 1** (PRD approval) using the existing `prd.md`.
73
+ ## Planning Invocation
88
74
 
89
- 2. **Otherwise (default mode):**
90
- - Set `mode: "autopilot"` and proceed to Step 1 normally.
75
+ ### Step 0: Resolve Invocation Mode
91
76
 
92
- <critical>In `--from-prd` mode, Steps 1–4 MUST be marked as `skipped_steps` with `skip_reason: "from-prd-mode"`. The pre-commit audit (Step 14) MUST honor this — a skipped step is not the same as a missing step.</critical>
77
+ 1. If `--from-prd <slug>` is present:
78
+ - Resolve to `.dw/spec/<slug>/`.
79
+ - Verify `prd.md` exists; otherwise STOP with: `--from-prd target .dw/spec/<slug>/prd.md not found. Run /dw-plan prd or fix the slug.`
80
+ - Create or update `autopilot-state.json` with `mode: "from-prd"`, `status: "planning"`, `skipped_steps: [1,2,3,4]`, and `skip_reasons["1-4"] = "from-prd-mode"`.
81
+ - Jump to PRD approval using the existing PRD.
82
+ 2. Otherwise:
83
+ - Create or update `autopilot-state.json` with `mode: "autopilot"`, `status: "planning"`, original wish, and `current_step: 1`.
93
84
 
94
85
  ### Step 1: Codebase Intelligence
95
86
 
96
- <critical>If `.dw/intel/` exists, querying it via `/dw-intel` is MANDATORY before starting. Falls back to `.dw/rules/` and direct grep if absent.</critical>
87
+ <critical>If `.dw/intel/` exists, query it via `/dw-intel` before planning. Fall back to `.dw/rules/` and direct grep if absent.</critical>
97
88
 
98
- - Query `.dw/intel/` via `/dw-intel` to understand project context
99
- - Identify: tech stack, existing patterns, related features
100
- - If `.dw/intel/` is absent, suggest running `/dw-intel --build` first for richer downstream context
89
+ - Identify tech stack, existing patterns, related features, and project constraints.
90
+ - If `.dw/intel/` is absent, suggest `/dw-intel --build` for richer future context, but continue with `.dw/rules/` and direct inspection.
101
91
 
102
92
  ### Step 2: Research (Conditional)
103
93
 
104
- Evaluate whether the topic requires deep research:
105
- - **YES** (run `/dw-brainstorm --research`): new technology for the project, unknown domain, external API integrations, critical architectural decisions
106
- - **NO** (skip to step 3): simple feature in an already mapped domain, refactoring existing code, basic CRUD
107
- - If skipping, DOCUMENT the reason in the progress block. E.g.: "Research skipped — domain already mapped in .dw/rules/[file].md". The user must see the justification.
108
-
109
- If executed, use `standard` mode by default. Incorporate findings into subsequent steps.
94
+ Run `/dw-brainstorm --research` when the feature involves new technology, unknown domain, external APIs, regulation, or high-impact architecture. Otherwise skip and record the reason in `skip_reasons`.
110
95
 
111
96
  ### Step 3: Brainstorm (Interactive)
112
97
 
113
- Run `/dw-brainstorm` with accumulated context (intel + research).
114
- - Generate 3 directions
115
- - Present the 3 directions to the user with your recommendation highlighted and justified
116
- - Wait for user confirmation on which direction to follow before proceeding
117
-
118
- ### Step 4: PRD (Interactive — 7+ Questions)
119
-
120
- <critical>The PRD MUST include an interactive interview with the user. Ask AT LEAST 7 clarification questions BEFORE writing the PRD. Do NOT answer questions automatically based on context — the user MUST respond.</critical>
121
-
122
- Run `/dw-plan prd` using brainstorm findings.
123
- - Follow ALL command instructions, especially the clarification questions section
124
- - Ask at least 7 questions about: problem, target users, critical features, scope, constraints, design, integration
125
- - In each question, present a recommendation grounded in brainstorm and deep-research findings (if executed). E.g.: "Based on the research, I recommend X because [evidence]. Do you agree or prefer a different direction?"
126
- - Wait for user responses to each question
127
- - This step is BLOCKING — the command STOPS until a response is received from the user for EACH question. If the user does not respond, do NOT proceed. Do NOT assume answers based on context.
128
- - Only after receiving all responses, write the complete PRD in `.dw/spec/prd-[name]/prd.md`
129
-
130
- ### === GATE 1: PRD Approval ===
98
+ Run `/dw-brainstorm` with accumulated context. Present three directions and wait for the user to choose one before continuing.
131
99
 
132
- **In default mode:** the PRD was just written in Step 4.
133
- **In `--from-prd` mode:** the PRD already existed on disk before this autopilot run started (typically authored by `/dw-bugfix --analysis` or by a safety-valve escalation, or hand-edited).
100
+ ### Step 4: PRD
134
101
 
135
- Present to the user:
136
- - Summary of functional requirements
137
- - Decisions made automatically (default mode) OR origin note: "PRD authored by /dw-bugfix escalation on <date>" / "PRD pre-existing on disk" (--from-prd mode)
138
- - Open questions (if any)
102
+ Run `/dw-plan prd` using brainstorm/research findings.
139
103
 
140
- **Wait for explicit approval.** If the user requests changes, adjust and re-present. In `--from-prd` mode, edits go directly into the existing `.dw/spec/<slug>/prd.md` — there is no separate draft.
104
+ <critical>The PRD stage must use the structured interview tool when available. If unavailable, ask the required questions in chat and record the fallback. The user must answer; do not infer answers.</critical>
141
105
 
142
- ### Step 5: TechSpec (Interactive — 7+ Questions)
106
+ After `prd.md` exists, present PRD summary and wait for explicit approval. If the user requests edits, update and re-present.
143
107
 
144
- <critical>The TechSpec MUST include an interactive interview with the user. Ask AT LEAST 7 technical clarification questions BEFORE writing the TechSpec. Do NOT answer questions automatically — the user MUST respond.</critical>
108
+ ### Step 5: TechSpec
145
109
 
146
110
  Run `/dw-plan techspec` from the approved PRD.
147
- - Follow ALL command instructions, especially the clarification questions section
148
- - Ask at least 7 questions about: preferred architecture, existing vs new libs, testing strategy, integration with existing systems, infrastructure constraints, performance, security
149
- - In each question, present a technical recommendation grounded in brainstorm, deep-research, and approved PRD findings. E.g.: "Research indicated lib X has better performance for this case [source]. Want to use X or have another preference?"
150
- - Wait for user responses to each question
151
- - This step is BLOCKING — the command STOPS until a response is received from the user for EACH question. If the user does not respond, do NOT proceed. Do NOT assume answers based on context.
152
- - Only after receiving all responses, generate in `.dw/spec/prd-[name]/techspec.md`
153
-
154
- ### Step 6: Tasks
155
-
156
- Run `/dw-plan tasks` from PRD + TechSpec.
157
- - Follow all command instructions
158
- - Generate individual tasks in `.dw/spec/prd-[name]/`
159
-
160
- ### === GATE 2: Tasks Approval ===
161
-
162
- Present to the user:
163
- - Task list with brief descriptions
164
- - Dependencies between tasks
165
- - Total effort estimate
166
-
167
- **Wait for explicit approval.** If the user requests changes, adjust and re-present.
168
-
169
- ### Step 7: Design Contract (Conditional)
170
-
171
- Evaluate whether tasks involve frontend:
172
- - **YES** (run `/dw-redesign-ui`): if there are tasks with visual components AND the `dw-ui-discipline` skill is available
173
- - Generate the design contract in `.dw/spec/prd-[name]/design-contract.md`
174
- - Present a summary of the design contract to the user (palette, typography, mobile/desktop layout) as a visual checkpoint before proceeding
175
- - **NO** (skip to step 8): purely backend/infra tasks
176
-
177
- ### Step 8: Execution
178
-
179
- Run `/dw-run` with the PRD path.
180
- - Follow ALL command instructions, including the native plan-checker gate (PASS required) and wave-based parallel execution via the bundled `dw-execute-phase` skill agents
181
- - Each task follows `/dw-run` with Level 1 validation
182
111
 
183
- ### Step 9: Implementation Review (Loop)
112
+ <critical>The TechSpec stage must use the structured interview tool when available. If unavailable, ask the required questions in chat and record the fallback. The user must answer; do not infer answers.</critical>
184
113
 
185
- <critical>BEFORE the PRD compliance review, run the project's build and lint. If they fail, fix and re-run until they pass. The implementation review CANNOT start with broken build or lint.</critical>
114
+ After `techspec.md` exists, present TechSpec summary and wait for explicit approval.
186
115
 
187
- Run the project's build and lint:
188
- 1. Identify build and lint commands in `package.json` (scripts `build`, `lint`, `lint:fix`, `type-check`, etc.)
189
- 2. Run lint with `--fix` enabled (e.g., `npm run lint -- --fix` or `npx eslint . --fix`) to auto-correct what's possible
190
- 3. Run build (e.g., `npm run build` or `npx tsc --noEmit`)
191
- 4. If any fail after `--fix`: analyze errors, fix manually, and re-run
192
- 5. Repeat until both build AND lint pass without errors
193
- 6. Only then proceed to the review
194
-
195
- Run `/dw-review --coverage-only` to verify PRD compliance (Level 2).
196
- - If gaps found: fix automatically and re-run the review
197
- - Maximum 3 correction cycles
198
- - Do NOT advance to QA until the review passes
199
-
200
- <critical>Required artifacts for this step (verify BEFORE marking complete):
201
- - Formatted output with compliance matrix shown to the user in the session
202
- - Explicit verdict (PASS / GAP / FAIL) for EACH RF in the PRD, EACH endpoint in the TechSpec, and EACH task
203
- - If gaps: correction commits before re-running the review
204
- A short text review, a "looks good", or a conclusion "implementation is correct" WITHOUT the structured RF-by-RF matrix DOES NOT count. A mental or eyeball review DOES NOT count. If the matrix didn't appear in the output, the command didn't run — re-execute.</critical>
205
-
206
- ### Step 10: Visual QA
207
-
208
- Run `/dw-qa` with Playwright MCP.
209
- - Test happy paths, edge cases, negative flows, accessibility
210
- - Document bugs with screenshots
211
-
212
- <critical>Required artifacts for this step (run `ls` on EACH path BEFORE marking complete):
213
- - `{{PRD_PATH}}/QA/qa-report.md` — exists and contains a per-RF section with PASS/FAIL
214
- - `{{PRD_PATH}}/QA/bugs.md` — exists (may be empty if no bugs, but the file must exist)
215
- - `{{PRD_PATH}}/QA/checklist.md` — exists and fully covered
216
- - `{{PRD_PATH}}/QA/screenshots/` — directory exists and contains at least 1 PNG per RF tested (format `RF-XX-[slug]-PASS.png` or `-FAIL.png`)
217
- - `{{PRD_PATH}}/QA/scripts/` — directory exists and contains Playwright `.spec.ts`/`.spec.js` scripts per RF
218
- - `{{PRD_PATH}}/QA/logs/` — directory exists with captured console/network logs
219
- Running Playwright ad-hoc, taking a few loose screenshots, or writing a short qa-report.md by hand DOES NOT replace this structure. If any artifact is missing or incomplete, the command did NOT run — invoke `/dw-qa` formally and follow its flow to completion.</critical>
220
-
221
- ### Step 11: Fix QA (Conditional)
222
-
223
- If QA found bugs:
224
- - Run `/dw-qa --fix` to fix and retest
225
- - Loop until stable (maximum 5 cycles). After 5 cycles, STOP and ask the user how to proceed.
226
-
227
- ### Step 12: Implementation Review (Post-QA)
116
+ ### Step 6: Tasks
228
117
 
229
- <critical>BEFORE the post-QA review, run build and lint again with --fix. QA fixes may have introduced new issues.</critical>
118
+ Run `/dw-plan tasks` from PRD + TechSpec. Verify:
119
+ - `tasks.md` exists.
120
+ - per-task files exist.
121
+ - `tasks-validation.md` exists and passes or has an explicit user override.
230
122
 
231
- Run the project's build and lint (same sequence as Step 9):
232
- 1. Lint with `--fix` enabled
233
- 2. Build
234
- 3. If any fail: fix and re-run until they pass
123
+ ### Step 7: Tasks Approval and Mandatory Stop
235
124
 
236
- Run `/dw-review --coverage-only` again to confirm QA fixes did not break PRD compliance.
237
- - If gaps found: fix and re-run
238
- - Maximum 3 cycles
125
+ Present task summary, dependencies, and total effort. Wait for explicit approval.
239
126
 
240
- <critical>Required artifacts (same rules as Step 9): explicit RF-by-RF matrix in the output. No matrix = command didn't run = re-execute.</critical>
127
+ After approval:
241
128
 
242
- ### Step 13: Code Review
129
+ 1. Save `.dw/spec/<prd-slug>/autopilot-state.json` with:
243
130
 
244
- Run `/dw-review --code-only` (Level 3) for formal review.
245
- - Generate persisted report
131
+ ```json
132
+ {
133
+ "status": "plan_complete",
134
+ "current_step": "goal",
135
+ "next_command": "/dw-goal --from-autopilot <prd-slug>"
136
+ }
137
+ ```
246
138
 
247
- ### Step 13.5: Close the bugfix loop (Conditional)
139
+ 2. Include `completed_steps` for all completed planning steps and `step_artifacts` for `prd.md`, `techspec.md`, `tasks.md`, per-task files, and `tasks-validation.md`.
140
+ 3. STOP and tell the user the planning phase is complete. Do not run implementation in this invocation.
248
141
 
249
- <critical>This step runs only when `mode == "from-prd"` AND the `prd_path` matches `.dw/spec/prd-bugfix-*`. Otherwise skip with `skip_reason: "not a bugfix escalation"`.</critical>
142
+ ## Execution Invocation
250
143
 
251
- When the autopilot is finishing a bugfix that was escalated by `/dw-bugfix`, the index entry in `.dw/bugfixes/NNN-<slug>/` still has only `TASK.md` and `escalated.md` — no `SUMMARY.md` was written because the surgical bugfix flow never reached step 5.5 (the spec-driven flow did the work instead). Without `SUMMARY.md`, `/dw-intel --build` skips this bugfix forever, so `bugfix-history` queries never surface the lesson learned.
144
+ ### Step 8: Durable Execution Goal
252
145
 
253
- This step closes that loop **before** Step 14 (Commit) so the SUMMARY lands in the same commit as the fix.
146
+ When `autopilot-state.json status=plan_complete`, formally invoke:
254
147
 
255
- **Procedure:**
148
+ ```text
149
+ /dw-goal --from-autopilot <prd-slug>
150
+ ```
256
151
 
257
- 1. **Find the index entry.** Glob `.dw/bugfixes/*/escalated.md`. For each, read the one-line content and check whether it references the current PRD slug (e.g., `→ see .dw/spec/prd-bugfix-stripe-webhook-retry/` matches the active PRD `prd-bugfix-stripe-webhook-retry`). The match is the target `NNN-<slug>/` directory.
258
- 2. **If no match is found:** the bugfix index doesn't expect a back-write. Skip silently and continue to Step 14.
259
- 3. **If `SUMMARY.md` already exists in the matched directory:** do not overwrite. Continue to Step 14 — the human or a previous run already closed the loop.
260
- 4. **Otherwise, write `SUMMARY.md`** using `.dw/templates/bugfix-summary-template.md`. Source fields from:
261
- - **Symptom (verbatim):** the `Symptom` section of `<prd_path>/prd.md`, or the first paragraph of the original `TASK.md` if the PRD doesn't carry it.
262
- - **Root Cause:** the original `TASK.md` Root Cause section.
263
- - **Resolution (2–4 bullets):** distilled from `<prd_path>/techspec.md` decisions + actual `git diff <base>...HEAD --stat` summary.
264
- - **Files Touched:** parsed from `git diff <base>...HEAD --name-only` (exclude `.dw/` paths). If >5 files, that's expected for an escalated bugfix — list them all and add a note "escalated from bugfix because of scope".
265
- - **Verification:** point to `<prd_path>/QA/qa-report.md` and the verify report referenced in Step 9's session output.
266
- - **Related — Concerns touched:** copy from the corresponding entries in `.dw/rules/concerns.md` if any rows reference modules in `Files Touched`.
267
- - **Frontmatter:** `slug: NNN-<slug>`, `created: <today's ISO date>`, `status: Fixed`, `severity: <inferred from PRD priority or default Medium>`, `related_concerns: [list from above]`.
268
- 5. **Append a final-line note** to `escalated.md`: `Closed by /dw-autopilot --from-prd on <YYYY-MM-DD>; SUMMARY.md written.` Preserve the original escalation line above it.
269
- 6. **Record the artifact** in `autopilot-state.json` `step_artifacts["13.5"] = [".dw/bugfixes/NNN-<slug>/SUMMARY.md", ".dw/bugfixes/NNN-<slug>/escalated.md"]`.
152
+ The goal owns this sequence:
270
153
 
271
- <critical>NEVER fabricate verification evidence. If the QA report is empty or the diff is empty, do not invent files in `Files Touched`. Write the SUMMARY.md sections that are grounded and mark the rest as `_(not available — see <prd_path>/QA/ for details)_`.</critical>
154
+ 1. `/dw-run <prd-path>`
155
+ 2. `/dw-review <prd-path>` (full review: coverage, quality, conventions, security, constitution, verify)
156
+ 3. `/dw-qa <prd-path>`
157
+ 4. `/dw-qa --fix <prd-path>` if QA found Open bugs
158
+ 5. `/dw-review <prd-path>` again after QA/fixes
272
159
 
273
- After this step, the bugfix becomes visible to `/dw-intel "bugfix history in <module>"` on the next `/dw-intel --build` run.
160
+ <critical>Do not substitute `/dw-review --coverage-only` for the goal reviews. The autopilot quality goal requires full `/dw-review` before QA and after QA fixes.</critical>
274
161
 
275
- ### Step 14: Commit
162
+ After `/dw-goal` completes, verify `.dw/goals/autopilot-<prd-slug>/status.json` has `status: "complete"`, then set `autopilot-state.json status: "goal_complete"`.
276
163
 
277
- <critical>MANDATORY PRE-COMMIT AUDIT — execute BEFORE invoking `/dw-commit`:
164
+ ### Step 9: Bugfix Loop Close (Conditional)
278
165
 
279
- Run `ls` on each path below and confirm existence. If ANY is missing, DO NOT commit:
280
- - `{{PRD_PATH}}/QA/qa-report.md`
281
- - `{{PRD_PATH}}/QA/bugs.md`
282
- - `{{PRD_PATH}}/QA/checklist.md`
283
- - `{{PRD_PATH}}/QA/screenshots/` (non-empty)
284
- - `{{PRD_PATH}}/QA/scripts/` (non-empty with `.spec.*` files)
285
- - `{{PRD_PATH}}/QA/logs/`
286
- - Evidence of the last `/dw-review --coverage-only` run with RF-by-RF matrix (session output or reference in `autopilot-state.json`)
166
+ If `mode == "from-prd"` and the PRD slug matches `prd-bugfix-*`, close the bugfix index before commit:
167
+ - Find `.dw/bugfixes/*/escalated.md` that references the PRD slug.
168
+ - If `SUMMARY.md` is missing, write it from available PRD, TechSpec, QA, and diff evidence using `.dw/templates/bugfix-summary-template.md`.
169
+ - Never fabricate verification evidence.
170
+ - Record artifacts in `autopilot-state.json`.
287
171
 
288
- Also verify `autopilot-state.json`:
289
- - Every step 1 through 13 (and 13.5 when in `--from-prd` mode against a `prd-bugfix-*` PRD) that is NOT in `skipped_steps` must be in `completed_steps`
290
- - Each completed step must have its artifacts listed in `step_artifacts`
172
+ ### Step 10: Pre-Commit Audit
291
173
 
292
- If any artifact or step is missing: STOP immediately. Report to the user: `Step N did not produce artifact X — re-running /dw-[command]`. Re-execute the command. Verify again. Only then proceed to `/dw-commit`.
174
+ Before `/dw-commit`, verify:
175
+ - `.dw/goals/autopilot-<prd-slug>/status.json` is complete.
176
+ - `<prd-path>/QA/review-consolidated.md` exists from the final post-QA review.
177
+ - `<prd-path>/QA/qa-report.md` and `<prd-path>/QA/bugs.md` exist.
178
+ - `autopilot-state.json` records planning artifacts and the completed goal.
293
179
 
294
- DO NOT make a partial commit. DO NOT justify the absence with manual validation. DO NOT mark a step as complete without the formal artifact.</critical>
180
+ If anything is missing, STOP and re-run the missing formal command. Do not commit partial work.
295
181
 
296
- Run `/dw-commit` automatically.
297
- - Semantic commits following Conventional Commits
298
- - Do NOT wait for approval
182
+ ### Step 11: Commit
299
183
 
300
- ### === GATE 3: Pull Request ===
184
+ Run `/dw-commit` automatically. Do not wait for approval after the goal is complete.
301
185
 
302
- Ask the user: **"Commits completed. Do you want to generate the Pull Request?"**
186
+ ### Step 12: Pull Request Gate
303
187
 
304
- - **YES**: run `/dw-generate-pr` with the target branch
305
- - **NO**: inform that commits are ready and the user can generate the PR manually later
188
+ Ask: **"Commits completed. Do you want to generate the Pull Request?"**
306
189
 
307
- ## Native Engine
190
+ - YES: run `/dw-generate-pr`.
191
+ - NO: report that commits are ready and PR can be generated later.
308
192
 
309
- The autopilot relies on dev-workflow-native infrastructure for codebase intelligence (`/dw-intel --build` + `/dw-intel`) and bundled phase execution agents (plan-checker + executor in `.agents/skills/dw-execute-phase/agents/`). All bundled and require no external dependencies. See the `dw-codebase-intel` and `dw-execute-phase` bundled skills under `.agents/skills/` for details.
193
+ Mark `autopilot-state.json status: "completed"` after commit, and include PR link if generated.
310
194
 
311
195
  ## State Persistence
312
196
 
313
- <critical>The autopilot MUST save its state after each completed step to allow re-invocation on the same PRD after interruption.</critical>
314
-
315
- Save the file `.dw/spec/prd-[name]/autopilot-state.json` with the following format:
197
+ `autopilot-state.json` must include:
316
198
 
317
199
  ```json
318
200
  {
319
201
  "mode": "autopilot",
202
+ "status": "planning",
320
203
  "wish": "original user description",
321
- "prd_path": ".dw/spec/prd-[name]",
204
+ "prd_path": ".dw/spec/prd-name",
322
205
  "from_prd_slug": null,
323
- "current_step": 8,
324
- "completed_steps": [1, 2, 3, 4, 5, 6, 7],
325
- "skipped_steps": [2],
326
- "skip_reasons": {"2": "domain already mapped in .dw/rules/auth.md"},
327
- "gates_passed": ["prd", "tasks"],
328
- "step_artifacts": {
329
- "9": ["review-matrix-shown-in-session"],
330
- "10": [
331
- ".dw/spec/prd-[name]/QA/qa-report.md",
332
- ".dw/spec/prd-[name]/QA/bugs.md",
333
- ".dw/spec/prd-[name]/QA/checklist.md",
334
- ".dw/spec/prd-[name]/QA/screenshots/",
335
- ".dw/spec/prd-[name]/QA/scripts/",
336
- ".dw/spec/prd-[name]/QA/logs/"
337
- ],
338
- "12": ["review-matrix-post-qa-shown-in-session"]
339
- },
340
- "started_at": "2026-04-10T14:30:00Z",
341
- "last_updated": "2026-04-10T15:45:00Z"
206
+ "current_step": 1,
207
+ "completed_steps": [],
208
+ "skipped_steps": [],
209
+ "skip_reasons": {},
210
+ "gates_passed": [],
211
+ "step_artifacts": {},
212
+ "goal_slug": null,
213
+ "next_command": null,
214
+ "started_at": "2026-05-20T00:00:00Z",
215
+ "last_updated": "2026-05-20T00:00:00Z"
342
216
  }
343
217
  ```
344
218
 
345
- - Update `current_step`, `completed_steps`, and `step_artifacts` BEFORE moving to the next step
346
- - A step ONLY moves to `completed_steps` after verifying its artifacts exist on disk
347
- - If the session drops, re-invoke `/dw-autopilot` on the same PRD; the command reads `autopilot-state.json` and continues from the correct step, revalidating artifacts before trusting `completed_steps`
348
- - When the pipeline finishes (after commit or PR), remove the file or mark `"status": "completed"`
349
- - In `--from-prd` mode, set `from_prd_slug: "<slug>"`, `mode: "from-prd"`, and include steps 1–4 in `skipped_steps` with `skip_reason: "from-prd-mode"` — this is what the pre-commit audit checks against (Step 14 verifies that every step NOT in `skipped_steps` is in `completed_steps`)
350
-
351
- <critical>After EACH completed step, display the updated progress block to the user. This is MANDATORY — the user MUST see what was done and what comes next. If a step was skipped, the reason MUST appear in the progress block.</critical>
219
+ Update state after each completed or skipped step. A step is complete only after required artifacts exist.
352
220
 
353
221
  ## Progress Format
354
222
 
355
- During execution, report progress in this format:
223
+ Report progress after each step:
356
224
 
225
+ ```text
226
+ === AUTOPILOT =====================================
227
+ OK [1] Codebase Intelligence
228
+ OK [2] Research (skipped — known domain)
229
+ OK [3] Brainstorm
230
+ OK [4] PRD
231
+ OK [5] TechSpec
232
+ OK [6] Tasks
233
+ STOP [PLAN COMPLETE] Next: /dw-goal --from-autopilot prd-name
234
+ ===================================================
357
235
  ```
236
+
237
+ During execution invocation:
238
+
239
+ ```text
358
240
  === AUTOPILOT =====================================
359
- OK [1/14] Codebase Intelligence
360
- OK [2/14] Research (skipped — known domain)
361
- OK [3/14] Brainstorm
362
- OK [4/14] PRD
363
- PAUSE [GATE 1] Awaiting PRD approval...
241
+ OK [PLAN] Already complete
242
+ RUN [GOAL] /dw-goal --from-autopilot prd-name
243
+ NEXT [COMMIT] after goal status=complete
364
244
  ===================================================
365
245
  ```
366
246
 
367
- ## Closing
247
+ ## Anti-patterns
368
248
 
369
- At the end, present:
370
- - PR link (if generated)
371
- - Summary: steps executed, steps skipped, estimated time saved
372
- - Suggested next steps (merge, deploy, etc.)
249
+ - Do not continue into implementation during the first invocation.
250
+ - Do not skip `/dw-goal` during the second invocation.
251
+ - Do not replace full `/dw-review` with a narrower review in the execution goal.
252
+ - Do not mark state complete from manual validation alone.
253
+ - Do not re-run planning when `status=plan_complete`; resume the goal.
373
254
 
374
255
  </system_instructions>
@@ -326,7 +326,7 @@
326
326
 
327
327
  Next — pick one:
328
328
  - Manual chain: `/dw-plan techspec prd-bugfix-<slug>` → `/dw-plan tasks prd-bugfix-<slug>` → `/dw-run` → `/dw-qa` → `/dw-review` → `/dw-commit` → `/dw-generate-pr`.
329
- - Hand off to autopilot: `/dw-autopilot --from-prd prd-bugfix-<slug>` — picks up at GATE 1 (PRD approval) and runs the rest automatically with the usual three gates.
329
+ - Hand off to autopilot: `/dw-autopilot --from-prd prd-bugfix-<slug>` — runs the planning phase from the existing PRD, stops after Tasks, then a later autopilot invocation resumes through `/dw-goal`.
330
330
  ```
331
331
 
332
332
  5. Stop this command. Do not proceed to step 5. The user (or autopilot) invokes `/dw-plan` or `/dw-autopilot --from-prd` next.
@@ -424,7 +424,8 @@
424
424
 
425
425
  Option B (hand off to autopilot):
426
426
  1. Run: `/dw-autopilot --from-prd prd-bugfix-<slug>`
427
- 2. Autopilot picks up at GATE 1 (PRD approval) and runs TechSpec, Tasks, Run, QA, Review, Commit, PR with the usual three gates.
427
+ 2. Autopilot runs PRD approval, TechSpec, and Tasks, then stops with `status: plan_complete`.
428
+ 3. A later autopilot invocation resumes via `/dw-goal --from-autopilot prd-bugfix-<slug>` for Run, full Review, QA/Fix, and post-QA full Review before commit/PR.
428
429
 
429
430
  The bugfix index entry stays queryable via `/dw-intel "bugfix history in <module>"`. Downstream `/dw-review --bugfix <slug>` and `/dw-qa --bugfix <slug>` still target `.dw/bugfixes/NNN-<slug>/` when you want a focused review of just the eventual surgical patch.
430
431
  ```