@nklisch/pi-agile-workflow 0.15.3

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 (203) hide show
  1. package/.claude-plugin/plugin.json +10 -0
  2. package/.codex-plugin/plugin.json +28 -0
  3. package/CHANGELOG.md +591 -0
  4. package/README.md +107 -0
  5. package/docs/ARCHITECTURE.md +716 -0
  6. package/docs/MIGRATION.md +419 -0
  7. package/docs/PRINCIPLES.md +464 -0
  8. package/docs/ROADMAP.md +95 -0
  9. package/docs/SPEC.md +855 -0
  10. package/docs/VISION.md +106 -0
  11. package/extensions/agile-workflow.test.ts +419 -0
  12. package/extensions/agile-workflow.ts +467 -0
  13. package/hooks/hooks.json +52 -0
  14. package/hooks/scripts/prompt-context.py +628 -0
  15. package/hooks/scripts/substrate-maintainer.py +359 -0
  16. package/hooks/scripts/test_prompt_context.py +757 -0
  17. package/package.json +30 -0
  18. package/scripts/install-work-view.sh +165 -0
  19. package/scripts/tests/agent-metadata.test.sh +75 -0
  20. package/scripts/tests/bump-version.test.sh +552 -0
  21. package/scripts/tests/channel-parity.test.sh +117 -0
  22. package/scripts/tests/convert-content-integrity.test.sh +246 -0
  23. package/scripts/tests/convert-install-routing.test.sh +159 -0
  24. package/scripts/tests/install-work-view.test.sh +411 -0
  25. package/scripts/tests/pi-package-metadata.test.sh +119 -0
  26. package/scripts/tests/work-board-shim.test.sh +239 -0
  27. package/scripts/tests/work-view-dist-version.test.sh +105 -0
  28. package/scripts/work-board.sh +64 -0
  29. package/scripts/work-view.sh +423 -0
  30. package/skills/autopilot/SKILL.md +330 -0
  31. package/skills/autopilot/agents/openai.yaml +6 -0
  32. package/skills/board/SKILL.md +62 -0
  33. package/skills/board/agents/openai.yaml +6 -0
  34. package/skills/bold-refactor/SKILL.md +244 -0
  35. package/skills/bold-refactor/agents/openai.yaml +6 -0
  36. package/skills/bug-scan/SKILL.md +378 -0
  37. package/skills/bug-scan/agents/openai.yaml +6 -0
  38. package/skills/bug-scan/references/async-promises.md +119 -0
  39. package/skills/bug-scan/references/concurrency-races.md +148 -0
  40. package/skills/bug-scan/references/data-layer.md +167 -0
  41. package/skills/bug-scan/references/error-handling.md +197 -0
  42. package/skills/bug-scan/references/gate-item-template.md +94 -0
  43. package/skills/bug-scan/references/language-footguns.md +219 -0
  44. package/skills/bug-scan/references/parked-item-template.md +103 -0
  45. package/skills/bug-scan/references/report-template.md +115 -0
  46. package/skills/bug-scan/references/resource-leaks.md +199 -0
  47. package/skills/bug-scan/references/state-closures.md +148 -0
  48. package/skills/bug-scan/references/time-numbers.md +158 -0
  49. package/skills/convert/SKILL.md +1463 -0
  50. package/skills/convert/agents/openai.yaml +6 -0
  51. package/skills/convert/references/legacy-overlap-migration.md +179 -0
  52. package/skills/deep-code-scan/SKILL.md +378 -0
  53. package/skills/deep-code-scan/agents/openai.yaml +6 -0
  54. package/skills/deep-code-scan/references/artifact-ledger.md +148 -0
  55. package/skills/deep-code-scan/references/consolidation.md +91 -0
  56. package/skills/deep-code-scan/references/decomposition.md +127 -0
  57. package/skills/deep-code-scan/references/item-templates.md +263 -0
  58. package/skills/deep-code-scan/references/lane-catalog.md +129 -0
  59. package/skills/deep-code-scan/references/review-gauntlet.md +108 -0
  60. package/skills/deep-code-scan/references/scanner-brief.md +152 -0
  61. package/skills/e2e-test-design/SKILL.md +517 -0
  62. package/skills/e2e-test-design/references/anti-tautology.md +261 -0
  63. package/skills/e2e-test-design/references/service-mocks.md +234 -0
  64. package/skills/e2e-test-design/references/test-taxonomy.md +211 -0
  65. package/skills/epic-design/SKILL.md +476 -0
  66. package/skills/epicize/SKILL.md +210 -0
  67. package/skills/epicize/agents/openai.yaml +6 -0
  68. package/skills/feature-design/SKILL.md +472 -0
  69. package/skills/fix/SKILL.md +173 -0
  70. package/skills/gate-cruft/SKILL.md +258 -0
  71. package/skills/gate-docs/SKILL.md +278 -0
  72. package/skills/gate-patterns/SKILL.md +389 -0
  73. package/skills/gate-refactor/SKILL.md +408 -0
  74. package/skills/gate-security/SKILL.md +275 -0
  75. package/skills/gate-tests/SKILL.md +367 -0
  76. package/skills/groom/SKILL.md +162 -0
  77. package/skills/groom/agents/openai.yaml +6 -0
  78. package/skills/ideate/SKILL.md +185 -0
  79. package/skills/ideate/agents/openai.yaml +6 -0
  80. package/skills/implement/SKILL.md +288 -0
  81. package/skills/implement-orchestrator/SKILL.md +604 -0
  82. package/skills/park/SKILL.md +111 -0
  83. package/skills/perf-design/SKILL.md +427 -0
  84. package/skills/perf-scout/SKILL.md +404 -0
  85. package/skills/perf-scout/agents/openai.yaml +6 -0
  86. package/skills/perf-scout/references/algorithmic-and-data-structures.md +126 -0
  87. package/skills/perf-scout/references/approximation-and-precomputation.md +136 -0
  88. package/skills/perf-scout/references/caching-and-memoization.md +123 -0
  89. package/skills/perf-scout/references/compiler-runtime-and-language.md +136 -0
  90. package/skills/perf-scout/references/database-and-storage-internals.md +144 -0
  91. package/skills/perf-scout/references/distributed-systems.md +150 -0
  92. package/skills/perf-scout/references/game-engine-and-realtime.md +136 -0
  93. package/skills/perf-scout/references/gpu-and-accelerators.md +130 -0
  94. package/skills/perf-scout/references/idea-ranking.md +75 -0
  95. package/skills/perf-scout/references/io-and-batching.md +135 -0
  96. package/skills/perf-scout/references/memory-and-data-locality.md +137 -0
  97. package/skills/perf-scout/references/parallelism-and-vectorization.md +126 -0
  98. package/skills/perf-scout/references/parked-item-template.md +117 -0
  99. package/skills/perf-scout/references/peer-review-pass.md +150 -0
  100. package/skills/perf-scout/references/report-template.md +148 -0
  101. package/skills/principles/SKILL.md +678 -0
  102. package/skills/principles/references/models.md +191 -0
  103. package/skills/principles/references/subagents.md +158 -0
  104. package/skills/prose-author/SKILL.md +185 -0
  105. package/skills/refactor-conventions-creator/SKILL.md +359 -0
  106. package/skills/refactor-conventions-creator/agents/openai.yaml +6 -0
  107. package/skills/refactor-conventions-creator/references/common-structures.md +91 -0
  108. package/skills/refactor-conventions-creator/references/common-styles.md +90 -0
  109. package/skills/refactor-design/SKILL.md +384 -0
  110. package/skills/release-deploy/SKILL.md +667 -0
  111. package/skills/release-deploy/agents/openai.yaml +6 -0
  112. package/skills/research/SKILL.md +166 -0
  113. package/skills/research/agents/openai.yaml +6 -0
  114. package/skills/review/SKILL.md +267 -0
  115. package/skills/review/references/deep-review.md +98 -0
  116. package/skills/review/references/review-lenses.md +68 -0
  117. package/skills/review/references/substrate-side-effects.md +161 -0
  118. package/skills/review/references/target-resolution.md +52 -0
  119. package/skills/scope/SKILL.md +486 -0
  120. package/work-view/Cargo.lock +486 -0
  121. package/work-view/Cargo.toml +9 -0
  122. package/work-view/crates/cli/.work-view-version +1 -0
  123. package/work-view/crates/cli/Cargo.toml +18 -0
  124. package/work-view/crates/cli/src/actionable.rs +500 -0
  125. package/work-view/crates/cli/src/args.rs +792 -0
  126. package/work-view/crates/cli/src/board/assets/board.css +855 -0
  127. package/work-view/crates/cli/src/board/assets/board.js +259 -0
  128. package/work-view/crates/cli/src/board/assets/card.js +139 -0
  129. package/work-view/crates/cli/src/board/assets/components.css +290 -0
  130. package/work-view/crates/cli/src/board/assets/dependency.js +1193 -0
  131. package/work-view/crates/cli/src/board/assets/detail.js +256 -0
  132. package/work-view/crates/cli/src/board/assets/filters.js +389 -0
  133. package/work-view/crates/cli/src/board/assets/index.html +77 -0
  134. package/work-view/crates/cli/src/board/assets/kanban.js +231 -0
  135. package/work-view/crates/cli/src/board/assets/markdown.js +260 -0
  136. package/work-view/crates/cli/src/board/assets/motion.css +131 -0
  137. package/work-view/crates/cli/src/board/assets/state.js +245 -0
  138. package/work-view/crates/cli/src/board/assets/table.js +304 -0
  139. package/work-view/crates/cli/src/board/assets/tokens.css +602 -0
  140. package/work-view/crates/cli/src/board/assets/views.js +41 -0
  141. package/work-view/crates/cli/src/board/assets.rs +162 -0
  142. package/work-view/crates/cli/src/board/feed.rs +204 -0
  143. package/work-view/crates/cli/src/board/mod.rs +246 -0
  144. package/work-view/crates/cli/src/board/open.rs +144 -0
  145. package/work-view/crates/cli/src/board/server.rs +407 -0
  146. package/work-view/crates/cli/src/main.rs +195 -0
  147. package/work-view/crates/cli/src/render.rs +354 -0
  148. package/work-view/crates/cli/src/scope.rs +157 -0
  149. package/work-view/crates/cli/src/stale.rs +581 -0
  150. package/work-view/crates/cli/tests/board-js/dependency-table.test.mjs +64 -0
  151. package/work-view/crates/cli/tests/board-js/expanded-browsing.test.mjs +79 -0
  152. package/work-view/crates/cli/tests/board-js/harness-smoke.test.mjs +11 -0
  153. package/work-view/crates/cli/tests/board-js/harness.mjs +437 -0
  154. package/work-view/crates/cli/tests/board-js/kanban-detail.test.mjs +75 -0
  155. package/work-view/crates/cli/tests/board-js/markdown-filter.test.mjs +60 -0
  156. package/work-view/crates/cli/tests/fixtures/golden/.work/CONVENTIONS.md +3 -0
  157. package/work-view/crates/cli/tests/fixtures/golden/.work/active/epics/epic-alpha.md +16 -0
  158. package/work-view/crates/cli/tests/fixtures/golden/.work/active/features/feat-a.md +16 -0
  159. package/work-view/crates/cli/tests/fixtures/golden/.work/active/features/feat-b.md +16 -0
  160. package/work-view/crates/cli/tests/fixtures/golden/.work/active/stories/story-alpha-1.md +16 -0
  161. package/work-view/crates/cli/tests/fixtures/golden/.work/active/stories/story-research-1.md +19 -0
  162. package/work-view/crates/cli/tests/fixtures/golden/.work/archive/feat-done.md +16 -0
  163. package/work-view/crates/cli/tests/fixtures/golden/.work/archive/feat-shipped.md +18 -0
  164. package/work-view/crates/cli/tests/fixtures/golden/.work/backlog/idea-backlog.md +7 -0
  165. package/work-view/crates/cli/tests/fixtures/golden/.work/releases/v1.0/v1.0.md +16 -0
  166. package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/CONVENTIONS.md +6 -0
  167. package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/features/feat-dep-done.md +17 -0
  168. package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/features/feat-design-ready.md +17 -0
  169. package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/features/feat-impl-ready.md +17 -0
  170. package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/stories/story-review-ready.md +17 -0
  171. package/work-view/crates/cli/tests/fixtures/with-malformed/.work/CONVENTIONS.md +4 -0
  172. package/work-view/crates/cli/tests/fixtures/with-malformed/.work/active/epics/malformed-no-closing-fence.md +8 -0
  173. package/work-view/crates/cli/tests/fixtures/with-malformed/.work/active/features/good-item.md +16 -0
  174. package/work-view/crates/cli/tests/integration.rs +2833 -0
  175. package/work-view/crates/core/Cargo.toml +13 -0
  176. package/work-view/crates/core/src/error.rs +61 -0
  177. package/work-view/crates/core/src/filter.rs +804 -0
  178. package/work-view/crates/core/src/graph.rs +324 -0
  179. package/work-view/crates/core/src/index.rs +590 -0
  180. package/work-view/crates/core/src/lib.rs +54 -0
  181. package/work-view/crates/core/src/model.rs +202 -0
  182. package/work-view/crates/core/src/parse.rs +494 -0
  183. package/work-view/crates/core/tests/fixtures/golden/.work/CONVENTIONS.md +15 -0
  184. package/work-view/crates/core/tests/fixtures/golden/.work/active/epics/epic-core.md +16 -0
  185. package/work-view/crates/core/tests/fixtures/golden/.work/active/features/feat-parser.md +16 -0
  186. package/work-view/crates/core/tests/fixtures/golden/.work/active/features/feat-query.md +16 -0
  187. package/work-view/crates/core/tests/fixtures/golden/.work/active/stories/malformed-no-id.md +15 -0
  188. package/work-view/crates/core/tests/fixtures/golden/.work/active/stories/story-parse-unit.md +16 -0
  189. package/work-view/crates/core/tests/fixtures/golden/.work/active/stories/story-security-gate.md +16 -0
  190. package/work-view/crates/core/tests/fixtures/golden/.work/archive/feat-old.md +16 -0
  191. package/work-view/crates/core/tests/fixtures/golden/.work/archive/feat-parser.md +17 -0
  192. package/work-view/crates/core/tests/fixtures/golden/.work/backlog/idea-future-board.md +7 -0
  193. package/work-view/crates/core/tests/fixtures/golden/.work/releases/v1.0/v1.0.md +16 -0
  194. package/work-view/crates/core/tests/fixtures/precedence/.work/CONVENTIONS.md +10 -0
  195. package/work-view/crates/core/tests/fixtures/precedence/.work/archive/dup-item.md +18 -0
  196. package/work-view/crates/core/tests/fixtures/precedence/.work/releases/v2.0/dup-item.md +18 -0
  197. package/work-view/crates/core/tests/integration.rs +541 -0
  198. package/work-view/dist/.gitattributes +1 -0
  199. package/work-view/dist/README.md +42 -0
  200. package/work-view/dist/aarch64-apple-darwin/work-view +0 -0
  201. package/work-view/dist/aarch64-unknown-linux-musl/work-view +0 -0
  202. package/work-view/dist/x86_64-apple-darwin/work-view +0 -0
  203. package/work-view/dist/x86_64-unknown-linux-musl/work-view +0 -0
@@ -0,0 +1,604 @@
1
+ ---
2
+ name: implement-orchestrator
3
+ description: >
4
+ ALWAYS invoke when the user asks to implement substrate items, work through stage:implementing
5
+ items, drain the queue, or implement a feature/epic scope. Default implementation path; call
6
+ implement directly only when the user says "inline". Builds a depends_on graph, bundles related
7
+ work, chooses wave width and worktree isolation, and dispatches implementation sub-agents when
8
+ useful. This skill authorizes sub-agents, including large non-overlapping write paths when ownership
9
+ and verification make that safe. Advances parents whose children all reach stage:review.
10
+ ---
11
+
12
+ # Implement-Orchestrator
13
+
14
+ You orchestrate the implementation of one or more substrate items at
15
+ `stage: implementing`. Your value is in the prompt crafting and the
16
+ dependency-aware scheduling across whatever scope you've been given —
17
+ not in writing line-by-line code yourself. You delegate the writing to
18
+ implementation sub-agents when the work can be split productively. You determine
19
+ how to parallelize: bundles, waves, worker ownership, worktree isolation, and
20
+ serialization are your call.
21
+
22
+ ## Sub-agent contract
23
+
24
+ Invocation of this skill is explicit authorization to spawn implementation
25
+ sub-agents. Do not wait for the user to separately say "use sub-agents" once this
26
+ skill is active. The user has chosen the orchestrator because the orchestrator is
27
+ the parallelization brain.
28
+
29
+ Authorization is not a mandate to fan out before sizing the system. Do a
30
+ read-first scope probe before choosing exploratory sub-agents, bundle shape, wave width,
31
+ or worktree isolation. Direct reading is often faster and more accurate when the
32
+ work points at a known module, a small file set, or a few obvious integration
33
+ points.
34
+
35
+ Use sub-agents as the primary scaling mechanism when the work has separable
36
+ ownership. Large write paths may still run in parallel when you assign explicit
37
+ file/module ownership, tell workers they are not alone in the codebase, use
38
+ worktree isolation when overlap or merge risk warrants it, and verify integration
39
+ after each wave. Serialize only the portions whose write sets or dependency
40
+ edges make parallel work unsafe.
41
+
42
+ ### Implementation tier (settle once, before dispatch)
43
+
44
+ The worker subagent posture and effort tier are a **dial**, not a silent
45
+ default. Agile-workflow does not ship an implementation role; each worker is a
46
+ generic subagent prompted with the implementer capsule from
47
+ `../principles/references/subagents.md`. Before spawning the first wave,
48
+ determine the implementation tier:
49
+
50
+ 1. **Honor an explicit choice** — a tier named in the goal/args/user request,
51
+ an autopilot caller note, or a stable project convention (e.g. a
52
+ `.work/CONVENTIONS.md` model note), wins. Use it and skip the question.
53
+ 2. **Autopilot mode is non-interactive** — when delegated by an active
54
+ autopilot run, use the tier autopilot settled for the scoped run. If the
55
+ caller note is missing the tier, fall back to the host runtime's
56
+ medium/default **baseline** worker capability and state the fallback in the
57
+ run notes. Do not ask the user from inside an autopilot-driven implementation
58
+ pass.
59
+ 3. **All other modes ask once** — when there is no explicit/project/autopilot
60
+ choice, ask the user what implementation effort tier to use (structured
61
+ question tool when available), then lock it for the whole run; never re-ask
62
+ per wave. Pick a **baseline**, **raised**, or **highest** tier
63
+ by capability, not by name — concrete model resolution per host is in
64
+ [../principles/references/models.md](../principles/references/models.md):
65
+ - **Baseline** = write fidelity at low cost: routine, well-scoped code.
66
+ - **Raised** = deeper reasoning/stamina for multi-item, cross-module, or
67
+ orchestration-critical bundles.
68
+ - **Highest** = the strongest reasoning available for large cross-feature
69
+ write paths, risky migrations, or repeated failed attempts.
70
+ The vocabulary matches `deep-code-scan`'s scanner-tier dial so the two read
71
+ alike.
72
+
73
+ Use explicit runtime paths: spawn implementation workers through the host's
74
+ generic/code-writing subagent mechanism, with the settled effort tier and the
75
+ implementer prompt posture from `../principles/references/subagents.md`. Map
76
+ routine small/single-item bundles to the settled baseline, raise effort within
77
+ the same model family for multi-item, cross-module, or orchestration-critical
78
+ bundles, and reserve the highest tier for large cross-feature write paths,
79
+ risky migrations, difficult generated-code reconciliation, or repeated failed
80
+ attempts. Use read-only exploratory subagents prompted with the explorer capsule
81
+ at medium/high reasoning for mapping. Do not use peeragent for routine
82
+ implementation-worker fanout.
83
+
84
+ In every runtime, make each worker prompt self-contained and require one commit
85
+ per item.
86
+
87
+ ## Trigger
88
+
89
+ This is the **default implementation path** for everything at
90
+ `stage: implementing` — features (with or without children), lone stories, or
91
+ mixed batches across multiple features. Even a single ready story routes here
92
+ by default; the one-agent wave is still worth running because the grounding,
93
+ the prompt, and the post-wave verification all add value the inline `implement`
94
+ skill skips.
95
+
96
+ Reach for `/agile-workflow:implement` directly only when the delivery is **very
97
+ small** (the criteria are spelled out in that skill's trigger section: ≤ 2
98
+ files, ~≤ 50 LoC, single unit of work, no `depends_on` coordination, or land
99
+ mode). When in doubt, route here.
100
+
101
+ Common phrases:
102
+ - "implement feature X" / "implement story Y"
103
+ - "implement everything ready under epic Z"
104
+ - "fan out the implementing band"
105
+ - "drain the ready stories"
106
+
107
+ ## Scope arguments
108
+
109
+ Accept any of:
110
+
111
+ - no arg → equivalent to `--all` (the default)
112
+ - `--all` — every implementing item in `.work/active/` (regardless of parent)
113
+ - `<feature-id>` — every child story of that feature at `stage: implementing`,
114
+ plus the feature itself if it has no children
115
+ - `<epic-id>` — every implementing item transitively under that epic
116
+ - `<id> [<id>...]` — explicit list, can mix kinds and parents
117
+ - single `<story-id>` with no parent or whose parent isn't in scope — run as a
118
+ one-agent wave, advance only that story
119
+ - `<NL filter>` (e.g. "the auth stories", "everything tagged refactor") — same
120
+ shape as autopilot's free-text scope: interpret against the implementing-band
121
+ items, log the interpretation in the run summary
122
+
123
+ Disambiguation: an arg is treated as an id only if a matching file exists in
124
+ `.work/active/`. Otherwise it's an NL filter. Whatever you accept, the rest of
125
+ the workflow is the same — the difference is just which items populate the
126
+ queue at Phase 1.
127
+
128
+ ## Workflow
129
+
130
+ ### Phase 1: Resolve scope and ground yourself
131
+
132
+ First, resolve the scope arg into a concrete **work set** — the items you'll
133
+ actually drive in this run. Use `work-view` with the appropriate filters; the
134
+ exact invocation depends on what you were given:
135
+
136
+ - A feature id → its child stories at `stage: implementing`, plus the feature
137
+ itself if it has no children
138
+ - An epic id → walk the parent chain to gather every implementing item beneath
139
+ it (features without children, plus all stories)
140
+ - `--all` (or no arg) → every item under `.work/active/` at `stage: implementing`
141
+ - An explicit id list → use those items directly
142
+ - An NL filter → interpret against the implementing-band items, keep matches,
143
+ log the interpretation
144
+
145
+ Note the **set of distinct parent features** that appear in the work set. Some
146
+ items may share a parent, others may not. You'll need each distinct parent for
147
+ the grounding step and for Phase 9 advancement.
148
+
149
+ Then read deeply — the quality of your agent prompts depends on this.
150
+
151
+ 1. **Every parent feature** in the work set — full design, all units, all
152
+ referenced patterns. Read each one fully; do not skim. If the work set
153
+ spans multiple features, that's more reading, not less.
154
+ 2. **Every item in the work set** — the story or childless feature you'll
155
+ spawn an agent for. Read its body, design, acceptance criteria, and
156
+ `depends_on`.
157
+ 3. **Foundation docs** referenced by any of the above: `docs/SPEC.md`,
158
+ `docs/ARCHITECTURE.md`
159
+ 4. **Principles** — both paradigms via the auto-loaded principles skill
160
+ 5. **AGENTS.md / CLAUDE.md** — project conventions, build commands
161
+ 5a. **`.agents/rules/*.md`** (if present) — the project's force-loaded agent
162
+ rules (tag semantics, test integrity, review policy)
163
+ 6. **Concrete pattern examples** in the codebase — for each type of code the
164
+ agents will write, find an existing example. Read 3-5 key files yourself.
165
+ Use exploratory sub-agents only for breadth you can name after local search.
166
+ 7. **Discrepancies between design and repo reality** — for every file the
167
+ designs reference, confirm interfaces match. Note discrepancies for
168
+ inclusion in agent prompts.
169
+
170
+ ### Phase 1.5: Size the system before delegation
171
+
172
+ Apply the Agent Dispatch Economy principle from `principles/SKILL.md` before
173
+ spawning discovery or implementation agents. Build a quick sizing note:
174
+
175
+ - likely write roots and known files
176
+ - item count, expected edit size, and dependency layers
177
+ - unknowns that require discovery
178
+ - whether the scope is direct-read, one-Explore, or parallel-Explore sized
179
+
180
+ If the work set points at a handful of known files, read them directly and skip
181
+ Explore. If one bounded area remains fuzzy, use one focused exploratory sub-agent. If
182
+ several independent surfaces remain unknown, use parallel exploratory sub-agents with
183
+ different questions. Feed this sizing decision into bundling and wave width; do
184
+ not default to a wide wave because many items are present.
185
+
186
+ ### Phase 2: Build the dependency graph
187
+
188
+ For every item in the work set, parse its `depends_on` field. Build a unified
189
+ map across the whole scope — dependencies do not need to share a parent:
190
+
191
+ - `item-id → list of dep ids it waits on`
192
+ - `dep id → list of items that wait on it`
193
+
194
+ A story under feature A may legitimately depend on a story under feature B.
195
+ The graph treats the work set as a flat pool; parents are bookkeeping for
196
+ Phase 9, not partitions of the schedule.
197
+
198
+ Validate:
199
+ - All `depends_on` entries refer to existing items
200
+ - No cycles (`work-view --blocking` per id)
201
+ - Cross-scope deps (an item whose `depends_on` points outside the work set)
202
+ must already be at `stage: done` or terminal — if not, drop the dependent
203
+ item from this run and log it; you can't satisfy that dep here.
204
+
205
+ ### Phase 3: Bundle, schedule, and check for conflicts
206
+
207
+ #### 3a — Detect bundles
208
+
209
+ Default to **one implementation sub-agent per item**, but bundle tightly-coupled
210
+ small items into a single sub-agent when doing so produces better code than
211
+ parallel agents fighting the same module. A bundle is a group of items owned by
212
+ one implementation sub-agent that
213
+ walks them sequentially, sharing context across all of them.
214
+
215
+ Bundle a group of items together when **all** of these hold:
216
+
217
+ - **Adjacent scope.** They touch the same subdirectory, the same module family,
218
+ or files that import each other heavily. "I'd refactor these together if I
219
+ were holding the whole thing in my head" is the test.
220
+ - **Individually small.** Each item is roughly under ~200 LoC of net new/changed
221
+ code, judged from its design. Big items belong in their own agent — they
222
+ already saturate one agent's attention.
223
+ - **Shared patterns / conventions / dependencies.** They follow the same idioms,
224
+ import the same modules, or depend on each other in ways that benefit from
225
+ the agent having loaded the full context once.
226
+ - **Same dependency layer.** Every bundle member must be eligible for the same
227
+ wave — i.e. an item cannot be bundled with one of its own (transitive)
228
+ dependencies. Two items that depend on the same upstream are fine; a
229
+ parent-child dep pair is not.
230
+ - **Fits one sub-agent's context budget.** Keep each bundle small enough that
231
+ the worker can load its prompt, designs, relevant code, and verification
232
+ output without losing precision. In practice that's roughly 3–8 small items
233
+ per bundle. When in doubt, bundle smaller.
234
+
235
+ A single-item "bundle" is the common case and is fine. Don't force bundling.
236
+ The win is reserved for clusters where the coordination overhead between
237
+ parallel agents (file overlap, convention drift, repeated grounding) would
238
+ exceed the cost of sequencing them inside one head.
239
+
240
+ For each candidate bundle, record:
241
+
242
+ - `bundle-id` (synthetic, e.g. `B1`, `B2`)
243
+ - ordered item list (dependency order if intra-bundle deps exist)
244
+ - shared scope description (e.g. "auth middleware family — `src/auth/*.ts`")
245
+ - rationale (1 sentence on why these belong together)
246
+
247
+ Log every bundling decision in your run notes; surface them in the final
248
+ output so the user can audit the call.
249
+
250
+ #### 3b — Topological wave plan over bundles
251
+
252
+ Treat each bundle (single-item or multi-item) as one schedulable unit. Build
253
+ the wave plan from the unified `depends_on` graph, lifted to the bundle level:
254
+ bundle A depends on bundle B if any item in A depends on any item in B.
255
+
256
+ - **Wave 1** (parallel): all bundles whose every external dependency is at
257
+ `stage: done` (or terminal in releases/archive)
258
+ - **Wave 2** (parallel): bundles whose dependencies are wave-1 bundles
259
+ - **Wave N** (parallel): bundles whose dependencies are wave-(N-1) bundles
260
+
261
+ Choose parallelism per wave based on write-set independence, dependency edges,
262
+ runtime capacity, and verification cost. Three bundles per wave is the safe
263
+ default for ordinary mixed implementation work. You may raise that for clearly
264
+ disjoint write paths or large independent subsystems, especially with worktree
265
+ isolation. You should lower it or serialize when bundles touch the same files,
266
+ share fragile generated artifacts, or require ordered API/type evolution.
267
+
268
+ #### 3c — File-overlap conflict check (cross-bundle)
269
+
270
+ Within-bundle file overlap is already resolved — one agent owns the bundle, so
271
+ "overlap" inside it is just sequential edits. Check for overlap **across
272
+ bundles in the same wave**. If two bundles in one wave name overlapping files,
273
+ choose one of three mitigations:
274
+
275
+ - **Merge the bundles** — if they're small enough to fit one agent's budget
276
+ and the overlap is the reason they should be together, collapse them into
277
+ one bundle. Often the cleanest answer.
278
+ - **Serialize the conflicting bundles** — pull one into a later sub-wave so
279
+ they don't share a slot. Preferred when merging would blow the budget.
280
+ - **Spawn the wave with worktree isolation** — each agent gets its own
281
+ worktree, you reconcile after. Use when serialization would balloon the
282
+ wave count or when you can't predict overlap precisely.
283
+
284
+ Cross-feature bundles make this check important — siblings under one feature
285
+ usually had disjoint files by design; bundles drawn from different features
286
+ have no such guarantee.
287
+
288
+ ### Phase 4: Re-align to project standards
289
+
290
+ Re-read `AGENTS.md` and `CLAUDE.md` if both exist. Treat `AGENTS.md` as
291
+ canonical when they disagree; `CLAUDE.md` is usually a symlink or compatibility
292
+ shim. Also read `.agents/rules/*.md` (if present) — the project's force-loaded
293
+ agent rules (tag semantics, test integrity, review policy) — and
294
+ `.agents/skills/patterns/` and legacy `.claude/skills/patterns/` if present.
295
+ Recency improves prompt adherence.
296
+
297
+ ### Phase 5: Craft agent prompts
298
+
299
+ The per-bundle prompt mirrors `/agile-workflow:implement`'s workflow — same
300
+ phases, same logic — just inlined so a sub-agent can execute it self-contained.
301
+ Whatever capabilities `implement` gains over time should be reflected here too.
302
+
303
+ There are two prompt shapes depending on bundle size:
304
+
305
+ - **Single-item bundle** (1 item): the classic per-story prompt described below.
306
+ - **Multi-item bundle** (2+ items): a per-bundle prompt that walks each item in
307
+ dependency order, sharing context across all items. See "Multi-item bundle
308
+ prompts" subsection at the end.
309
+
310
+ For each **single-item** bundle, write a self-contained prompt with:
311
+
312
+ 1. **Role and goal** — one sentence with ownership framing: "You are
313
+ implementing <story-name> for feature <feature-name> — write
314
+ production-quality code that you'd be proud to have reviewed."
315
+
316
+ 2. **Land-mode check** (from implement Phase 4a) — "Before writing new code,
317
+ check if the implementation already exists in the working tree. Signals: a
318
+ 'Files in this cluster' list in the story body, retroactive-capture note,
319
+ sparse design with concrete file paths matching `git status`. If you're
320
+ in land mode: read the existing code, update the story body's design
321
+ section to reflect as-built reality, validate (typecheck/lint/test scoped
322
+ to touched packages), add tests for any meaningful behavior that lacks
323
+ them, log 'Land mode' in implementation notes, then proceed to commit."
324
+
325
+ 3. **Dep readiness check** (from implement Phase 2) — "If this story has
326
+ non-empty `depends_on`, verify each dep is at `stage: done` (or in
327
+ releases/archive). If any dep is unmet, append a one-line note and return
328
+ without advancing — don't try to implement on top of unmet deps."
329
+
330
+ 4. **Story file content** — paste the story body verbatim. Tell the agent:
331
+ "Update this file with implementation notes when done."
332
+
333
+ 5. **Parent feature design excerpt** — paste the relevant implementation units
334
+ from the item's parent feature body. Don't summarize — exact specs matter.
335
+ When the work set spans multiple features, each agent gets only the
336
+ excerpt that belongs to its item's parent (don't dump unrelated features'
337
+ designs into the prompt).
338
+
339
+ 6. **Codebase context** — concrete:
340
+ - Key file paths it will read or modify (specific, not generic)
341
+ - Existing patterns to follow with concrete codebase examples
342
+ - Discrepancies between design and repo reality you found
343
+ - Specific imports needed
344
+ - Project conventions from AGENTS.md / CLAUDE.md
345
+
346
+ 7. **Design-flaw escape hatch** (from implement guardrails) — "If during
347
+ implementation you discover a genuine design flaw, don't muscle through.
348
+ Update the story body with a `## Implementation discovery` section, set
349
+ stage back to `drafting`, and return. The orchestrator will route the
350
+ story back through the design family on the next pass."
351
+
352
+ 8. **Stage transition instruction** — "When done, update the story's
353
+ frontmatter `stage: implementing → review` and append implementation notes.
354
+ The PostToolUse hook auto-bumps `updated:`."
355
+
356
+ 9. **Verification commands** — from AGENTS.md / CLAUDE.md (e.g.,
357
+ `pnpm typecheck && pnpm lint && pnpm test`).
358
+
359
+ 10. **Commit instruction** — "After build and tests pass, commit with message
360
+ `implement: <story-id>`. Do NOT push."
361
+
362
+ 11. **Test integrity** — "When tests fail during verification: fix bad
363
+ tests (stale fixtures, drifted assertions, broken mocks) in-session.
364
+ Park real production bugs via `/agile-workflow:park` instead of
365
+ silently fixing mid-pass. Park pre-existing flakes too — don't bundle.
366
+ NEVER game a test to make it pass. A failing test that documents *why*
367
+ it fails (inline comment naming the bug, `skip` linked to a backlog
368
+ id, `xfail` with reason) is more honest than a green test that lies.
369
+ No `expect(true).toBe(true)`, no asserting on whatever the code
370
+ happens to return, no deleting a test as 'flaky' without root-causing
371
+ first."
372
+
373
+ 12. **Emotional framing** — pride in craft, permission to report blockers,
374
+ quality as aspiration not threat. Avoid pressure language.
375
+
376
+ #### Multi-item bundle prompts
377
+
378
+ For a **multi-item bundle**, write one self-contained prompt covering every
379
+ item in the bundle. The agent loads the shared context once and walks the
380
+ items sequentially, gaining coherence the parallel-agents alternative loses.
381
+ Structure the prompt as:
382
+
383
+ 1. **Bundle role and goal** — "You own a tightly-coupled cluster of N items
384
+ in <shared-scope>. Treat them as one coherent delivery — you'll walk them
385
+ in order, but the design intent crosses items. Aim for production-quality
386
+ code you'd be proud to have reviewed."
387
+
388
+ 2. **Shared context block** (loaded once for all items):
389
+ - Why these items are bundled (the rationale from Phase 3a)
390
+ - Parent-feature design excerpts relevant to the bundle (paste verbatim,
391
+ deduped — don't repeat the same excerpt per item)
392
+ - Shared codebase context: the file paths the bundle will touch, the
393
+ patterns and conventions shared across items, the imports and module
394
+ boundaries common to the cluster
395
+ - Discrepancies between design and repo reality you found that apply to
396
+ the bundle as a whole
397
+
398
+ 3. **Land-mode check** (shared) — same logic as single-item, applied per item
399
+ as the agent reaches it.
400
+
401
+ 4. **Per-item working list** — in dependency order, for each item:
402
+ - Item id and name, with a one-line goal
403
+ - Story body content verbatim
404
+ - Item-specific design excerpt (only the parts of parent-feature design
405
+ not already covered by the shared block)
406
+ - Item-specific files and conventions only-this-item touches
407
+ - Item-specific `depends_on` and the readiness check for it
408
+
409
+ 5. **Per-item execution loop** — "For each item in order: (a) verify
410
+ `depends_on` is satisfied; (b) implement; (c) run scoped verification;
411
+ (d) update the item file's body with implementation notes and advance
412
+ `stage: implementing → review`; (e) commit with message
413
+ `implement: <item-id>`; (f) move to the next item. Do NOT batch commits
414
+ across items — one commit per item keeps the substrate clean and lets
415
+ review roll back items independently."
416
+
417
+ 6. **Bundle-final verification** — "After the last item is committed, run
418
+ the full project verification commands (typecheck, lint, full test suite)
419
+ once for the whole bundle. If anything fails, fix it — the fix is part of
420
+ the bundle's delivery, not a follow-up."
421
+
422
+ 7. **Design-flaw escape hatch (per item)** — "If during implementation of
423
+ any item you discover a genuine design flaw in that item, do NOT muscle
424
+ through. Update that item's body with a `## Implementation discovery`
425
+ section, set its stage back to `drafting`, commit the items already
426
+ completed, and return. The orchestrator will route the flawed item back
427
+ through the design family on the next pass. The completed items remain
428
+ at `stage: review`."
429
+
430
+ 8. **Test integrity** — same wording as single-item; reinforce that bundle
431
+ scope is NOT a license to silence tests across items.
432
+
433
+ 9. **Emotional framing** — "Holding the whole cluster in your head is the
434
+ point of this bundle — that's what produces coherent code. Take your time
435
+ per item; the bundle isn't a race."
436
+
437
+ The bundle prompt is longer than a single-item prompt, but the agent reads
438
+ the shared context once and amortizes it across every item — that's the
439
+ budget win the bundle is buying.
440
+
441
+ ### Phase 6: Spawn sub-agents (per wave)
442
+
443
+ Spawn one implementation sub-agent per bundle, regardless of bundle size.
444
+
445
+ Spawn code-writing worker subagents through the host's generic/general-purpose
446
+ subagent mechanism, prompted with the implementer capsule and the settled effort
447
+ tier from the kickoff decision:
448
+ - baseline / host medium-default for small or single-item bundles
449
+ - raised / host high-effort for multi-item, cross-module, or orchestration-critical
450
+ bundles when the settled choice allows escalation
451
+ - highest / host maximum-effort only for large cross-feature write paths, deep
452
+ migrations, high-risk reconciliation, or repeated failed attempts, and only
453
+ when selected explicitly or permitted by the settled tier
454
+ - no model override outside the settled family/tier unless the user has named
455
+ one or the project has a stable model convention
456
+
457
+ Use the deployment's existing `Explore` role for read-only mapping only when it
458
+ is already available; agile-workflow does not ship an Explore override or any
459
+ implementation/review roles. If no suitable generic subagent adapter exists,
460
+ keep the bounded work in the host session or use the fresh-context fallback
461
+ already described by the skill.
462
+
463
+ For waves with multiple bundles, send all in a **single message** with multiple
464
+ sub-agent calls when the runtime supports parallel execution.
465
+
466
+ The `description` should make the bundle scope visible — e.g.
467
+ `"Implement B2: 4 stories under auth middleware"` for a multi-item bundle, or
468
+ `"Implement story S-12"` for a single-item bundle.
469
+
470
+ Use worktree isolation if multiple bundles in the same wave will modify
471
+ overlapping files and you chose not to merge them (see Phase 3c), or if large
472
+ independent write paths are safer to reconcile from separate worktrees. Within a
473
+ bundle, isolation is unnecessary — one sub-agent owns the whole cluster.
474
+
475
+ ### Phase 7: Review wave results
476
+
477
+ After each wave:
478
+ 1. Read each agent's result summary
479
+ 2. For each bundle: verify the agent advanced **every** item in the bundle to
480
+ `stage: review` (or back to `drafting` if a design-flaw escape hatch
481
+ fired), and wrote implementation notes on each item's body
482
+ 3. Verify the agent committed once per item (multi-item bundles produce N
483
+ commits, not 1)
484
+ 4. Run the verification commands yourself to confirm integration is clean
485
+ across all bundles in the wave
486
+
487
+ If a bundle agent fully completed only some of its items and bailed (e.g. a
488
+ design-flaw escape hatch fired on item 3 of 5), accept the partial result:
489
+ items 1–2 stay at `review`, item 3 is back at `drafting`, items 4–5 stay at
490
+ `implementing` and will be picked up next pass.
491
+
492
+ If an agent reported a blocker or left gaps:
493
+ - Small fix → make it yourself directly
494
+ - Larger issue → spawn a focused follow-up agent with a targeted prompt
495
+
496
+ Don't proceed to the next wave if the previous wave's results aren't verified.
497
+
498
+ ### Phase 8: Iterate waves until done
499
+
500
+ Continue spawning waves until every item in the work set is at `stage: review`
501
+ (or `done` if review-skipping for trivial ones, but generally items advance
502
+ to `review` only).
503
+
504
+ ### Phase 9: Advance every parent feature whose children are now all at review
505
+
506
+ For each distinct parent feature you noted during Phase 1, check whether every
507
+ one of its child stories is now at `stage: review` or `done`. A parent
508
+ qualifies for advancement when **all** of its children are terminal-or-review,
509
+ not just the subset you happened to touch in this run — children outside your
510
+ work set must also already be at one of those stages.
511
+
512
+ For each qualifying parent feature:
513
+
514
+ 1. Append a summary to its body:
515
+ - Stories implemented in this run (list with their statuses)
516
+ - Any cross-cutting deviations
517
+ - Verification status (build + tests pass)
518
+ 2. Advance its frontmatter: `stage: implementing → review`. The PostToolUse
519
+ hook bumps `updated:`.
520
+ 3. Commit it:
521
+ ```bash
522
+ git add .work/active/features/<id>.md
523
+ git commit -m "implement: <feature-id> (<N> stories ready for review)"
524
+ ```
525
+
526
+ If a parent has children outside the work set still at `stage: implementing`,
527
+ leave its stage at `implementing` — a later orchestrator run (or autopilot
528
+ pass) will pick those up and advance the parent then. Don't force-advance a
529
+ parent whose work isn't complete.
530
+
531
+ For items in the work set that have no parent feature (lone stories,
532
+ parentless items), there's nothing to advance at this phase — the items
533
+ themselves already moved to `stage: review` via their agents.
534
+
535
+ ## Output
536
+
537
+ In conversation:
538
+ - **Scope**: how the scope arg resolved (e.g., "epic E-04 → 7 stories under 3
539
+ features", or "story S-12 alone")
540
+ - **Bundles**: how the items packed into agent-sized units (e.g., "9 items →
541
+ 5 bundles: 1 multi-item bundle of 4 stories under `src/auth/*`, 1 of 2
542
+ stories under `src/billing/webhooks`, 3 single-item bundles"). Include a
543
+ one-line rationale per multi-item bundle.
544
+ - **Items advanced**: count + list, with which parent each belongs to
545
+ - **Parent features advanced to review**: list (only those whose children are
546
+ all terminal-or-review now)
547
+ - **Parent features still at implementing**: list (children outside the run
548
+ remain — note which)
549
+ - **Waves**: how many waves ran, parallelism per wave (in bundles), any
550
+ worktree isolation
551
+ - **Deviations across items**: list (or "none")
552
+ - **Verification**: build + test status
553
+ - **Next**: `/agile-workflow:review <id>` for each advanced parent or item
554
+
555
+ ## Guardrails
556
+
557
+ - Ground yourself before spawning agents. Vague prompts produce vague
558
+ implementations. Cross-feature scopes mean more reading, not less — every
559
+ parent in the work set gets the full read.
560
+ - Size the system before dispatch. If local search and direct file reads answer
561
+ the discovery question, skip exploratory fanout and record that choice. Spawn Explore
562
+ only for named unknowns or genuinely independent surfaces.
563
+ - Decide parallelism deliberately. Three sub-agents per wave is a conservative
564
+ default, not a hard ceiling. Use more only when write ownership is clear,
565
+ dependencies are independent, and verification/reconciliation remains bounded.
566
+ Use fewer when write sets overlap or the system is fragile. Bigger scopes mean
567
+ more waves or wider safe waves, scheduled by the unified `depends_on` graph
568
+ lifted to the bundle level.
569
+ - **Bundle when the cluster wants to be one delivery; don't bundle for its
570
+ own sake.** The default is still one agent per item. Reach for a multi-item
571
+ bundle only when the criteria in Phase 3a all hold — adjacent scope, small
572
+ individual items, shared patterns, same dependency layer, fits one sub-agent's
573
+ context budget. Over-bundling produces an agent that loses the thread;
574
+ under-bundling produces parallel agents that fight the same module.
575
+ - **Don't bundle a parent-child dependency pair into the same bundle.** A
576
+ bundle is a wave-slot; intra-bundle dependencies are sequenced inside the
577
+ agent prompt, but the dependency must already be satisfiable when the bundle
578
+ starts — that means deps inside a bundle only go from later items to earlier
579
+ ones in the bundle's own order, never from earlier items to later ones.
580
+ - Every agent prompt must be self-contained. Agents share no context. When
581
+ the scope spans multiple features, each agent's prompt includes only the
582
+ parent-feature design excerpt(s) relevant to its bundle's items.
583
+ - Reference paths and key signatures in prompts, not entire files. Agents
584
+ read files.
585
+ - Only reference patterns you've verified by reading.
586
+ - Run the verification commands after each wave. Integration issues only
587
+ surface at the seams between agents' work — and cross-feature waves widen
588
+ those seams. Bundle-level verification runs inside the agent; wave-level
589
+ verification is still yours.
590
+ - Check for file-overlap conflicts across bundles in Phase 3c before spawning.
591
+ Two bundles in the same wave that touch the same file is a recipe for a
592
+ merge accident — merge them, serialize them, or run with worktree isolation.
593
+ - The orchestrator (you) updates parent features' stages to `review`, NOT
594
+ individual agents. Agents only manage their own item files. And only
595
+ advance a parent whose children are *all* at `review` or terminal — partial
596
+ parents stay at `implementing`.
597
+ - **Test integrity** is reinforced in every agent prompt and again at your
598
+ post-wave verification (Phase 7). If an agent's commit silenced a test
599
+ to make it pass — deletion, broad skip, `expect(true).toBe(true)`,
600
+ asserting on whatever the code now returns — treat that as a blocker:
601
+ revert or fix yourself, and surface it in the run summary. Real
602
+ production bugs surfaced during verification get parked, not bundled.
603
+ (Note: "bundled" here means rolled into another item, the old usage —
604
+ it is unrelated to the new wave-slot bundle concept above.)