@brunosps00/dev-workflow 0.8.0 → 0.9.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/README.md +18 -14
  2. package/bin/dev-workflow.js +1 -1
  3. package/lib/constants.js +8 -2
  4. package/lib/init.js +6 -0
  5. package/lib/install-deps.js +0 -5
  6. package/lib/migrate-gsd.js +164 -0
  7. package/lib/uninstall.js +2 -2
  8. package/package.json +1 -1
  9. package/scaffold/en/commands/dw-analyze-project.md +6 -11
  10. package/scaffold/en/commands/dw-autopilot.md +6 -13
  11. package/scaffold/en/commands/dw-brainstorm.md +1 -1
  12. package/scaffold/en/commands/dw-code-review.md +6 -5
  13. package/scaffold/en/commands/dw-create-prd.md +5 -4
  14. package/scaffold/en/commands/dw-create-techspec.md +5 -4
  15. package/scaffold/en/commands/dw-execute-phase.md +149 -0
  16. package/scaffold/en/commands/dw-fix-qa.md +34 -13
  17. package/scaffold/en/commands/dw-help.md +5 -2
  18. package/scaffold/en/commands/dw-intel.md +98 -29
  19. package/scaffold/en/commands/dw-map-codebase.md +125 -0
  20. package/scaffold/en/commands/dw-new-project.md +1 -1
  21. package/scaffold/en/commands/dw-plan-checker.md +144 -0
  22. package/scaffold/en/commands/dw-quick.md +30 -12
  23. package/scaffold/en/commands/dw-redesign-ui.md +5 -9
  24. package/scaffold/en/commands/dw-refactoring-analysis.md +6 -5
  25. package/scaffold/en/commands/dw-resume.md +10 -8
  26. package/scaffold/en/commands/dw-run-plan.md +14 -20
  27. package/scaffold/en/commands/dw-run-qa.md +124 -23
  28. package/scaffold/en/commands/dw-run-task.md +5 -4
  29. package/scaffold/en/commands/dw-update.md +3 -1
  30. package/scaffold/en/templates/idea-onepager.md +1 -1
  31. package/scaffold/pt-br/commands/dw-analyze-project.md +6 -11
  32. package/scaffold/pt-br/commands/dw-autopilot.md +6 -13
  33. package/scaffold/pt-br/commands/dw-brainstorm.md +1 -1
  34. package/scaffold/pt-br/commands/dw-code-review.md +6 -5
  35. package/scaffold/pt-br/commands/dw-create-prd.md +5 -4
  36. package/scaffold/pt-br/commands/dw-create-techspec.md +5 -4
  37. package/scaffold/pt-br/commands/dw-execute-phase.md +149 -0
  38. package/scaffold/pt-br/commands/dw-fix-qa.md +34 -13
  39. package/scaffold/pt-br/commands/dw-help.md +5 -2
  40. package/scaffold/pt-br/commands/dw-intel.md +98 -29
  41. package/scaffold/pt-br/commands/dw-map-codebase.md +125 -0
  42. package/scaffold/pt-br/commands/dw-new-project.md +1 -1
  43. package/scaffold/pt-br/commands/dw-plan-checker.md +144 -0
  44. package/scaffold/pt-br/commands/dw-quick.md +30 -12
  45. package/scaffold/pt-br/commands/dw-redesign-ui.md +5 -9
  46. package/scaffold/pt-br/commands/dw-refactoring-analysis.md +6 -5
  47. package/scaffold/pt-br/commands/dw-resume.md +10 -8
  48. package/scaffold/pt-br/commands/dw-run-plan.md +16 -22
  49. package/scaffold/pt-br/commands/dw-run-qa.md +124 -23
  50. package/scaffold/pt-br/commands/dw-run-task.md +5 -4
  51. package/scaffold/pt-br/commands/dw-update.md +3 -1
  52. package/scaffold/pt-br/templates/idea-onepager.md +1 -1
  53. package/scaffold/skills/api-testing-recipes/SKILL.md +104 -0
  54. package/scaffold/skills/api-testing-recipes/recipes/dotnet-webapp-factory.md +168 -0
  55. package/scaffold/skills/api-testing-recipes/recipes/http-rest-client.md +130 -0
  56. package/scaffold/skills/api-testing-recipes/recipes/pytest-httpx.md +157 -0
  57. package/scaffold/skills/api-testing-recipes/recipes/rust-reqwest.md +173 -0
  58. package/scaffold/skills/api-testing-recipes/recipes/supertest-node.md +153 -0
  59. package/scaffold/skills/api-testing-recipes/references/auth-patterns.md +138 -0
  60. package/scaffold/skills/api-testing-recipes/references/log-conventions.md +117 -0
  61. package/scaffold/skills/api-testing-recipes/references/matrix-conventions.md +68 -0
  62. package/scaffold/skills/api-testing-recipes/references/openapi-driven.md +97 -0
  63. package/scaffold/skills/dw-codebase-intel/SKILL.md +101 -0
  64. package/scaffold/skills/dw-codebase-intel/agents/intel-updater.md +318 -0
  65. package/scaffold/skills/dw-codebase-intel/references/incremental-update.md +79 -0
  66. package/scaffold/skills/dw-codebase-intel/references/intel-format.md +208 -0
  67. package/scaffold/skills/dw-codebase-intel/references/query-patterns.md +148 -0
  68. package/scaffold/skills/dw-execute-phase/SKILL.md +133 -0
  69. package/scaffold/skills/dw-execute-phase/agents/executor.md +264 -0
  70. package/scaffold/skills/dw-execute-phase/agents/plan-checker.md +215 -0
  71. package/scaffold/skills/dw-execute-phase/references/atomic-commits.md +143 -0
  72. package/scaffold/skills/dw-execute-phase/references/plan-verification.md +156 -0
  73. package/scaffold/skills/dw-execute-phase/references/wave-coordination.md +102 -0
@@ -0,0 +1,148 @@
1
+ # Query patterns — how `/dw-intel` answers different question shapes
2
+
3
+ `/dw-intel "<query>"` reads `.dw/intel/` and returns structured answers with file paths cited. This file describes how the command maps natural-language queries to which intel files to read.
4
+
5
+ ## Query shape detection
6
+
7
+ The command classifies the query into one of these shapes before searching:
8
+
9
+ | Shape | Example queries | Primary file | Secondary files |
10
+ |-------|-----------------|--------------|-----------------|
11
+ | **where-is** | "where is the user routes file?", "where is auth defined?" | `files.json` | `apis.json` |
12
+ | **what-uses** | "what uses express?", "where is the redis client called?" | `deps.json` (for libs), `files.json` (for symbols) | grep fallback |
13
+ | **architecture-of** | "what's the architecture?", "how is data flow structured?" | `arch.md` | `stack.json` |
14
+ | **stack** | "what frameworks?", "is this typescript or javascript?" | `stack.json` | — |
15
+ | **dep-info** | "which version of react?", "what's prisma used for here?" | `deps.json` | — |
16
+ | **api-list** | "list endpoints", "what routes exist?" | `apis.json` | — |
17
+ | **find-export** | "where is `createServer` exported from?", "find the `userSchema` symbol" | `files.json` (search `exports` arrays) | grep fallback |
18
+ | **convention** | "what's the file naming convention?", "are tests co-located?" | `arch.md` | `.dw/rules/` if available |
19
+
20
+ ## Match algorithm
21
+
22
+ For each shape, the command:
23
+
24
+ 1. **Tokenize** the query into keywords (drop stopwords).
25
+ 2. **Search the primary file** for matches:
26
+ - JSON files: case-insensitive substring match in keys + descriptions
27
+ - `arch.md`: case-insensitive full-text search
28
+ 3. **Rank** matches by:
29
+ - Exact symbol match > substring match > description match
30
+ - Direct deps > indirect (transitive) deps
31
+ 4. **Return** top 3-5 matches with file paths cited.
32
+
33
+ If primary file yields zero matches, fall back to secondary files. If still zero, fall back to direct grep over the project (slower but exhaustive).
34
+
35
+ ## Examples
36
+
37
+ ### Query: "where is auth defined?"
38
+
39
+ **Shape:** where-is
40
+
41
+ **Process:**
42
+ 1. Search `files.json` for keys containing `auth` → finds `src/auth/index.ts`, `src/middleware/auth.ts`, `src/routes/auth.ts`
43
+ 2. Search `apis.json` for paths containing `auth` → finds `POST /api/auth/login`, `POST /api/auth/logout`
44
+ 3. Return top files + endpoints with paths
45
+
46
+ **Output:**
47
+ ```
48
+ Auth is defined across 3 files and exposes 2 endpoints:
49
+
50
+ Files:
51
+ - src/auth/index.ts (entry-point) — exports: configureAuth, AuthError
52
+ - src/middleware/auth.ts (module) — exports: requireAuth, optionalAuth
53
+ - src/routes/auth.ts (module) — exports: authRouter
54
+
55
+ Endpoints:
56
+ - POST /api/auth/login (file: src/routes/auth.ts) — Authenticate user
57
+ - POST /api/auth/logout (file: src/routes/auth.ts) — Clear session
58
+ ```
59
+
60
+ ### Query: "what uses redis?"
61
+
62
+ **Shape:** what-uses
63
+
64
+ **Process:**
65
+ 1. Search `deps.json` for entry `redis` (or `ioredis`, `redis-py`, etc. depending on stack)
66
+ 2. Read its `used_by` array
67
+ 3. Cross-reference with `files.json` to enrich (which files have this dep imported and what they do)
68
+
69
+ **Output:**
70
+ ```
71
+ Redis (ioredis@^5.3.0, production) is used by 3 files:
72
+
73
+ - src/cache/index.ts — exports: cacheGet, cacheSet, cacheDel
74
+ - src/jobs/queue.ts — exports: enqueueJob (uses ioredis as BullMQ backend)
75
+ - src/sessions/store.ts — exports: createSessionStore
76
+ ```
77
+
78
+ ### Query: "what frameworks?"
79
+
80
+ **Shape:** stack
81
+
82
+ **Process:**
83
+ 1. Read `stack.json` directly
84
+ 2. Output the `frameworks` field, with versions if available from `deps.json`
85
+
86
+ **Output:**
87
+ ```
88
+ Frameworks detected:
89
+ - Express (^4.18.0, production)
90
+ - React (^18.2.0, production)
91
+ - Prisma (^5.4.0, production)
92
+
93
+ Build system: npm scripts
94
+ Test framework: Jest
95
+ Package manager: npm
96
+ ```
97
+
98
+ ### Query: "list endpoints"
99
+
100
+ **Shape:** api-list
101
+
102
+ **Process:**
103
+ 1. Read `apis.json`
104
+ 2. Group by tag/prefix (`/api/users`, `/api/orders`, `/api/auth` → User Management, Orders, Auth)
105
+ 3. Output tabular
106
+
107
+ **Output:**
108
+ ```
109
+ 12 endpoints across 3 groups:
110
+
111
+ Auth (2)
112
+ - POST /api/auth/login — Authenticate user
113
+ - POST /api/auth/logout — Clear session
114
+
115
+ Users (5)
116
+ - GET /api/users — List users
117
+ - POST /api/users — Create user
118
+ - GET /api/users/:id — Get user by id
119
+ - PATCH /api/users/:id — Update user
120
+ - DELETE /api/users/:id — Delete user
121
+
122
+ Orders (5) ...
123
+ ```
124
+
125
+ ## Stale-index handling
126
+
127
+ Before answering, check `.dw/intel/.last-refresh.json`:
128
+
129
+ - If `updated_at` is more than 7 days old → prefix the answer with: `⚠ Index last refreshed YYYY-MM-DD (X days ago). Run /dw-map-codebase to refresh.`
130
+ - If `.last-refresh.json` is absent → prefix with: `⚠ No refresh metadata. Index may be stale; run /dw-map-codebase.`
131
+
132
+ Don't refuse to answer — return the best info available, but flag the staleness so the user can decide whether to trust it.
133
+
134
+ ## Fallback path (no `.dw/intel/`)
135
+
136
+ If `.dw/intel/` doesn't exist at all:
137
+
138
+ 1. Check `.dw/rules/` (from `/dw-analyze-project` or `/dw-new-project` seeding)
139
+ 2. If `.dw/rules/index.md` exists, search there for the query keywords
140
+ 3. Otherwise, do a direct `grep -r` over the project source (excluding `node_modules`, `.git`, etc.)
141
+ 4. Suggest at the end: `Tip: run /dw-map-codebase to build a queryable index. Subsequent /dw-intel queries will be much faster.`
142
+
143
+ ## Don't
144
+
145
+ - Don't fabricate paths or symbols not present in the index
146
+ - Don't return "I don't know" without first trying the secondary file and grep fallback
147
+ - Don't ignore stale-index warnings — surface them prominently
148
+ - Don't dump the entire JSON of an intel file as the answer; synthesize and cite paths
@@ -0,0 +1,133 @@
1
+ ---
2
+ name: dw-execute-phase
3
+ description: Phase execution and plan verification for dev-workflow. Two agents (executor for wave-based parallel task dispatch with deviation handling, plan-checker for goal-backward plan verification before execution). Used by /dw-execute-phase, /dw-plan-checker, /dw-run-plan, /dw-autopilot. Adapted from get-shit-done-cc (MIT).
4
+ allowed-tools:
5
+ - Read
6
+ - Write
7
+ - Edit
8
+ - Bash
9
+ - Grep
10
+ - Glob
11
+ ---
12
+
13
+ # dw-execute-phase
14
+
15
+ Bundled skill providing **phase-level execution discipline** for dev-workflow: parallel task dispatch in waves, atomic commit per task, deviation handling mid-execution, and goal-backward plan verification before any execution burns context.
16
+
17
+ ## Why a skill (not inline)
18
+
19
+ - The execution discipline (wave coordination, deviation rules, checkpoint protocol) is a separate concern from the commands that invoke it. Bundling it as a skill lets multiple commands (`/dw-run-plan`, `/dw-autopilot`, `/dw-execute-phase` itself) reuse the same discipline.
20
+ - The plan-checker is a verification GATE — it must run before `/dw-run-plan`/`/dw-execute-phase` mutate code, and bundling it makes that contract visible.
21
+ - The agents own the protocol; the orchestrating commands just wire them up.
22
+
23
+ ## When to Use
24
+
25
+ Read this skill when:
26
+
27
+ - `/dw-execute-phase` is invoked to run a batch of tasks in parallel waves.
28
+ - `/dw-plan-checker` is invoked to verify a `tasks.md` file will achieve its PRD goal before execution.
29
+ - `/dw-run-plan` is invoked (it spawns the executor agent for each wave).
30
+ - `/dw-autopilot` enters the execution stage (it gates on plan-checker before invoking the executor).
31
+
32
+ Do NOT use when:
33
+
34
+ - A single one-off change is being made (use `/dw-run-task` directly — no waves needed).
35
+ - The user is exploring/brainstorming, not executing (use `/dw-brainstorm`).
36
+ - The plan hasn't been created yet (use `/dw-create-tasks` first).
37
+
38
+ ## Agents
39
+
40
+ | Agent | Responsibility | Spawn from |
41
+ |-------|----------------|------------|
42
+ | `agents/executor.md` | Runs tasks in waves, atomic commit per task, handles deviations (3 deviation rules), respects checkpoint markers, writes `SUMMARY.md` per phase | `/dw-execute-phase`, `/dw-run-plan` |
43
+ | `agents/plan-checker.md` | Goal-backward verification of `tasks.md` before execution. Checks: requirement coverage, task completeness, dependency soundness, artifact wiring, context budget. Returns PASS / REVISE / BLOCK. | `/dw-plan-checker`, `/dw-create-tasks` (auto-gate before declaring tasks ready) |
44
+
45
+ ## How the Two Agents Compose
46
+
47
+ The expected flow:
48
+
49
+ 1. `/dw-create-tasks` produces `.dw/spec/prd-<slug>/tasks.md` from PRD + TechSpec.
50
+ 2. **Plan-checker GATE** — `/dw-plan-checker .dw/spec/prd-<slug>/` spawns the plan-checker agent. The agent reads PRD/TechSpec/tasks.md and verifies tasks WILL achieve the goal. Returns one of: `PASS` (proceed), `REVISE` (issues found, planner re-runs), `BLOCK` (fundamental gap, abort).
51
+ 3. `/dw-execute-phase` spawns the executor agent ONLY if plan-checker returned `PASS`. The executor runs tasks in waves, commits atomically, handles deviations.
52
+ 4. `/dw-run-qa` runs after all waves complete to validate the implementation against PRD.
53
+
54
+ `/dw-autopilot` orchestrates this entire flow with hard gates between stages.
55
+
56
+ ## Wave Concept
57
+
58
+ Tasks in `tasks.md` are grouped into **waves** by their `Depends on:` frontmatter:
59
+
60
+ - Wave 1: tasks with no dependencies → run in parallel
61
+ - Wave 2: tasks that depend on Wave 1 → run after Wave 1 commits land
62
+ - Wave N: ...
63
+
64
+ Within a wave, tasks run in parallel via subagent dispatch. Across waves, sequential.
65
+
66
+ The executor calculates waves automatically by topologically sorting task dependencies. See `references/wave-coordination.md`.
67
+
68
+ ## Deviation Rules (during execution)
69
+
70
+ Mid-task, the executor may discover the plan is incomplete or contradicted by reality. Three rules:
71
+
72
+ 1. **Auto-add missing critical functionality** — if a task says "create endpoint" but no validation is specified and the project's CLAUDE.md/rules require it, add the validation as part of the same task. Note in the task's commit message.
73
+ 2. **Surface ambiguity, don't guess** — if the plan says "use the existing service" and 3 services match, STOP, write a deviation entry to `.dw/spec/prd-<slug>/deviations.md`, and ask the user.
74
+ 3. **Block on architectural conflicts** — if the task as planned would violate a locked decision in CONTEXT.md / project rules, abort the task and surface the conflict for re-planning.
75
+
76
+ Detail in `references/atomic-commits.md` (deviation entry format) and `references/plan-verification.md` (what plan-checker should catch BEFORE execution to prevent deviations).
77
+
78
+ ## Atomic Commit Protocol
79
+
80
+ Every task ends with exactly one git commit:
81
+
82
+ ```
83
+ feat(<scope>): <task title> (RF-XX)
84
+
85
+ <one-line summary of what this commit delivers>
86
+
87
+ - Files added: <list>
88
+ - Files modified: <list>
89
+ - Tests added/updated: <list>
90
+ - Deviations: <link to deviations.md entry, if any>
91
+
92
+ Closes RF-XX (partial — see tasks.md).
93
+ ```
94
+
95
+ The commit message format is consistent across waves so `/dw-generate-pr` can build a clean PR body. See `references/atomic-commits.md`.
96
+
97
+ ## Checkpoint Protocol
98
+
99
+ If the executor exhausts its context budget mid-phase OR the user signals stop:
100
+
101
+ - Write current progress to `.dw/spec/prd-<slug>/active-session.md` (last completed task, next task, blockers).
102
+ - Exit cleanly with status `CHECKPOINT`.
103
+ - Next invocation of `/dw-resume` reads this file and resumes from the last completed task.
104
+
105
+ ## Files in `.dw/spec/prd-<slug>/`
106
+
107
+ | File | Read by | Written by |
108
+ |------|---------|------------|
109
+ | `prd.md` | plan-checker, executor | `/dw-create-prd` |
110
+ | `techspec.md` | plan-checker, executor | `/dw-create-techspec` |
111
+ | `tasks.md` | plan-checker (verifies), executor (executes) | `/dw-create-tasks` |
112
+ | `<NN>_task.md` | executor (per-task detail) | `/dw-create-tasks` |
113
+ | `deviations.md` | plan-checker (next iteration), executor | executor (rule 1/2 deviations) |
114
+ | `active-session.md` | `/dw-resume`, executor (continuation) | executor (checkpoint) |
115
+ | `SUMMARY.md` | `/dw-generate-pr` | executor (after final wave) |
116
+
117
+ ## References
118
+
119
+ - `references/wave-coordination.md` — how the executor groups tasks into waves and dispatches them in parallel.
120
+ - `references/plan-verification.md` — the 6-dimension goal-backward analysis the plan-checker performs.
121
+ - `references/atomic-commits.md` — commit message format, deviation entry format, when to use Edit vs Write.
122
+
123
+ ## Rules
124
+
125
+ - **No execution without plan-checker PASS.** `/dw-execute-phase` and `/dw-run-plan` must call plan-checker first; if it returns REVISE or BLOCK, abort.
126
+ - **One commit per task, no exceptions.** Even trivial tasks commit. This drives traceability and revert safety.
127
+ - **Deviations are recorded, not silenced.** Every adjustment beyond the plan goes in `deviations.md` with reason.
128
+ - **Checkpoint > timeout.** When context budget is low, checkpoint cleanly rather than running tasks half-way.
129
+ - **Wave order is topological, not user-defined.** The executor computes wave boundaries from `Depends on:` fields; users can't override.
130
+
131
+ ## Inspired by
132
+
133
+ Adapted from [`get-shit-done-cc`](https://github.com/gsd-build/get-shit-done) (`gsd-executor`, `gsd-plan-checker`) by gsd-build (MIT license). Core protocols (goal-backward verification, atomic commits, deviation handling, checkpoint resume) preserved. Path conventions changed from `.planning/<phase>/` to `.dw/spec/prd-<slug>/`. SDK CLI calls (`gsd-sdk query init.execute-phase`) replaced by inline operations. The companion `gsd-debugger` agent (1452 lines) was NOT ported — its scope overlaps with the existing `/dw-bugfix` and `/dw-fix-qa` commands.
@@ -0,0 +1,264 @@
1
+ ---
2
+ name: dw-executor
3
+ description: Executes a phase (set of tasks for one PRD) with wave-based parallel dispatch, atomic commits, deviation handling, and checkpoint protocol.
4
+ tools: Read, Write, Edit, Bash, Grep, Glob
5
+ color: yellow
6
+ ---
7
+
8
+ <required_reading>
9
+ CRITICAL: If your spawn prompt contains a required_reading block, you MUST Read every listed file BEFORE any other action. Skipping this causes hallucinated context and broken output.
10
+ </required_reading>
11
+
12
+ # dw-executor
13
+
14
+ <role>
15
+ You are **dw-executor**, the phase execution agent for dev-workflow. You execute the tasks in `.dw/spec/prd-<slug>/tasks.md` atomically, in waves, with one git commit per task. You handle deviations mid-execution per the three deviation rules. You checkpoint cleanly when context budget gets tight.
16
+
17
+ Spawned by `/dw-execute-phase` or `/dw-run-plan` orchestrator with a PRD path.
18
+
19
+ Your job: run every task in the phase to completion, commit each one, write `SUMMARY.md` at the end, update `active-session.md` for resume.
20
+ </role>
21
+
22
+ <project_context>
23
+ Before executing, discover project context:
24
+
25
+ **`./CLAUDE.md`**: read if present. Treat its directives as hard constraints during execution. Before committing each task, verify code changes do not violate CLAUDE.md rules (forbidden patterns, required conventions, mandated tools). If a task action would contradict CLAUDE.md, apply the CLAUDE.md rule — it takes precedence over plan instructions. Document the adjustment as a Rule-1 deviation.
26
+
27
+ **Project skills**: list `.agents/skills/` and `.claude/skills/` if present. Read `SKILL.md` for each (lightweight). Load specific reference files as needed during implementation. Apply skill rules.
28
+
29
+ **`.dw/rules/`**: project conventions (from `/dw-analyze-project`). Read `index.md` first; load module-specific rules as relevant per task.
30
+
31
+ **`.dw/intel/`**: machine-readable codebase intel (from `/dw-map-codebase`). Read `arch.md` for architecture overview; query `files.json`/`apis.json` when implementing.
32
+ </project_context>
33
+
34
+ ## Execution Flow
35
+
36
+ ### Step 1: Load context
37
+
38
+ ```
39
+ Inputs from spawn prompt:
40
+ - prd_path: .dw/spec/prd-<slug>/
41
+ - start_from: <NN> (optional — resume from this task number, default 01)
42
+ - mode: full | wave-only | up-to-task <NN>
43
+ ```
44
+
45
+ Read:
46
+ - `<prd_path>/prd.md` — the goal
47
+ - `<prd_path>/techspec.md` — the architecture
48
+ - `<prd_path>/tasks.md` — the task list with dependencies
49
+ - `<prd_path>/active-session.md` if it exists — last position from a previous checkpoint
50
+
51
+ Verify `tasks.md` parses (frontmatter + numbered task list). If malformed, abort with `EXEC-FAILED: malformed tasks.md`.
52
+
53
+ ### Step 2: Compute waves
54
+
55
+ Parse each task's `Depends on:` field (none, or comma-separated task numbers).
56
+
57
+ Topological sort:
58
+ - Wave 1 = tasks with no dependencies
59
+ - Wave N = tasks whose dependencies are all in waves 1..N-1
60
+ - If a cycle is detected → abort with `EXEC-FAILED: dependency cycle in tasks.md`
61
+
62
+ Skip tasks already marked `[x]` in `tasks.md`. Skip tasks before `start_from` if specified.
63
+
64
+ Print the wave plan:
65
+
66
+ ```
67
+ Wave 1: tasks 01, 02, 03 (parallel)
68
+ Wave 2: tasks 04, 05 (parallel, depends on wave 1)
69
+ Wave 3: tasks 06 (depends on wave 2)
70
+ ```
71
+
72
+ ### Step 3: Execute each wave
73
+
74
+ For each wave:
75
+
76
+ 1. For each task in the wave (parallel within wave):
77
+ - Read `<prd_path>/<NN>_task.md` for the task detail
78
+ - Read CLAUDE.md if present (re-read each task in case it changed)
79
+ - Implement the task per its spec
80
+ - Run the task's verification (linter, tests, build)
81
+ - If verification PASSES → atomic commit (Step 4)
82
+ - If verification FAILS → deviation handling (Step 5)
83
+ 2. Wait for all tasks in the wave to complete before starting the next wave.
84
+ 3. After each task commits, mark it `[x]` in `tasks.md` (atomic edit).
85
+
86
+ ### Step 4: Atomic commit per task
87
+
88
+ Format (per `references/atomic-commits.md`):
89
+
90
+ ```
91
+ <type>(<scope>): <task title> (RF-XX)
92
+
93
+ <one-line summary>
94
+
95
+ - Files added: <list>
96
+ - Files modified: <list>
97
+ - Tests added/updated: <list>
98
+ - Deviations: <link or "none">
99
+
100
+ Closes RF-XX (partial — full close on tasks.md completion).
101
+ ```
102
+
103
+ Type from Conventional Commits (`feat`, `fix`, `refactor`, `test`, `docs`, `chore`). Scope from task domain. Run `git add -A && git commit` once.
104
+
105
+ ### Step 5: Deviation handling (when implementation diverges from plan)
106
+
107
+ Three rules:
108
+
109
+ **Rule 1 — Auto-add missing critical functionality**
110
+
111
+ If implementing the task naturally requires something the plan didn't specify but the project rules / CLAUDE.md require it (e.g., input validation on a public endpoint, security headers on a route, error logging), add it as part of the same task. Document in `<prd_path>/deviations.md`:
112
+
113
+ ```markdown
114
+ ## DEVIATION-<NN>-1 (Rule 1): <one-line title>
115
+
116
+ - **Task:** <NN> — <task title>
117
+ - **What was added:** <description>
118
+ - **Why:** <which rule / CLAUDE.md directive triggered>
119
+ - **Files affected:** <list>
120
+ - **Commit:** <will be filled when task commits>
121
+ ```
122
+
123
+ **Rule 2 — Surface ambiguity, don't guess**
124
+
125
+ If the plan is ambiguous and 2+ valid interpretations exist (e.g., "use the existing service" but multiple services match), STOP. Write to `deviations.md`:
126
+
127
+ ```markdown
128
+ ## DEVIATION-<NN>-2 (Rule 2): Ambiguity in task <NN>
129
+
130
+ - **Task:** <NN> — <task title>
131
+ - **Ambiguity:** <description>
132
+ - **Options considered:**
133
+ - A: <option>
134
+ - B: <option>
135
+ - **Recommended:** <your pick + reason>
136
+ - **Status:** PAUSED awaiting user decision.
137
+ ```
138
+
139
+ Then exit the wave with status `DEVIATION-PAUSE`. The orchestrating command surfaces the deviation to the user.
140
+
141
+ **Rule 3 — Block on architectural conflicts**
142
+
143
+ If the task as planned would violate a locked decision (CONTEXT.md `## Decisions`, project rules, security policy), abort the task. Write:
144
+
145
+ ```markdown
146
+ ## DEVIATION-<NN>-3 (Rule 3): Architectural conflict in task <NN>
147
+
148
+ - **Task:** <NN> — <task title>
149
+ - **Conflict:** <plan says X, locked decision says Y>
150
+ - **Source of constraint:** <CONTEXT.md | .dw/rules/<file>.md | CLAUDE.md>
151
+ - **Status:** BLOCKED — re-plan needed.
152
+ ```
153
+
154
+ Exit with status `EXEC-BLOCKED`. The orchestrator escalates to re-planning.
155
+
156
+ ### Step 6: Checkpoint protocol
157
+
158
+ If your context budget hits 70% before all tasks complete:
159
+
160
+ 1. Finish the current task (commit it cleanly).
161
+ 2. Write `<prd_path>/active-session.md`:
162
+
163
+ ```markdown
164
+ ---
165
+ type: active-session
166
+ schema_version: "1.0"
167
+ prd: <prd-slug>
168
+ last_completed_task: <NN>
169
+ next_task: <NN+1>
170
+ last_wave_completed: <wave_number>
171
+ remaining_tasks: [<NN+1>, <NN+2>, ...]
172
+ checkpoint_reason: context-budget
173
+ checkpoint_at: <ISO-8601>
174
+ ---
175
+
176
+ # Active Session — <prd-slug>
177
+
178
+ ## Last completed
179
+ - Task <NN>: <title> (commit <SHA>)
180
+
181
+ ## Next up
182
+ - Task <NN+1>: <title> (depends on: <list>)
183
+
184
+ ## Open deviations
185
+ - <list of unresolved DEVIATION-* entries from deviations.md>
186
+
187
+ ## How to resume
188
+ Run `/dw-resume` from the project root. The session will continue from task <NN+1>.
189
+ ```
190
+
191
+ 3. Exit with status `CHECKPOINT`.
192
+
193
+ ### Step 7: Final summary
194
+
195
+ After the last wave completes:
196
+
197
+ Write `<prd_path>/SUMMARY.md`:
198
+
199
+ ```markdown
200
+ ---
201
+ type: phase-summary
202
+ schema_version: "1.0"
203
+ prd: <prd-slug>
204
+ status: COMPLETE | PARTIAL
205
+ total_tasks: <N>
206
+ completed_tasks: <N>
207
+ deviations: <count>
208
+ duration_minutes: <N>
209
+ ---
210
+
211
+ # Phase Summary — <prd-slug>
212
+
213
+ ## Status: <STATUS>
214
+
215
+ ## Tasks
216
+
217
+ | # | Title | Wave | Commit | Status |
218
+ |---|-------|------|--------|--------|
219
+ | 01 | ... | 1 | <SHA> | ✓ |
220
+
221
+ ## Deviations
222
+
223
+ <link to deviations.md or "none">
224
+
225
+ ## Next Steps
226
+
227
+ - Run `/dw-run-qa` to validate against PRD
228
+ - Run `/dw-code-review` for the formal Level 3 review
229
+ - Then `/dw-commit` (consolidates) and `/dw-generate-pr`
230
+ ```
231
+
232
+ Mark all tasks `[x]` in `tasks.md` (already done per-task; final pass confirms).
233
+
234
+ Exit with status `EXEC-COMPLETE`.
235
+
236
+ ## Status Markers (final line of agent output)
237
+
238
+ The orchestrator pattern-matches on these — emit exactly one:
239
+
240
+ - `## EXEC-COMPLETE` — all tasks done, SUMMARY.md written
241
+ - `## EXEC-PARTIAL` — some tasks committed but not all (e.g., wave failed); recoverable via `/dw-resume`
242
+ - `## EXEC-BLOCKED` — Rule 3 deviation, abort and surface to user
243
+ - `## DEVIATION-PAUSE` — Rule 2 deviation, awaiting user input
244
+ - `## CHECKPOINT` — context budget exhausted, recoverable via `/dw-resume`
245
+ - `## EXEC-FAILED` — unrecoverable error (malformed tasks.md, dependency cycle, etc.)
246
+
247
+ ## Critical Rules
248
+
249
+ - <critical>One commit per task. Never combine task changes into a single commit.</critical>
250
+ - <critical>Verification before commit. Lint + tests + build must pass before `git commit`.</critical>
251
+ - <critical>Deviations are recorded. Every Rule-1/2/3 adjustment goes in `deviations.md` with the linked commit.</critical>
252
+ - <critical>CLAUDE.md > plan. If plan and CLAUDE.md conflict, CLAUDE.md wins (Rule 1 deviation).</critical>
253
+ - <critical>Atomic edits to tasks.md. Mark `[x]` for the just-committed task BEFORE moving to the next.</critical>
254
+ - Do NOT push to remote. The orchestrator runs `/dw-generate-pr` after `/dw-run-qa`.
255
+ - Do NOT skip waves. Tasks within a wave run in parallel; waves run sequentially.
256
+
257
+ ## Anti-Patterns
258
+
259
+ 1. DO NOT batch multiple tasks into one commit
260
+ 2. DO NOT skip verification because "the change is small"
261
+ 3. DO NOT silently fix a plan ambiguity — surface it (Rule 2)
262
+ 4. DO NOT contradict CLAUDE.md or `.dw/rules/` — apply Rule 1 instead
263
+ 5. DO NOT exit without writing `SUMMARY.md` (or `active-session.md` for checkpoints)
264
+ 6. DO NOT continue past 70% context budget — checkpoint cleanly