@rune-kit/rune 2.10.0 → 2.12.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 (240) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +65 -6
  3. package/commands/rune.md +168 -168
  4. package/compiler/__tests__/detect-invariants.test.js +136 -0
  5. package/compiler/__tests__/doctor-mesh.test.js +229 -0
  6. package/compiler/__tests__/hook-dispatch.test.js +91 -0
  7. package/compiler/__tests__/hooks-antigravity.test.js +118 -0
  8. package/compiler/__tests__/hooks-cursor.test.js +139 -0
  9. package/compiler/__tests__/hooks-install.test.js +305 -0
  10. package/compiler/__tests__/hooks-merge.test.js +204 -0
  11. package/compiler/__tests__/hooks-tiers.test.js +519 -0
  12. package/compiler/__tests__/hooks-windsurf.test.js +115 -0
  13. package/compiler/__tests__/inject-claude-md.test.js +152 -0
  14. package/compiler/__tests__/load-invariants.test.js +408 -0
  15. package/compiler/__tests__/onboard-invariants.test.js +240 -0
  16. package/compiler/adapters/hooks/antigravity.js +140 -0
  17. package/compiler/adapters/hooks/claude.js +166 -0
  18. package/compiler/adapters/hooks/cursor.js +191 -0
  19. package/compiler/adapters/hooks/index.js +82 -0
  20. package/compiler/adapters/hooks/tier-emitter.js +182 -0
  21. package/compiler/adapters/hooks/windsurf.js +202 -0
  22. package/compiler/bin/rune.js +196 -6
  23. package/compiler/commands/hook-dispatch.js +87 -0
  24. package/compiler/commands/hooks/install.js +120 -0
  25. package/compiler/commands/hooks/merge.js +211 -0
  26. package/compiler/commands/hooks/presets.js +116 -0
  27. package/compiler/commands/hooks/status.js +112 -0
  28. package/compiler/commands/hooks/tiers.js +221 -0
  29. package/compiler/commands/hooks/uninstall.js +94 -0
  30. package/compiler/doctor.js +236 -0
  31. package/contexts/dev.md +34 -34
  32. package/contexts/research.md +43 -43
  33. package/contexts/review.md +55 -55
  34. package/extensions/ai-ml/PACK.md +88 -88
  35. package/extensions/ai-ml/skills/ai-agents.md +172 -172
  36. package/extensions/ai-ml/skills/code-sandbox.md +187 -187
  37. package/extensions/ai-ml/skills/deep-research.md +146 -146
  38. package/extensions/ai-ml/skills/embedding-search.md +66 -66
  39. package/extensions/ai-ml/skills/fine-tuning-guide.md +74 -74
  40. package/extensions/ai-ml/skills/llm-architect.md +125 -125
  41. package/extensions/ai-ml/skills/llm-integration.md +64 -64
  42. package/extensions/ai-ml/skills/prompt-patterns.md +72 -72
  43. package/extensions/ai-ml/skills/rag-patterns.md +66 -66
  44. package/extensions/ai-ml/skills/web-extraction.md +114 -114
  45. package/extensions/analytics/PACK.md +92 -92
  46. package/extensions/analytics/skills/ab-testing.md +72 -72
  47. package/extensions/analytics/skills/dashboard-patterns.md +83 -83
  48. package/extensions/analytics/skills/data-validation.md +68 -68
  49. package/extensions/analytics/skills/funnel-analysis.md +81 -81
  50. package/extensions/analytics/skills/sql-patterns.md +57 -57
  51. package/extensions/analytics/skills/statistical-analysis.md +79 -79
  52. package/extensions/analytics/skills/tracking-setup.md +71 -71
  53. package/extensions/backend/PACK.md +104 -104
  54. package/extensions/backend/skills/api-patterns.md +84 -84
  55. package/extensions/backend/skills/async-pipeline.md +193 -193
  56. package/extensions/backend/skills/auth-patterns.md +97 -97
  57. package/extensions/backend/skills/background-jobs.md +133 -133
  58. package/extensions/backend/skills/caching-patterns.md +108 -108
  59. package/extensions/backend/skills/cli-generation.md +133 -133
  60. package/extensions/backend/skills/database-patterns.md +87 -87
  61. package/extensions/backend/skills/middleware-patterns.md +104 -104
  62. package/extensions/chrome-ext/PACK.md +93 -93
  63. package/extensions/chrome-ext/skills/cws-preflight.md +143 -143
  64. package/extensions/chrome-ext/skills/cws-publish.md +104 -104
  65. package/extensions/chrome-ext/skills/ext-ai-integration.md +251 -251
  66. package/extensions/chrome-ext/skills/ext-messaging.md +139 -139
  67. package/extensions/chrome-ext/skills/ext-storage.md +133 -133
  68. package/extensions/chrome-ext/skills/mv3-scaffold.md +164 -164
  69. package/extensions/content/PACK.md +96 -96
  70. package/extensions/content/skills/blog-patterns.md +88 -88
  71. package/extensions/content/skills/cms-integration.md +131 -131
  72. package/extensions/content/skills/content-scoring.md +107 -107
  73. package/extensions/content/skills/i18n.md +83 -83
  74. package/extensions/content/skills/mdx-authoring.md +137 -137
  75. package/extensions/content/skills/reference.md +1014 -1014
  76. package/extensions/content/skills/seo-patterns.md +67 -67
  77. package/extensions/content/skills/video-repurpose.md +153 -153
  78. package/extensions/devops/PACK.md +101 -101
  79. package/extensions/devops/skills/chaos-testing.md +67 -67
  80. package/extensions/devops/skills/ci-cd.md +75 -75
  81. package/extensions/devops/skills/docker.md +58 -58
  82. package/extensions/devops/skills/edge-serverless.md +163 -163
  83. package/extensions/devops/skills/infra-as-code.md +158 -158
  84. package/extensions/devops/skills/kubernetes.md +110 -110
  85. package/extensions/devops/skills/monitoring.md +57 -57
  86. package/extensions/devops/skills/server-setup.md +64 -64
  87. package/extensions/devops/skills/ssl-domain.md +42 -42
  88. package/extensions/ecommerce/PACK.md +116 -116
  89. package/extensions/ecommerce/skills/cart-system.md +79 -79
  90. package/extensions/ecommerce/skills/inventory-mgmt.md +102 -102
  91. package/extensions/ecommerce/skills/order-management.md +126 -126
  92. package/extensions/ecommerce/skills/payment-integration.md +472 -472
  93. package/extensions/ecommerce/skills/shopify-dev.md +69 -69
  94. package/extensions/ecommerce/skills/subscription-billing.md +93 -93
  95. package/extensions/ecommerce/skills/tax-compliance.md +117 -117
  96. package/extensions/gamedev/PACK.md +142 -142
  97. package/extensions/gamedev/skills/asset-pipeline.md +74 -74
  98. package/extensions/gamedev/skills/audio-system.md +129 -129
  99. package/extensions/gamedev/skills/camera-system.md +87 -87
  100. package/extensions/gamedev/skills/ecs.md +98 -98
  101. package/extensions/gamedev/skills/game-loops.md +72 -72
  102. package/extensions/gamedev/skills/input-system.md +199 -199
  103. package/extensions/gamedev/skills/multiplayer.md +180 -180
  104. package/extensions/gamedev/skills/particles.md +105 -105
  105. package/extensions/gamedev/skills/physics-engine.md +89 -89
  106. package/extensions/gamedev/skills/scene-management.md +146 -146
  107. package/extensions/gamedev/skills/threejs-patterns.md +90 -90
  108. package/extensions/gamedev/skills/webgl.md +71 -71
  109. package/extensions/mobile/PACK.md +106 -106
  110. package/extensions/mobile/skills/app-store-connect.md +152 -152
  111. package/extensions/mobile/skills/app-store-prep.md +66 -66
  112. package/extensions/mobile/skills/deep-linking.md +109 -109
  113. package/extensions/mobile/skills/flutter.md +60 -60
  114. package/extensions/mobile/skills/ios-build-pipeline.md +142 -142
  115. package/extensions/mobile/skills/native-bridge.md +66 -66
  116. package/extensions/mobile/skills/ota-updates.md +97 -97
  117. package/extensions/mobile/skills/push-notifications.md +111 -111
  118. package/extensions/mobile/skills/react-native.md +82 -82
  119. package/extensions/saas/PACK.md +116 -116
  120. package/extensions/saas/skills/billing-integration.md +200 -200
  121. package/extensions/saas/skills/feature-flags.md +130 -130
  122. package/extensions/saas/skills/multi-tenant.md +103 -103
  123. package/extensions/saas/skills/onboarding-flow.md +139 -139
  124. package/extensions/saas/skills/subscription-flow.md +95 -95
  125. package/extensions/saas/skills/team-management.md +144 -144
  126. package/extensions/security/PACK.md +99 -99
  127. package/extensions/security/skills/api-security.md +140 -140
  128. package/extensions/security/skills/compliance.md +68 -68
  129. package/extensions/security/skills/owasp-audit.md +64 -64
  130. package/extensions/security/skills/pentest-patterns.md +77 -77
  131. package/extensions/security/skills/secret-mgmt.md +65 -65
  132. package/extensions/security/skills/supply-chain.md +65 -65
  133. package/extensions/trading/PACK.md +80 -80
  134. package/extensions/trading/skills/chart-components.md +55 -55
  135. package/extensions/trading/skills/experiment-loop.md +125 -125
  136. package/extensions/trading/skills/fintech-patterns.md +47 -47
  137. package/extensions/trading/skills/indicator-library.md +58 -58
  138. package/extensions/trading/skills/quant-analysis.md +111 -111
  139. package/extensions/trading/skills/realtime-data.md +58 -58
  140. package/extensions/trading/skills/trade-logic.md +104 -104
  141. package/extensions/ui/PACK.md +130 -130
  142. package/extensions/ui/skills/a11y-audit.md +91 -91
  143. package/extensions/ui/skills/animation-patterns.md +127 -127
  144. package/extensions/ui/skills/component-patterns.md +100 -100
  145. package/extensions/ui/skills/design-decision.md +108 -108
  146. package/extensions/ui/skills/design-system.md +68 -68
  147. package/extensions/ui/skills/landing-patterns.md +155 -155
  148. package/extensions/ui/skills/palette-picker.md +173 -173
  149. package/extensions/ui/skills/react-health.md +90 -90
  150. package/extensions/ui/skills/type-system.md +125 -125
  151. package/extensions/ui/skills/web-vitals.md +153 -153
  152. package/extensions/zalo/PACK.md +145 -145
  153. package/extensions/zalo/skills/zalo-oa-mcp.md +317 -317
  154. package/extensions/zalo/skills/zalo-oa-messaging.md +429 -429
  155. package/extensions/zalo/skills/zalo-oa-setup.md +236 -236
  156. package/extensions/zalo/skills/zalo-oa-webhook.md +189 -189
  157. package/extensions/zalo/skills/zalo-personal-messaging.md +194 -194
  158. package/extensions/zalo/skills/zalo-personal-setup.md +153 -153
  159. package/extensions/zalo/skills/zalo-rate-guard.md +219 -219
  160. package/hooks/auto-format/index.cjs +48 -48
  161. package/hooks/hooks.json +111 -111
  162. package/hooks/post-session-reflect/index.cjs +189 -189
  163. package/hooks/pre-compact/index.cjs +95 -95
  164. package/hooks/run-hook.cmd +1 -1
  165. package/hooks/secrets-scan/index.cjs +100 -100
  166. package/hooks/session-start/index.cjs +71 -71
  167. package/hooks/typecheck/index.cjs +65 -65
  168. package/package.json +63 -63
  169. package/references/ui-pro-max-data/LICENSE-UI-PRO-MAX +21 -21
  170. package/references/ui-pro-max-data/charts.csv +26 -26
  171. package/references/ui-pro-max-data/colors.csv +161 -161
  172. package/references/ui-pro-max-data/styles.csv +68 -68
  173. package/references/ui-pro-max-data/typography.csv +74 -74
  174. package/references/ui-pro-max-data/ui-reasoning.csv +162 -162
  175. package/references/ui-pro-max-data/ux-guidelines.csv +99 -99
  176. package/skills/adversary/SKILL.md +283 -283
  177. package/skills/asset-creator/SKILL.md +157 -157
  178. package/skills/audit/SKILL.md +147 -2
  179. package/skills/autopsy/SKILL.md +335 -335
  180. package/skills/ba/SKILL.md +85 -1
  181. package/skills/brainstorm/SKILL.md +380 -342
  182. package/skills/browser-pilot/SKILL.md +169 -168
  183. package/skills/constraint-check/SKILL.md +165 -165
  184. package/skills/context-engine/SKILL.md +408 -404
  185. package/skills/cook/SKILL.md +917 -863
  186. package/skills/db/SKILL.md +273 -273
  187. package/skills/debug/SKILL.md +465 -465
  188. package/skills/dependency-doctor/SKILL.md +265 -235
  189. package/skills/deploy/SKILL.md +274 -231
  190. package/skills/design/DESIGN-REFERENCE.md +365 -365
  191. package/skills/design/SKILL.md +590 -589
  192. package/skills/doc-processor/SKILL.md +254 -254
  193. package/skills/docs/SKILL.md +374 -374
  194. package/skills/docs-seeker/SKILL.md +178 -177
  195. package/skills/fix/SKILL.md +332 -330
  196. package/skills/git/SKILL.md +339 -339
  197. package/skills/hallucination-guard/SKILL.md +220 -219
  198. package/skills/incident/SKILL.md +254 -253
  199. package/skills/integrity-check/SKILL.md +169 -169
  200. package/skills/journal/SKILL.md +241 -240
  201. package/skills/launch/SKILL.md +344 -344
  202. package/skills/logic-guardian/SKILL.md +269 -251
  203. package/skills/marketing/SKILL.md +351 -289
  204. package/skills/mcp-builder/SKILL.md +425 -425
  205. package/skills/neural-memory/SKILL.md +359 -362
  206. package/skills/onboard/SKILL.md +432 -403
  207. package/skills/onboard/references/invariants-template.md +76 -0
  208. package/skills/onboard/scripts/detect-invariants.js +439 -0
  209. package/skills/onboard/scripts/inject-claude-md.js +150 -0
  210. package/skills/onboard/scripts/onboard-invariants.js +194 -0
  211. package/skills/perf/SKILL.md +347 -346
  212. package/skills/plan/SKILL.md +435 -428
  213. package/skills/preflight/SKILL.md +415 -415
  214. package/skills/problem-solver/SKILL.md +380 -284
  215. package/skills/rescue/SKILL.md +474 -474
  216. package/skills/research/SKILL.md +4 -0
  217. package/skills/retro/SKILL.md +3 -1
  218. package/skills/review/SKILL.md +614 -588
  219. package/skills/review-intake/SKILL.md +249 -249
  220. package/skills/safeguard/SKILL.md +200 -200
  221. package/skills/sast/SKILL.md +190 -190
  222. package/skills/scaffold/SKILL.md +328 -287
  223. package/skills/scope-guard/SKILL.md +183 -180
  224. package/skills/scout/SKILL.md +269 -263
  225. package/skills/sentinel/SKILL.md +384 -381
  226. package/skills/sentinel-env/SKILL.md +254 -254
  227. package/skills/sequential-thinking/SKILL.md +234 -234
  228. package/skills/session-bridge/SKILL.md +595 -543
  229. package/skills/session-bridge/scripts/load-invariants.js +397 -0
  230. package/skills/skill-forge/SKILL.md +581 -581
  231. package/skills/skill-router/SKILL.md +3 -0
  232. package/skills/slides/SKILL.md +19 -0
  233. package/skills/surgeon/SKILL.md +215 -215
  234. package/skills/team/SKILL.md +557 -537
  235. package/skills/test/SKILL.md +620 -614
  236. package/skills/trend-scout/SKILL.md +145 -145
  237. package/skills/verification/SKILL.md +334 -326
  238. package/skills/video-creator/SKILL.md +201 -201
  239. package/skills/watchdog/SKILL.md +168 -168
  240. package/skills/worktree/SKILL.md +140 -140
@@ -1,537 +1,557 @@
1
- ---
2
- name: team
3
- description: "Multi-agent meta-orchestrator. Use when task spans 5+ files or 3+ modules, or when user says 'parallel', 'split this up', 'do all of these'. Decomposes large tasks into parallel workstreams, assigns to isolated cook instances, coordinates merging."
4
- context: fork
5
- agent: general-purpose
6
- metadata:
7
- author: runedev
8
- version: "0.8.0"
9
- layer: L1
10
- model: opus
11
- group: orchestrator
12
- tools: "Read, Write, Edit, Bash, Glob, Grep"
13
- emit: phase.complete
14
- ---
15
-
16
- # team
17
-
18
- ## Purpose
19
-
20
- Meta-orchestrator for complex tasks requiring parallel workstreams. Team decomposes large features into independent subtasks, assigns each to an isolated cook instance (using git worktrees), coordinates progress, and merges results. Uses opus for strategic decomposition and conflict resolution.
21
-
22
- <HARD-GATE>
23
- - MAX 3 PARALLEL AGENTS: Never launch more than 3 Task calls simultaneously. If more than 3 streams exist, batch them.
24
- - No merge without conflict resolution complete (Phase 3 clean).
25
- - Full integration tests MUST run before reporting success.
26
- </HARD-GATE>
27
-
28
- ## Triggers
29
-
30
- - `/rune team <task>` — manual invocation for large features
31
- - Auto-trigger: when task affects 5+ files or spans 3+ modules
32
-
33
- ## Mode Selection (Auto-Detect)
34
-
35
- ```
36
- IF streams ≤ 2 AND total files ≤ 5:
37
- → LITE MODE (lightweight parallel, no worktrees)
38
- ELSE:
39
- → FULL MODE (worktree isolation, opus coordination)
40
- ```
41
-
42
- ### Lite Mode
43
-
44
- For small parallel tasks that don't warrant full worktree isolation:
45
-
46
- ```
47
- Lite Mode Rules:
48
- - Max 2 parallel agents (haiku coordination, sonnet workers)
49
- - NO worktree creation — agents work on same branch
50
- - File ownership still enforced (disjoint file sets)
51
- - Simplified merge: sequential git add (no merge conflicts possible with disjoint files)
52
- - Skip Phase 3 (COORDINATE) — no conflicts with disjoint files
53
- - Skip integrity-check — small scope, direct output review
54
- - Coordinator model: haiku (not opus) — saves cost
55
-
56
- Lite Mode Phases:
57
- Phase 1: DECOMPOSE (haiku) — identify 2 streams with disjoint files
58
- Phase 2: ASSIGN — launch 2 parallel Task agents (sonnet, no worktree)
59
- Phase 4: MERGE — sequential git add (no merge needed)
60
- Phase 5: VERIFY — integration tests on result
61
- ```
62
-
63
- **Announce mode**: "Team lite mode: 2 streams, ≤5 files, no worktrees needed."
64
- **Override**: User can say "full mode" to force worktree isolation.
65
-
66
- ### Full Mode
67
-
68
- Standard team workflow with worktree isolation (Phases 1-5 as documented below).
69
-
70
- ### Complexity Tiers (DAG Stage Selection)
71
-
72
- Before decomposing, classify the task into a complexity tier. Each tier defines a different DAG (directed acyclic graph) of stages, ensuring the right amount of process for the task's complexity.
73
-
74
- | Tier | Signals | DAG Stages | Context Windows |
75
- |------|---------|------------|-----------------|
76
- | **Trivial** | ≤3 files, single module, no shared contracts | impl → test | 1 (single cook) |
77
- | **Medium** | 4-10 files, 2-3 modules, shared interfaces | research → plan → impl → test → review → fix | 3 (plan, impl+test, review+fix) |
78
- | **Large** | 10+ files, 3+ modules, breaking changes or RFC | research → plan → impl → test → review₁ → fix → review₂ → final merge | 4+ (plan, impl+test, review₁+fix, review₂+merge) |
79
-
80
- **Key principle — reviewer isolation**: The agent that writes code MUST NOT review its own code. Each review stage uses a **separate context window** (separate Task invocation) that has never seen the implementation reasoning. This prevents author bias from contaminating the review.
81
-
82
- **Stage → Context Window mapping**:
83
- - `research + plan` = Context Window 1 (opus — architectural reasoning)
84
- - `impl + test` = Context Window 2 (sonnet — code writing)
85
- - `review₁ + fix` = Context Window 3 (sonnet — fresh eyes, no impl context)
86
- - `review₂ + merge` = Context Window 4 (sonnet — final verification, Large tier only)
87
-
88
- **Merge queue**: When multiple streams complete at different times, use dependency order for merging. If a later stream's merge creates conflicts with an already-merged stream, provide the conflicting stream's cook report as **conflict context** to the resolution agent — never resolve blindly.
89
-
90
- ## Calls (outbound)
91
-
92
- - `plan` (L2): high-level task decomposition into independent workstreams
93
- - `scout` (L2): understand full project scope and module boundaries
94
- # Exception: L1→L1 meta-orchestration (team is the only L1 that calls other L1s)
95
- - `cook` (L1): delegate feature tasks to parallel instances (worktree isolation)
96
- - `launch` (L1): delegate deployment/marketing when build is complete
97
- - `rescue` (L1): delegate legacy refactoring when rescue work detected
98
- - `integrity-check` (L3): verify cook report integrity before merge
99
- - `completion-gate` (L3): validate workstream completion claims against evidence
100
- - `constraint-check` (L3): audit HARD-GATE compliance across parallel streams
101
- - `worktree` (L3): create isolated worktrees for parallel cook instances
102
- - `context-pack` (L3): create structured handoff briefings before spawning subagents
103
- - L4 extension packs: domain-specific patterns when context matches (e.g., @rune/mobile when porting web to mobile)
104
-
105
- ## Called By (inbound)
106
-
107
- - User: `/rune team <task>` direct invocation only
108
-
109
- ---
110
-
111
- ## Execution
112
-
113
- ### Step 0 — Initialize TodoWrite
114
-
115
- ```
116
- TodoWrite([
117
- { content: "DECOMPOSE: Scout modules and plan workstreams", status: "pending", activeForm: "Decomposing task into workstreams" },
118
- { content: "ASSIGN: Launch parallel cook agents in worktrees", status: "pending", activeForm: "Assigning streams to cook agents" },
119
- { content: "COORDINATE: Monitor streams, resolve conflicts", status: "pending", activeForm: "Coordinating parallel streams" },
120
- { content: "MERGE: Merge worktrees back to main", status: "pending", activeForm: "Merging worktrees to main" },
121
- { content: "VERIFY: Run integration tests on merged result", status: "pending", activeForm: "Verifying integration" }
122
- ])
123
- ```
124
-
125
- ---
126
-
127
- ### Phase 1 — DECOMPOSE
128
-
129
- Mark todo[0] `in_progress`.
130
-
131
- **1a. Map module boundaries.**
132
-
133
- ```
134
- REQUIRED SUB-SKILL: rune:scout
135
- → Invoke `scout` with the full task description.
136
- Scout returns: module list, file ownership map, dependency graph.
137
- Capture: which modules are independent vs. coupled.
138
- ```
139
-
140
- **1b. Break into workstreams.**
141
-
142
- ```
143
- REQUIRED SUB-SKILL: rune:plan
144
- → Invoke `plan` with scout output + task description.
145
- Plan returns: ordered list of workstreams, each with:
146
- - stream_id: "A" | "B" | "C" (max 3)
147
- - task: specific sub-task description
148
- - files: list of files this stream owns
149
- - depends_on: [] | ["B"] (empty = parallel-safe)
150
- ```
151
-
152
- **1c. Validate decomposition.**
153
-
154
- ```
155
- GATE CHECK — before proceeding:
156
- [ ] Each stream owns disjoint file sets (no overlap)
157
- [ ] No coupled modules across streams:
158
- Use Grep to find import/require statements in each stream's owned files
159
- If stream A files import from stream B files → flag as COUPLED
160
- COUPLED modules MUST be moved to same stream OR stream B added to A's depends_on
161
- [ ] Dependent streams have explicit depends_on declared
162
- [ ] Total streams 3
163
- [ ] Change Stacking check: no file appears in touches[] of 2+ parallel streams
164
- [ ] Every stream's requires[] is satisfied by a prior stream's provides[] or existing code
165
-
166
- If any check fails re-invoke plan with conflict notes.
167
- ```
168
-
169
- **1d. Question Gate (non-trivial tasks only).**
170
-
171
- > From superpowers (obra/superpowers, 84k★): "Subagents that start work without asking questions produce the wrong thing 40% of the time."
172
-
173
- Before dispatching streams, include in each NEXUS Handoff: "Before starting, ask up to 3 clarifying questions if anything is unclear about scope, conventions, or expected output."
174
-
175
- - If a cook agent returns questions instead of starting work answer them, then re-dispatch
176
- - If a cook agent starts work without questions → proceed normally (questions are invited, not required)
177
- - **Skip if**: Lite mode (2 streams, ≤5 files) overhead exceeds value
178
-
179
- Mark todo[0] `completed`.
180
-
181
- ---
182
-
183
- ### Phase 2 — ASSIGN
184
-
185
- Mark todo[1] `in_progress`.
186
-
187
- **2a. Launch parallel streams.**
188
-
189
- Launch independent streams (depends_on: []) in parallel using Task tool with worktree isolation.
190
-
191
- > From agency-agents (msitarzewski/agency-agents, 50.8k★): "Structured handoff docs prevent the #1 multi-agent failure: context loss between agents."
192
-
193
- Each stream receives a **NEXUS Handoff Template** not a bare prompt:
194
-
195
- ```
196
- For each stream where depends_on == []:
197
- Task(
198
- subagent_type: "general-purpose",
199
- model: "sonnet",
200
- isolation: "worktree",
201
- prompt: <NEXUS Handoff below>
202
- )
203
- ```
204
-
205
- **NEXUS Handoff Template** (sent to each cook instance):
206
-
207
- ```markdown
208
- ## NEXUS Handoff: Stream [id]
209
-
210
- ### Metadata
211
- - Stream: [id] of [total]
212
- - Depends on: [none | stream ids]
213
- - File ownership: [list ONLY these files may be modified]
214
- - Model: sonnet
215
-
216
- ### Context
217
- - Project: [project name and type]
218
- - Overall goal: [1-line feature description]
219
- - This stream's goal: [specific sub-task]
220
- - Conventions: [key patterns from scout — naming, file structure, test framework]
221
-
222
- ### Deliverable
223
- - [ ] [specific outcome 1 — e.g., "AuthService with login/register/reset methods"]
224
- - [ ] [specific outcome 2 — e.g., "Unit tests covering happy path + 3 error cases"]
225
- - [ ] [specific outcome 3 — e.g., "Types exported for Phase 2 consumers"]
226
-
227
- ### Quality Expectations
228
- - Tests: must pass with evidence (stdout captured)
229
- - Types: no `any`, strict mode
230
- - Security: no hardcoded secrets, parameterized queries
231
- - Conventions: [project-specific from scout output]
232
-
233
- ### Evidence Required
234
- Return a Cook Report with:
235
- - Exact files modified (git diff --stat)
236
- - Test output (stdout — not just "tests pass")
237
- - Any CONCERNS discovered during implementation
238
- ```
239
-
240
- **2b. Launch dependent streams sequentially.**
241
-
242
- ```
243
- For each stream where depends_on != []:
244
- WAIT for all depends_on streams to complete.
245
- Then launch with NEXUS Handoff that includes:
246
- - Completed stream's deliverables as "Available Context"
247
- - Exported interfaces/types from prior streams in "Code Contracts" section
248
- - Any CONCERNS from prior streams in "Known Issues" section
249
- ```
250
-
251
- **2b.5. Pre-merge scope verification.**
252
-
253
- After each stream completes (before collecting final report):
254
-
255
- ```
256
- Bash: git diff --name-only main...[worktree-branch]
257
- → Compare actual modified files vs stream's planned file ownership list.
258
- If agent modified files OUTSIDE its declared scope:
259
- FLAG: "Stream [id] modified [file] outside its scope."
260
- Present to user for approval before proceeding to merge.
261
- If all files within scope: proceed normally.
262
- ```
263
-
264
- This catches scope creep BEFORE merge — much cheaper to fix than after.
265
-
266
- **2c. Collect cook reports.**
267
-
268
- Wait for all Task calls to return. Store each cook report keyed by stream_id.
269
-
270
- ```
271
- Error recovery:
272
- If a Task fails or returns error report:
273
- Log failure: "Stream [id] failed: [error]"
274
- If stream is non-blocking: continue with other streams
275
- If stream is blocking (others depend on it): STOP, report to user with partial results
276
- ```
277
-
278
- Mark todo[1] `completed`.
279
-
280
- ---
281
-
282
- ### Phase 3 — COORDINATE
283
-
284
- Mark todo[2] `in_progress`.
285
-
286
- **3a. Check for file conflicts.**
287
-
288
- ```
289
- Bash: git diff --name-only [worktree-a-branch] [worktree-b-branch]
290
- ```
291
-
292
- If overlapping files detected between completed worktrees:
293
- - Identify the conflict source from cook reports
294
- - Determine which stream's version takes precedence (later stream wins by default)
295
- - Flag for manual resolution if ambiguous — present to user before merge
296
-
297
- **3a.5. Verify cook report integrity.**
298
-
299
- ```
300
- REQUIRED SUB-SKILL: rune:integrity-check
301
- → Invoke integrity-check on each cook report text.
302
- If any report returns TAINTED:
303
- BLOCK this stream from merge.
304
- Report: "Stream [id] cook report contains adversarial content."
305
- If SUSPICIOUS: warn user, ask for confirmation before merge.
306
- ```
307
-
308
- **3b. Review cook report summaries.**
309
-
310
- For each completed stream, verify cook report contains:
311
- - Files modified
312
- - Tests passing
313
- - No unresolved TODOs or sentinel CRITICAL flags
314
-
315
- ```
316
- Error recovery:
317
- If cook report contains sentinel CRITICAL:
318
- BLOCK this stream from merge
319
- Report: "Stream [id] blocked: CRITICAL issue in [file] — [details]"
320
- Present to user for decision before continuing
321
- ```
322
-
323
- **3c. Evaluate subagent status per stream.**
324
-
325
- Each cook instance MUST have returned one of four statuses. Team handles them as follows:
326
-
327
- | Cook Status | Team Action |
328
- |-------------|-------------|
329
- | `DONE` | Stream cleared for merge — proceed normally |
330
- | `DONE_WITH_CONCERNS` | Stream cleared for merge, BUT trigger **cross-workstream review**: check if the concern impacts any other stream's files or contracts before merging ALL streams. Log concern in Team Report. |
331
- | `NEEDS_CONTEXT` | Stream paused present the specific question to user. Resume that stream after answer. Other independent streams may continue in parallel. |
332
- | `BLOCKED` | Stream blocked from merge. If stream has no dependents continue with remaining streams and report partial completion. If stream has dependents STOP all dependent streams, present to user with full blocker details. |
333
-
334
- **Cross-workstream review (triggered by any DONE_WITH_CONCERNS)**:
335
-
336
- ```
337
- 1. Read the concern from the cook report
338
- 2. Check if the concern touches shared contracts, interfaces, or shared files
339
- Use Grep to find the concern's affected symbols/files across all worktrees
340
- 3. If concern is isolated to stream's own files proceed to merge (concern logged only)
341
- 4. If concern crosses stream boundaries resolve before merge:
342
- Present to user with: affected streams, concern details, two remediation options
343
- Do NOT merge any stream until user decides
344
- ```
345
-
346
- Mark todo[2] `completed`.
347
-
348
- ---
349
-
350
- ### Phase 4 — MERGE
351
-
352
- Mark todo[3] `in_progress`.
353
-
354
- **4a. Merge each worktree sequentially.**
355
-
356
- ```
357
- # Bookmark before any merge
358
- Bash: git tag pre-team-merge
359
-
360
- For each stream in dependency order (independent first, dependent last):
361
-
362
- Bash: git checkout main
363
- Bash: git merge --no-ff [worktree-branch] -m "merge: stream [id] — [stream.task]"
364
-
365
- If merge conflict:
366
- Bash: git status (identify conflicting files)
367
- If ≤3 conflicting files:
368
- Resolve using cook report guidance (stream's intended change wins)
369
- Bash: git add [resolved-files]
370
- Bash: git merge --continue
371
- If >3 conflicting files OR ambiguous ownership:
372
- STOP merge
373
- Bash: git merge --abort
374
- Present to user: "Stream [id] has [N] conflicts. Manual resolution required."
375
- ```
376
-
377
- **4b. Cleanup worktrees.**
378
-
379
- ```
380
- Bash: git worktree remove [worktree-path] --force
381
- ```
382
-
383
- (Repeat for each worktree after its branch is merged.)
384
-
385
- Mark todo[3] `completed`.
386
-
387
- ---
388
-
389
- ### Phase 5 — VERIFY
390
-
391
- Mark todo[4] `in_progress`.
392
-
393
- ```
394
- REQUIRED SUB-SKILL: rune:verification
395
- → Invoke `verification` on the merged main branch.
396
- verification runs: type check, lint, unit tests, integration tests.
397
- Capture: passed count, failed count, coverage %.
398
- ```
399
-
400
- ```
401
- Error recovery:
402
- If verification fails after merge:
403
- Rollback all merges:
404
- Bash: git reset --hard pre-team-merge
405
- Bash: git tag -d pre-team-merge
406
- Report: "Integration tests failed. All merges reverted to pre-team-merge state."
407
- Present fix options to user
408
- ```
409
-
410
- Mark todo[4] `completed`.
411
-
412
- ---
413
-
414
- ## Constraints
415
-
416
- 1. MUST NOT launch more than 3 parallel agents — batch if more streams exist
417
- 2. MUST define clear scope boundaries per agent before dispatch — no overlapping file ownership
418
- 3. MUST resolve all merge conflicts before declaring completionno "fix later"
419
- 4. MUST NOT let agents modify the same filesplit by file ownership
420
- 5. MUST collect and review all agent outputs before merging — no blind merge
421
- 6. MUST NOT skip the integration verification after merge
422
-
423
- ## Mesh Gates
424
-
425
- | Gate | Requires | If Missing |
426
- |------|----------|------------|
427
- | Scope Gate | Each agent has explicit file ownership list | Define boundaries before dispatch |
428
- | Conflict Gate | Zero merge conflicts after integration | Resolve all conflicts, re-verify |
429
- | Verification Gate | All tests pass after merge | Fix regressions before completion |
430
-
431
- ## Output Format
432
-
433
- ```
434
- ## Team Report: [Task Name]
435
- - **Streams**: [count]
436
- - **Status**: complete | partial | blocked
437
- - **Duration**: [time across streams]
438
-
439
- ### Streams
440
- | Stream | Task | Status | Deliverables | Concerns |
441
- |--------|------|--------|-------------|----------|
442
- | A | [task] | DONE | 3/3 delivered | None |
443
- | B | [task] | DONE_WITH_CONCERNS | 2/2 delivered | Perf regression on large input |
444
- | C | [task] | DONE | 2/2 delivered | None |
445
-
446
- ### Acceptance Criteria
447
- | # | Criterion | Stream | Evidence | Verdict |
448
- |---|-----------|--------|----------|---------|
449
- | 1 | Auth endpoints return JWT | A | Test stdout: "3 passed" | PASS |
450
- | 2 | No SQL injection | A | Sentinel: PASS | PASS |
451
- | 3 | Dashboard loads < 2s | B | No perf test run | UNVERIFIED |
452
-
453
- ### Integration
454
- - Merge conflicts: [count]
455
- - Integration tests: [passed]/[total]
456
- - Coverage: [%]
457
- - Unresolved concerns: [count — from DONE_WITH_CONCERNS streams]
458
- ```
459
-
460
- ---
461
-
462
- ## Parallel Execution Rules
463
-
464
- ```
465
- Independent streams → PARALLEL (max 3 sonnet agents)
466
- Dependent streams → SEQUENTIAL (respecting dependency order)
467
- All streams done MERGE sequentially (avoid conflicts)
468
- ```
469
-
470
- ## Returns
471
-
472
- | Artifact | Format | Location |
473
- |----------|--------|----------|
474
- | Workstream assignments | Markdown (inline) | NEXUS Handoff Templates emitted per stream |
475
- | Cook Reports (per stream) | Markdown (inline) | Collected from each parallel cook instance |
476
- | Merged implementation | Source files | `main` branch after Phase 4 merge |
477
- | Integration test results | Inline stdout | Captured in Phase 5 verify |
478
- | Team Report | Markdown (inline) | Emitted at end of session |
479
-
480
- ## Document Ownership
481
-
482
- | Scope | Access | Files |
483
- |-------|--------|-------|
484
- | **Owns** (read + write) | `.rune/team-report-*.md`, worktree branches, merge commits |
485
- | **Reads** (never writes) | `.rune/plan-*.md`, `.rune/contract.md`, `CLAUDE.md`, cook reports from sub-agents |
486
- | **Never modifies** | Source files directly (delegates to cook instances), `SKILL.md` files, `compiler/**` |
487
-
488
- Each cook instance owns its declared file set (disjoint). Team owns coordination artifacts only never touches source code directly.
489
-
490
- ## Anti-Patterns
491
-
492
- Common multi-agent orchestration failures. These cause the most expensive rework in team workflows.
493
-
494
- | Anti-Pattern | Why It Fails | Correct Approach |
495
- |---|---|---|
496
- | **Overlapping file ownership** two agents write to the same file | Merge conflicts, lost work, non-deterministic output | Enforce disjoint `touches[]` per stream. Move shared files to a single owner |
497
- | **Blind merge** merging cook reports without reviewing them | Poisoned output propagates. One bad stream corrupts the whole feature | `integrity-check` + `completion-gate` on every cook report before merge |
498
- | **Over-parallelization** — launching 5+ agents for a 3-file task | Context fragmentation, coordination overhead > implementation time | Auto-detect: ≤5 files lite mode (max 2 agents). Full mode caps at 3 |
499
- | **Cross-domain implementation** one agent implements both frontend and backend | Domain expertise diluted. Agent makes shallow choices in unfamiliar territory | Split by domain. Frontend agent ≠ backend agent. Each gets domain context |
500
- | **Missing handoff context** — bare prompt to cook instance without scope/conventions | Agent guesses project conventions, uses wrong patterns, produces inconsistent code | NEXUS Handoff Template: always include metadata, deliverables, conventions, quality expectations |
501
- | **Sequential when parallel is safe** — running independent streams one by one | Wastes time. 3 independent streams × 5min = 15min sequential vs 5min parallel | Check dependency graph. Independent streams → parallel. Dependent → sequential |
502
-
503
- ## Sharp Edges
504
-
505
- Known failure modes for this skill. Check these before declaring done.
506
-
507
- | Failure Mode | Severity | Mitigation |
508
- |---|---|---|
509
- | Launching more than 3 parallel agents (full mode) / 2 (lite mode) | CRITICAL | HARD-GATE blocks this — batch into ≤3 streams (full) or ≤2 (lite) |
510
- | Using full mode with worktrees for ≤2 streams, ≤5 files | MEDIUM | Auto-detect triggers lite mode — saves opus cost and worktree overhead |
511
- | Agents with overlapping file ownership | HIGH | Scope Gate: define disjoint file sets before dispatch — never leave overlap unresolved |
512
- | Merging without running integration tests | HIGH | Verification Gate: integration tests on merged result are mandatory |
513
- | Ignoring sentinel CRITICAL flag in agent cook report | HIGH | Stream blocked from merge — present to user before any merge action |
514
- | Launching dependent streams before their dependencies complete | MEDIUM | Respect depends_on ordering — sequential after parallel, not parallel throughout |
515
- | Coupled modules split across streams | HIGH | Dependency graph check in Phase 1c — move coupled files to same stream or add depends_on |
516
- | Agent modified files outside declared scope | HIGH | Pre-merge scope verification in Phase 2b.5 flag before merge, not after |
517
- | Merge failure with no rollback path | HIGH | pre-team-merge tag created before merges git reset --hard on failure |
518
- | Poisoned cook report merged blindly | HIGH | Phase 3a.5 integrity-check on all cook reports before merge |
519
- | Bare prompt to cook instance no context, conventions, or scope boundary | HIGH | NEXUS Handoff Template: structured handoff with metadata, deliverables, quality expectations, and evidence requirements |
520
- | Cook returns "done" with no acceptance criteria tracking | MEDIUM | Team Report includes Acceptance Criteria table with per-criterion evidence and PASS/FAIL/UNVERIFIED verdict |
521
- | Subagent builds wrong thing due to ambiguous scope | HIGH | Question Gate (Step 1d): invite questions before work starts. Cost of answering 3 questions << cost of rebuilding 500 LOC |
522
- | Parallel streams touch same files causing merge conflicts | HIGH | Change Stacking check in Step 1c: validate disjoint `touches[]` across all parallel streams |
523
-
524
- ## Done When
525
-
526
- - Task decomposed into ≤3 workstreams each with disjoint file ownership
527
- - All cook agents completed and returned reports
528
- - All merge conflicts resolved (zero unresolved before merge commit)
529
- - Integration tests pass on merged main branch
530
- - All worktrees cleaned up
531
- - Team Report emitted with stream statuses and integration results
532
-
533
- ## Cost Profile
534
-
535
- ~$0.20-0.50 per session. Opus for coordination. Most expensive orchestrator but handles largest tasks.
536
-
537
- **Scope guardrail**: Do not invoke launch, rescue, or scaffold autonomously unless explicitly delegated by the parent agent.
1
+ ---
2
+ name: team
3
+ description: "Multi-agent meta-orchestrator. Use when task spans 5+ files or 3+ modules, or when user says 'parallel', 'split this up', 'do all of these'. Decomposes large tasks into parallel workstreams, assigns to isolated cook instances, coordinates merging."
4
+ context: fork
5
+ agent: general-purpose
6
+ metadata:
7
+ author: runedev
8
+ version: "1.0.0"
9
+ layer: L1
10
+ model: opus
11
+ group: orchestrator
12
+ tools: "Read, Write, Edit, Bash, Glob, Grep"
13
+ emit: phase.complete
14
+ ---
15
+
16
+ # team
17
+
18
+ ## Purpose
19
+
20
+ Meta-orchestrator for complex tasks requiring parallel workstreams. Team decomposes large features into independent subtasks, assigns each to an isolated cook instance (using git worktrees), coordinates progress, and merges results. Uses opus for strategic decomposition and conflict resolution.
21
+
22
+ <HARD-GATE>
23
+ - MAX 3 PARALLEL AGENTS: Never launch more than 3 Task calls simultaneously. If more than 3 streams exist, batch them.
24
+ - No merge without conflict resolution complete (Phase 3 clean).
25
+ - Full integration tests MUST run before reporting success.
26
+ </HARD-GATE>
27
+
28
+ ## Triggers
29
+
30
+ - `/rune team <task>` — manual invocation for large features
31
+ - Auto-trigger: when task affects 5+ files or spans 3+ modules
32
+
33
+ ## Mode Selection (Auto-Detect)
34
+
35
+ ```
36
+ IF streams ≤ 2 AND total files ≤ 5:
37
+ → LITE MODE (lightweight parallel, no worktrees)
38
+ ELSE:
39
+ → FULL MODE (worktree isolation, opus coordination)
40
+ ```
41
+
42
+ ### Lite Mode
43
+
44
+ For small parallel tasks that don't warrant full worktree isolation:
45
+
46
+ ```
47
+ Lite Mode Rules:
48
+ - Max 2 parallel agents (haiku coordination, sonnet workers)
49
+ - NO worktree creation — agents work on same branch
50
+ - File ownership still enforced (disjoint file sets)
51
+ - Simplified merge: sequential git add (no merge conflicts possible with disjoint files)
52
+ - Skip Phase 3 (COORDINATE) — no conflicts with disjoint files
53
+ - Skip integrity-check — small scope, direct output review
54
+ - Coordinator model: haiku (not opus) — saves cost
55
+
56
+ Lite Mode Phases:
57
+ Phase 1: DECOMPOSE (haiku) — identify 2 streams with disjoint files
58
+ Phase 2: ASSIGN — launch 2 parallel Task agents (sonnet, no worktree)
59
+ Phase 4: MERGE — sequential git add (no merge needed)
60
+ Phase 5: VERIFY — integration tests on result
61
+ ```
62
+
63
+ **Announce mode**: "Team lite mode: 2 streams, ≤5 files, no worktrees needed."
64
+ **Override**: User can say "full mode" to force worktree isolation.
65
+
66
+ ### Full Mode
67
+
68
+ Standard team workflow with worktree isolation (Phases 1-5 as documented below).
69
+
70
+ ### Complexity Tiers (DAG Stage Selection)
71
+
72
+ Before decomposing, classify the task into a complexity tier. Each tier defines a different DAG (directed acyclic graph) of stages, ensuring the right amount of process for the task's complexity.
73
+
74
+ | Tier | Signals | DAG Stages | Context Windows |
75
+ |------|---------|------------|-----------------|
76
+ | **Trivial** | ≤3 files, single module, no shared contracts | impl → test | 1 (single cook) |
77
+ | **Medium** | 4-10 files, 2-3 modules, shared interfaces | research → plan → impl → test → review → fix | 3 (plan, impl+test, review+fix) |
78
+ | **Large** | 10+ files, 3+ modules, breaking changes or RFC | research → plan → impl → test → review₁ → fix → review₂ → final merge | 4+ (plan, impl+test, review₁+fix, review₂+merge) |
79
+
80
+ **Key principle — reviewer isolation**: The agent that writes code MUST NOT review its own code. Each review stage uses a **separate context window** (separate Task invocation) that has never seen the implementation reasoning. This prevents author bias from contaminating the review.
81
+
82
+ **Stage → Context Window mapping**:
83
+ - `research + plan` = Context Window 1 (opus — architectural reasoning)
84
+ - `impl + test` = Context Window 2 (sonnet — code writing)
85
+ - `review₁ + fix` = Context Window 3 (sonnet — fresh eyes, no impl context)
86
+ - `review₂ + merge` = Context Window 4 (sonnet — final verification, Large tier only)
87
+
88
+ **Merge queue**: When multiple streams complete at different times, use dependency order for merging. If a later stream's merge creates conflicts with an already-merged stream, provide the conflicting stream's cook report as **conflict context** to the resolution agent — never resolve blindly.
89
+
90
+ ## Calls (outbound)
91
+
92
+ - `plan` (L2): high-level task decomposition into independent workstreams
93
+ - `scout` (L2): understand full project scope and module boundaries
94
+ # Exception: L1→L1 meta-orchestration (team is the only L1 that calls other L1s)
95
+ - `cook` (L1): delegate feature tasks to parallel instances (worktree isolation)
96
+ - `launch` (L1): delegate deployment/marketing when build is complete
97
+ - `rescue` (L1): delegate legacy refactoring when rescue work detected
98
+ - `integrity-check` (L3): verify cook report integrity before merge
99
+ - `completion-gate` (L3): validate workstream completion claims against evidence
100
+ - `constraint-check` (L3): audit HARD-GATE compliance across parallel streams
101
+ - `scope-guard` (L3): pre-merge scope verification validate each stream's actual file changes against declared ownership
102
+ - `worktree` (L3): create isolated worktrees for parallel cook instances
103
+ - `context-pack` (L3): create structured handoff briefings before spawning subagents
104
+ - L4 extension packs: domain-specific patterns when context matches (e.g., @rune/mobile when porting web to mobile)
105
+
106
+ ## Called By (inbound)
107
+
108
+ - `scaffold` (L1): decompose scaffolding into parallel workstreams
109
+ - User: `/rune team <task>` direct invocation only
110
+
111
+ ---
112
+
113
+ ## Execution
114
+
115
+ ### Step 0 — Initialize TodoWrite
116
+
117
+ ```
118
+ TodoWrite([
119
+ { content: "DECOMPOSE: Scout modules and plan workstreams", status: "pending", activeForm: "Decomposing task into workstreams" },
120
+ { content: "ASSIGN: Launch parallel cook agents in worktrees", status: "pending", activeForm: "Assigning streams to cook agents" },
121
+ { content: "COORDINATE: Monitor streams, resolve conflicts", status: "pending", activeForm: "Coordinating parallel streams" },
122
+ { content: "MERGE: Merge worktrees back to main", status: "pending", activeForm: "Merging worktrees to main" },
123
+ { content: "VERIFY: Run integration tests on merged result", status: "pending", activeForm: "Verifying integration" }
124
+ ])
125
+ ```
126
+
127
+ ---
128
+
129
+ ### Phase 1 — DECOMPOSE
130
+
131
+ Mark todo[0] `in_progress`.
132
+
133
+ **1a. Map module boundaries.**
134
+
135
+ ```
136
+ REQUIRED SUB-SKILL: rune:scout
137
+ Invoke `scout` with the full task description.
138
+ → Scout returns: module list, file ownership map, dependency graph.
139
+ → Capture: which modules are independent vs. coupled.
140
+ ```
141
+
142
+ **1b. Break into workstreams.**
143
+
144
+ ```
145
+ REQUIRED SUB-SKILL: rune:plan
146
+ Invoke `plan` with scout output + task description.
147
+ Plan returns: ordered list of workstreams, each with:
148
+ - stream_id: "A" | "B" | "C" (max 3)
149
+ - task: specific sub-task description
150
+ - files: list of files this stream owns
151
+ - depends_on: [] | ["B"] (empty = parallel-safe)
152
+ ```
153
+
154
+ **1c. Validate decomposition.**
155
+
156
+ ```
157
+ GATE CHECK before proceeding:
158
+ [ ] Each stream owns disjoint file sets (no overlap)
159
+ [ ] No coupled modules across streams:
160
+ Use Grep to find import/require statements in each stream's owned files
161
+ If stream A files import from stream B files → flag as COUPLED
162
+ COUPLED modules MUST be moved to same stream OR stream B added to A's depends_on
163
+ [ ] Dependent streams have explicit depends_on declared
164
+ [ ] Total streams 3
165
+ [ ] Change Stacking check: no file appears in touches[] of 2+ parallel streams
166
+ [ ] Every stream's requires[] is satisfied by a prior stream's provides[] or existing code
167
+
168
+ If any check fails → re-invoke plan with conflict notes.
169
+ ```
170
+
171
+ **1d. Question Gate (non-trivial tasks only).**
172
+
173
+ > From superpowers (obra/superpowers, 84k★): "Subagents that start work without asking questions produce the wrong thing 40% of the time."
174
+
175
+ Before dispatching streams, include in each NEXUS Handoff: "Before starting, ask up to 3 clarifying questions if anything is unclear about scope, conventions, or expected output."
176
+
177
+ - If a cook agent returns questions instead of starting work answer them, then re-dispatch
178
+ - If a cook agent starts work without questions → proceed normally (questions are invited, not required)
179
+ - **Skip if**: Lite mode (2 streams, ≤5 files) — overhead exceeds value
180
+
181
+ Mark todo[0] `completed`.
182
+
183
+ ---
184
+
185
+ ### Phase 2 — ASSIGN
186
+
187
+ Mark todo[1] `in_progress`.
188
+
189
+ **2a. Launch parallel streams.**
190
+
191
+ Launch independent streams (depends_on: []) in parallel using Task tool with worktree isolation.
192
+
193
+ > From agency-agents (msitarzewski/agency-agents, 50.8k★): "Structured handoff docs prevent the #1 multi-agent failure: context loss between agents."
194
+
195
+ Each stream receives a **NEXUS Handoff Template** — not a bare prompt:
196
+
197
+ ```
198
+ For each stream where depends_on == []:
199
+ Task(
200
+ subagent_type: "general-purpose",
201
+ model: "sonnet",
202
+ isolation: "worktree",
203
+ prompt: <NEXUS Handoff below>
204
+ )
205
+ ```
206
+
207
+ **NEXUS Handoff Template** (sent to each cook instance):
208
+
209
+ ```markdown
210
+ ## NEXUS Handoff: Stream [id]
211
+
212
+ ### Metadata
213
+ - Stream: [id] of [total]
214
+ - Depends on: [none | stream ids]
215
+ - File ownership: [list — ONLY these files may be modified]
216
+ - Model: sonnet
217
+
218
+ ### Context
219
+ - Project: [project name and type]
220
+ - Overall goal: [1-line feature description]
221
+ - This stream's goal: [specific sub-task]
222
+ - Conventions: [key patterns from scout — naming, file structure, test framework]
223
+
224
+ ### Deliverable
225
+ - [ ] [specific outcome 1 — e.g., "AuthService with login/register/reset methods"]
226
+ - [ ] [specific outcome 2 — e.g., "Unit tests covering happy path + 3 error cases"]
227
+ - [ ] [specific outcome 3 — e.g., "Types exported for Phase 2 consumers"]
228
+
229
+ ### Quality Expectations
230
+ - Tests: must pass with evidence (stdout captured)
231
+ - Types: no `any`, strict mode
232
+ - Security: no hardcoded secrets, parameterized queries
233
+ - Conventions: [project-specific — from scout output]
234
+
235
+ ### Evidence Required
236
+ Return a Cook Report with:
237
+ - Exact files modified (git diff --stat)
238
+ - Test output (stdout — not just "tests pass")
239
+ - Any CONCERNS discovered during implementation
240
+ ```
241
+
242
+ **2b. Launch dependent streams sequentially.**
243
+
244
+ ```
245
+ For each stream where depends_on != []:
246
+ WAIT for all depends_on streams to complete.
247
+ Then launch with NEXUS Handoff that includes:
248
+ - Completed stream's deliverables as "Available Context"
249
+ - Exported interfaces/types from prior streams in "Code Contracts" section
250
+ - Any CONCERNS from prior streams in "Known Issues" section
251
+ ```
252
+
253
+ **2b.5. Pre-merge scope verification.**
254
+
255
+ After each stream completes (before collecting final report):
256
+
257
+ ```
258
+ Bash: git diff --name-only main...[worktree-branch]
259
+ Compare actual modified files vs stream's planned file ownership list.
260
+ If agent modified files OUTSIDE its declared scope:
261
+ FLAG: "Stream [id] modified [file] outside its scope."
262
+ Present to user for approval before proceeding to merge.
263
+ → If all files within scope: proceed normally.
264
+ ```
265
+
266
+ This catches scope creep BEFORE merge — much cheaper to fix than after.
267
+
268
+ **2c. Collect cook reports.**
269
+
270
+ Wait for all Task calls to return. Store each cook report keyed by stream_id.
271
+
272
+ ```
273
+ Error recovery:
274
+ If a Task fails or returns error report:
275
+ Log failure: "Stream [id] failed: [error]"
276
+ → If stream is non-blocking: continue with other streams
277
+ → If stream is blocking (others depend on it): STOP, report to user with partial results
278
+ ```
279
+
280
+ Mark todo[1] `completed`.
281
+
282
+ ---
283
+
284
+ ### Phase 3 — COORDINATE
285
+
286
+ Mark todo[2] `in_progress`.
287
+
288
+ **3a. Check for file conflicts.**
289
+
290
+ ```
291
+ Bash: git diff --name-only [worktree-a-branch] [worktree-b-branch]
292
+ ```
293
+
294
+ If overlapping files detected between completed worktrees:
295
+ - Identify the conflict source from cook reports
296
+ - Determine which stream's version takes precedence (later stream wins by default)
297
+ - Flag for manual resolution if ambiguous — present to user before merge
298
+
299
+ **3a.5. Verify cook report integrity.**
300
+
301
+ ```
302
+ REQUIRED SUB-SKILL: rune:integrity-check
303
+ Invoke integrity-check on each cook report text.
304
+ If any report returns TAINTED:
305
+ BLOCK this stream from merge.
306
+ Report: "Stream [id] cook report contains adversarial content."
307
+ → If SUSPICIOUS: warn user, ask for confirmation before merge.
308
+ ```
309
+
310
+ **3b. Review cook report summaries.**
311
+
312
+ For each completed stream, verify cook report contains:
313
+ - Files modified
314
+ - Tests passing
315
+ - No unresolved TODOs or sentinel CRITICAL flags
316
+
317
+ ```
318
+ Error recovery:
319
+ If cook report contains sentinel CRITICAL:
320
+ BLOCK this stream from merge
321
+ → Report: "Stream [id] blocked: CRITICAL issue in [file] — [details]"
322
+ → Present to user for decision before continuing
323
+ ```
324
+
325
+ **3c. Evaluate subagent status per stream.**
326
+
327
+ Each cook instance MUST have returned one of four statuses. Team handles them as follows:
328
+
329
+ | Cook Status | Team Action |
330
+ |-------------|-------------|
331
+ | `DONE` | Stream cleared for merge proceed normally |
332
+ | `DONE_WITH_CONCERNS` | Stream cleared for merge, BUT trigger **cross-workstream review**: check if the concern impacts any other stream's files or contracts before merging ALL streams. Log concern in Team Report. |
333
+ | `NEEDS_CONTEXT` | Stream paused — present the specific question to user. Resume that stream after answer. Other independent streams may continue in parallel. |
334
+ | `BLOCKED` | Stream blocked from merge. If stream has no dependents → continue with remaining streams and report partial completion. If stream has dependents → STOP all dependent streams, present to user with full blocker details. |
335
+
336
+ **Cross-workstream review (triggered by any DONE_WITH_CONCERNS)**:
337
+
338
+ ```
339
+ 1. Read the concern from the cook report
340
+ 2. Check if the concern touches shared contracts, interfaces, or shared files
341
+ Use Grep to find the concern's affected symbols/files across all worktrees
342
+ 3. If concern is isolated to stream's own files proceed to merge (concern logged only)
343
+ 4. If concern crosses stream boundaries resolve before merge:
344
+ → Present to user with: affected streams, concern details, two remediation options
345
+ → Do NOT merge any stream until user decides
346
+ ```
347
+
348
+ Mark todo[2] `completed`.
349
+
350
+ ---
351
+
352
+ ### Phase 4 — MERGE
353
+
354
+ Mark todo[3] `in_progress`.
355
+
356
+ **4a. Merge each worktree sequentially.**
357
+
358
+ ```
359
+ # Bookmark before any merge
360
+ Bash: git tag pre-team-merge
361
+
362
+ For each stream in dependency order (independent first, dependent last):
363
+
364
+ Bash: git checkout main
365
+ Bash: git merge --no-ff [worktree-branch] -m "merge: stream [id] — [stream.task]"
366
+
367
+ If merge conflict:
368
+ Bash: git status (identify conflicting files)
369
+ If ≤3 conflicting files:
370
+ Resolve using cook report guidance (stream's intended change wins)
371
+ Bash: git add [resolved-files]
372
+ Bash: git merge --continue
373
+ If >3 conflicting files OR ambiguous ownership:
374
+ STOP merge
375
+ Bash: git merge --abort
376
+ → Present to user: "Stream [id] has [N] conflicts. Manual resolution required."
377
+ ```
378
+
379
+ **4b. Cleanup worktrees.**
380
+
381
+ ```
382
+ Bash: git worktree remove [worktree-path] --force
383
+ ```
384
+
385
+ (Repeat for each worktree after its branch is merged.)
386
+
387
+ Mark todo[3] `completed`.
388
+
389
+ ---
390
+
391
+ ### Phase 5 — VERIFY
392
+
393
+ Mark todo[4] `in_progress`.
394
+
395
+ ```
396
+ REQUIRED SUB-SKILL: rune:verification
397
+ Invoke `verification` on the merged main branch.
398
+ → verification runs: type check, lint, unit tests, integration tests.
399
+ → Capture: passed count, failed count, coverage %.
400
+ ```
401
+
402
+ ```
403
+ Error recovery:
404
+ If verification fails after merge:
405
+ Rollback all merges:
406
+ Bash: git reset --hard pre-team-merge
407
+ Bash: git tag -d pre-team-merge
408
+ Report: "Integration tests failed. All merges reverted to pre-team-merge state."
409
+ → Present fix options to user
410
+ ```
411
+
412
+ Mark todo[4] `completed`.
413
+
414
+ ---
415
+
416
+ ## Constraints
417
+
418
+ 1. MUST NOT launch more than 3 parallel agentsbatch if more streams exist
419
+ 2. MUST define clear scope boundaries per agent before dispatch no overlapping file ownership
420
+ 3. MUST resolve all merge conflicts before declaring completion — no "fix later"
421
+ 4. MUST NOT let agents modify the same file split by file ownership
422
+ 5. MUST collect and review all agent outputs before merging — no blind merge
423
+ 6. MUST NOT skip the integration verification after merge
424
+
425
+ ## Mesh Gates
426
+
427
+ | Gate | Requires | If Missing |
428
+ |------|----------|------------|
429
+ | Scope Gate | Each agent has explicit file ownership list | Define boundaries before dispatch |
430
+ | Conflict Gate | Zero merge conflicts after integration | Resolve all conflicts, re-verify |
431
+ | Verification Gate | All tests pass after merge | Fix regressions before completion |
432
+
433
+ ## Output Format
434
+
435
+ ```
436
+ ## Team Report: [Task Name]
437
+ - **Streams**: [count]
438
+ - **Status**: complete | partial | blocked
439
+ - **Duration**: [time across streams]
440
+
441
+ ### Streams
442
+ | Stream | Task | Status | Deliverables | Concerns |
443
+ |--------|------|--------|-------------|----------|
444
+ | A | [task] | DONE | 3/3 delivered | None |
445
+ | B | [task] | DONE_WITH_CONCERNS | 2/2 delivered | Perf regression on large input |
446
+ | C | [task] | DONE | 2/2 delivered | None |
447
+
448
+ ### Acceptance Criteria
449
+ | # | Criterion | Stream | Evidence | Verdict |
450
+ |---|-----------|--------|----------|---------|
451
+ | 1 | Auth endpoints return JWT | A | Test stdout: "3 passed" | PASS |
452
+ | 2 | No SQL injection | A | Sentinel: PASS | PASS |
453
+ | 3 | Dashboard loads < 2s | B | No perf test run | UNVERIFIED |
454
+
455
+ ### Integration
456
+ - Merge conflicts: [count]
457
+ - Integration tests: [passed]/[total]
458
+ - Coverage: [%]
459
+ - Unresolved concerns: [count — from DONE_WITH_CONCERNS streams]
460
+ ```
461
+
462
+ ---
463
+
464
+ ## Parallel Execution Rules
465
+
466
+ ```
467
+ Independent streams PARALLEL (max 3 sonnet agents)
468
+ Dependent streams → SEQUENTIAL (respecting dependency order)
469
+ All streams done → MERGE sequentially (avoid conflicts)
470
+ ```
471
+
472
+ ## Returns
473
+
474
+ | Artifact | Format | Location |
475
+ |----------|--------|----------|
476
+ | Workstream assignments | Markdown (inline) | NEXUS Handoff Templates emitted per stream |
477
+ | Cook Reports (per stream) | Markdown (inline) | Collected from each parallel cook instance |
478
+ | Merged implementation | Source files | `main` branch after Phase 4 merge |
479
+ | Integration test results | Inline stdout | Captured in Phase 5 verify |
480
+ | Team Report | Markdown (inline) | Emitted at end of session |
481
+
482
+ ## Document Ownership
483
+
484
+ | Scope | Access | Files |
485
+ |-------|--------|-------|
486
+ | **Owns** (read + write) | `.rune/team-report-*.md`, worktree branches, merge commits |
487
+ | **Reads** (never writes) | `.rune/plan-*.md`, `.rune/contract.md`, `CLAUDE.md`, cook reports from sub-agents |
488
+ | **Never modifies** | Source files directly (delegates to cook instances), `SKILL.md` files, `compiler/**` |
489
+
490
+ Each cook instance owns its declared file set (disjoint). Team owns coordination artifacts only — never touches source code directly.
491
+
492
+ ## Monorepo Awareness
493
+
494
+ When the project is a monorepo (signals: `pnpm-workspace.yaml`, `turbo.json`, `nx.json`, or `packages/` directory with multiple `package.json`):
495
+
496
+ **Stream assignment rules for monorepos:**
497
+ - Assign streams by **package boundary**, not by file type one stream per package (e.g., Stream A = `packages/api`, Stream B = `packages/web`)
498
+ - Cross-package changes (e.g., shared types in `packages/core` consumed by both api + web) must be in a **dependency stream** that completes before consumer streams start
499
+ - Use `turbo run test --filter=...[HEAD^1]` in Phase 5 (VERIFY) to test only affected packages do NOT run the full test suite when only 1 package changed
500
+
501
+ **Dependency stream pattern for cross-package changes:**
502
+
503
+ ```
504
+ Stream A (depends_on: []): packages/core — shared types + utilities
505
+ Stream B (depends_on: ["A"]): packages/api consumes updated core types
506
+ Stream C (depends_on: ["A"]): packages/web — consumes updated core types
507
+ B and C run in parallel after A completes.
508
+ ```
509
+
510
+ ## Anti-Patterns
511
+
512
+ Common multi-agent orchestration failures. These cause the most expensive rework in team workflows.
513
+
514
+ | Anti-Pattern | Why It Fails | Correct Approach |
515
+ |---|---|---|
516
+ | **Overlapping file ownership** two agents write to the same file | Merge conflicts, lost work, non-deterministic output | Enforce disjoint `touches[]` per stream. Move shared files to a single owner |
517
+ | **Blind merge** merging cook reports without reviewing them | Poisoned output propagates. One bad stream corrupts the whole feature | `integrity-check` + `completion-gate` on every cook report before merge |
518
+ | **Over-parallelization** launching 5+ agents for a 3-file task | Context fragmentation, coordination overhead > implementation time | Auto-detect: 5 files lite mode (max 2 agents). Full mode caps at 3 |
519
+ | **Cross-domain implementation** one agent implements both frontend and backend | Domain expertise diluted. Agent makes shallow choices in unfamiliar territory | Split by domain. Frontend agent backend agent. Each gets domain context |
520
+ | **Missing handoff context** bare prompt to cook instance without scope/conventions | Agent guesses project conventions, uses wrong patterns, produces inconsistent code | NEXUS Handoff Template: always include metadata, deliverables, conventions, quality expectations |
521
+ | **Sequential when parallel is safe** running independent streams one by one | Wastes time. 3 independent streams × 5min = 15min sequential vs 5min parallel | Check dependency graph. Independent streams parallel. Dependent → sequential |
522
+
523
+ ## Sharp Edges
524
+
525
+ Known failure modes for this skill. Check these before declaring done.
526
+
527
+ | Failure Mode | Severity | Mitigation |
528
+ |---|---|---|
529
+ | Launching more than 3 parallel agents (full mode) / 2 (lite mode) | CRITICAL | HARD-GATE blocks this batch into ≤3 streams (full) or ≤2 (lite) |
530
+ | Using full mode with worktrees for ≤2 streams, ≤5 files | MEDIUM | Auto-detect triggers lite mode — saves opus cost and worktree overhead |
531
+ | Agents with overlapping file ownership | HIGH | Scope Gate: define disjoint file sets before dispatch — never leave overlap unresolved |
532
+ | Merging without running integration tests | HIGH | Verification Gate: integration tests on merged result are mandatory |
533
+ | Ignoring sentinel CRITICAL flag in agent cook report | HIGH | Stream blocked from merge — present to user before any merge action |
534
+ | Launching dependent streams before their dependencies complete | MEDIUM | Respect depends_on ordering — sequential after parallel, not parallel throughout |
535
+ | Coupled modules split across streams | HIGH | Dependency graph check in Phase 1c — move coupled files to same stream or add depends_on |
536
+ | Agent modified files outside declared scope | HIGH | Pre-merge scope verification in Phase 2b.5 — flag before merge, not after |
537
+ | Merge failure with no rollback path | HIGH | pre-team-merge tag created before merges git reset --hard on failure |
538
+ | Poisoned cook report merged blindly | HIGH | Phase 3a.5 integrity-check on all cook reports before merge |
539
+ | Bare prompt to cook instance — no context, conventions, or scope boundary | HIGH | NEXUS Handoff Template: structured handoff with metadata, deliverables, quality expectations, and evidence requirements |
540
+ | Cook returns "done" with no acceptance criteria tracking | MEDIUM | Team Report includes Acceptance Criteria table with per-criterion evidence and PASS/FAIL/UNVERIFIED verdict |
541
+ | Subagent builds wrong thing due to ambiguous scope | HIGH | Question Gate (Step 1d): invite questions before work starts. Cost of answering 3 questions << cost of rebuilding 500 LOC |
542
+ | Parallel streams touch same files causing merge conflicts | HIGH | Change Stacking check in Step 1c: validate disjoint `touches[]` across all parallel streams |
543
+
544
+ ## Done When
545
+
546
+ - Task decomposed into ≤3 workstreams each with disjoint file ownership
547
+ - All cook agents completed and returned reports
548
+ - All merge conflicts resolved (zero unresolved before merge commit)
549
+ - Integration tests pass on merged main branch
550
+ - All worktrees cleaned up
551
+ - Team Report emitted with stream statuses and integration results
552
+
553
+ ## Cost Profile
554
+
555
+ ~$0.20-0.50 per session. Opus for coordination. Most expensive orchestrator but handles largest tasks.
556
+
557
+ **Scope guardrail**: Do not invoke launch, rescue, or scaffold autonomously unless explicitly delegated by the parent agent.