agileflow 3.3.0 → 3.4.1

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 (210) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +6 -6
  3. package/lib/skill-loader.js +0 -1
  4. package/package.json +1 -1
  5. package/scripts/agileflow-statusline.sh +81 -0
  6. package/scripts/agileflow-welcome.js +79 -0
  7. package/scripts/claude-tmux.sh +90 -23
  8. package/scripts/claude-watchdog.sh +225 -0
  9. package/scripts/generators/agent-registry.js +14 -1
  10. package/scripts/generators/inject-babysit.js +22 -9
  11. package/scripts/generators/inject-help.js +19 -9
  12. package/scripts/lib/ac-test-matcher.js +452 -0
  13. package/scripts/lib/audit-cleanup.js +250 -0
  14. package/scripts/lib/audit-registry.js +304 -0
  15. package/scripts/lib/configure-features.js +35 -0
  16. package/scripts/lib/feature-catalog.js +3 -3
  17. package/scripts/lib/gate-enforcer.js +295 -0
  18. package/scripts/lib/model-profiles.js +118 -0
  19. package/scripts/lib/quality-gates.js +163 -0
  20. package/scripts/lib/signal-detectors.js +44 -1
  21. package/scripts/lib/skill-catalog.js +557 -0
  22. package/scripts/lib/skill-recommender.js +311 -0
  23. package/scripts/lib/status-writer.js +255 -0
  24. package/scripts/lib/story-claiming.js +128 -45
  25. package/scripts/lib/task-sync.js +32 -38
  26. package/scripts/lib/tdd-phase-manager.js +455 -0
  27. package/scripts/lib/team-events.js +34 -3
  28. package/scripts/lib/tmux-audit-monitor.js +611 -0
  29. package/scripts/lib/tmux-group-colors.js +113 -0
  30. package/scripts/lib/tool-registry.yaml +241 -0
  31. package/scripts/lib/tool-shed.js +441 -0
  32. package/scripts/messaging-bridge.js +209 -1
  33. package/scripts/native-team-observer.js +219 -0
  34. package/scripts/obtain-context.js +14 -0
  35. package/scripts/ralph-loop.js +30 -5
  36. package/scripts/smart-detect.js +21 -0
  37. package/scripts/spawn-audit-sessions.js +877 -0
  38. package/scripts/team-manager.js +56 -16
  39. package/scripts/tmux-close-windows.sh +180 -0
  40. package/src/core/agents/a11y-analyzer-aria.md +155 -0
  41. package/src/core/agents/a11y-analyzer-forms.md +162 -0
  42. package/src/core/agents/a11y-analyzer-keyboard.md +175 -0
  43. package/src/core/agents/a11y-analyzer-semantic.md +153 -0
  44. package/src/core/agents/a11y-analyzer-visual.md +158 -0
  45. package/src/core/agents/a11y-consensus.md +248 -0
  46. package/src/core/agents/ads-audit-budget.md +181 -0
  47. package/src/core/agents/ads-audit-compliance.md +169 -0
  48. package/src/core/agents/ads-audit-creative.md +164 -0
  49. package/src/core/agents/ads-audit-google.md +226 -0
  50. package/src/core/agents/ads-audit-meta.md +183 -0
  51. package/src/core/agents/ads-audit-tracking.md +197 -0
  52. package/src/core/agents/ads-consensus.md +396 -0
  53. package/src/core/agents/ads-generate.md +145 -0
  54. package/src/core/agents/ads-performance-tracker.md +197 -0
  55. package/src/core/agents/api-quality-analyzer-conventions.md +148 -0
  56. package/src/core/agents/api-quality-analyzer-docs.md +176 -0
  57. package/src/core/agents/api-quality-analyzer-errors.md +183 -0
  58. package/src/core/agents/api-quality-analyzer-pagination.md +171 -0
  59. package/src/core/agents/api-quality-analyzer-versioning.md +143 -0
  60. package/src/core/agents/api-quality-consensus.md +214 -0
  61. package/src/core/agents/arch-analyzer-circular.md +148 -0
  62. package/src/core/agents/arch-analyzer-complexity.md +171 -0
  63. package/src/core/agents/arch-analyzer-coupling.md +146 -0
  64. package/src/core/agents/arch-analyzer-layering.md +151 -0
  65. package/src/core/agents/arch-analyzer-patterns.md +162 -0
  66. package/src/core/agents/arch-consensus.md +227 -0
  67. package/src/core/agents/brainstorm-analyzer-features.md +169 -0
  68. package/src/core/agents/brainstorm-analyzer-growth.md +161 -0
  69. package/src/core/agents/brainstorm-analyzer-integration.md +172 -0
  70. package/src/core/agents/brainstorm-analyzer-market.md +147 -0
  71. package/src/core/agents/brainstorm-analyzer-ux.md +167 -0
  72. package/src/core/agents/brainstorm-consensus.md +237 -0
  73. package/src/core/agents/completeness-consensus.md +5 -5
  74. package/src/core/agents/perf-consensus.md +2 -2
  75. package/src/core/agents/security-consensus.md +2 -2
  76. package/src/core/agents/seo-analyzer-content.md +167 -0
  77. package/src/core/agents/seo-analyzer-images.md +187 -0
  78. package/src/core/agents/seo-analyzer-performance.md +206 -0
  79. package/src/core/agents/seo-analyzer-schema.md +176 -0
  80. package/src/core/agents/seo-analyzer-sitemap.md +172 -0
  81. package/src/core/agents/seo-analyzer-technical.md +144 -0
  82. package/src/core/agents/seo-consensus.md +289 -0
  83. package/src/core/agents/test-consensus.md +2 -2
  84. package/src/core/commands/adr.md +1 -0
  85. package/src/core/commands/ads/audit.md +375 -0
  86. package/src/core/commands/ads/budget.md +97 -0
  87. package/src/core/commands/ads/competitor.md +112 -0
  88. package/src/core/commands/ads/creative.md +85 -0
  89. package/src/core/commands/ads/generate.md +238 -0
  90. package/src/core/commands/ads/google.md +112 -0
  91. package/src/core/commands/ads/health.md +327 -0
  92. package/src/core/commands/ads/landing.md +119 -0
  93. package/src/core/commands/ads/linkedin.md +112 -0
  94. package/src/core/commands/ads/meta.md +91 -0
  95. package/src/core/commands/ads/microsoft.md +115 -0
  96. package/src/core/commands/ads/plan.md +321 -0
  97. package/src/core/commands/ads/test-plan.md +317 -0
  98. package/src/core/commands/ads/tiktok.md +129 -0
  99. package/src/core/commands/ads/track.md +288 -0
  100. package/src/core/commands/ads/youtube.md +124 -0
  101. package/src/core/commands/ads.md +140 -0
  102. package/src/core/commands/assign.md +1 -0
  103. package/src/core/commands/audit.md +43 -6
  104. package/src/core/commands/babysit.md +315 -1266
  105. package/src/core/commands/baseline.md +1 -0
  106. package/src/core/commands/blockers.md +1 -0
  107. package/src/core/commands/board.md +1 -0
  108. package/src/core/commands/changelog.md +1 -0
  109. package/src/core/commands/choose.md +1 -0
  110. package/src/core/commands/ci.md +1 -0
  111. package/src/core/commands/code/accessibility.md +347 -0
  112. package/src/core/commands/code/api.md +297 -0
  113. package/src/core/commands/code/architecture.md +297 -0
  114. package/src/core/commands/{audit → code}/completeness.md +72 -25
  115. package/src/core/commands/{audit → code}/legal.md +63 -16
  116. package/src/core/commands/{audit → code}/logic.md +64 -16
  117. package/src/core/commands/{audit → code}/performance.md +67 -20
  118. package/src/core/commands/{audit → code}/security.md +69 -19
  119. package/src/core/commands/{audit → code}/test.md +67 -20
  120. package/src/core/commands/configure.md +1 -0
  121. package/src/core/commands/council.md +1 -0
  122. package/src/core/commands/deploy.md +1 -0
  123. package/src/core/commands/diagnose.md +1 -0
  124. package/src/core/commands/docs.md +1 -0
  125. package/src/core/commands/epic/edit.md +213 -0
  126. package/src/core/commands/epic.md +1 -0
  127. package/src/core/commands/export.md +238 -0
  128. package/src/core/commands/help.md +16 -1
  129. package/src/core/commands/{discovery → ideate}/brief.md +12 -12
  130. package/src/core/commands/{discovery/new.md → ideate/discover.md} +20 -16
  131. package/src/core/commands/ideate/features.md +496 -0
  132. package/src/core/commands/ideate/new.md +158 -124
  133. package/src/core/commands/impact.md +1 -0
  134. package/src/core/commands/learn/explain.md +118 -0
  135. package/src/core/commands/learn/glossary.md +135 -0
  136. package/src/core/commands/learn/patterns.md +138 -0
  137. package/src/core/commands/learn/tour.md +126 -0
  138. package/src/core/commands/migrate/codemods.md +151 -0
  139. package/src/core/commands/migrate/plan.md +131 -0
  140. package/src/core/commands/migrate/scan.md +114 -0
  141. package/src/core/commands/migrate/validate.md +119 -0
  142. package/src/core/commands/multi-expert.md +1 -0
  143. package/src/core/commands/pr.md +1 -0
  144. package/src/core/commands/review.md +1 -0
  145. package/src/core/commands/seo/audit.md +373 -0
  146. package/src/core/commands/seo/competitor.md +174 -0
  147. package/src/core/commands/seo/content.md +107 -0
  148. package/src/core/commands/seo/geo.md +229 -0
  149. package/src/core/commands/seo/hreflang.md +140 -0
  150. package/src/core/commands/seo/images.md +96 -0
  151. package/src/core/commands/seo/page.md +198 -0
  152. package/src/core/commands/seo/plan.md +163 -0
  153. package/src/core/commands/seo/programmatic.md +131 -0
  154. package/src/core/commands/seo/references/cwv-thresholds.md +64 -0
  155. package/src/core/commands/seo/references/eeat-framework.md +110 -0
  156. package/src/core/commands/seo/references/quality-gates.md +91 -0
  157. package/src/core/commands/seo/references/schema-types.md +102 -0
  158. package/src/core/commands/seo/schema.md +183 -0
  159. package/src/core/commands/seo/sitemap.md +97 -0
  160. package/src/core/commands/seo/technical.md +100 -0
  161. package/src/core/commands/seo.md +107 -0
  162. package/src/core/commands/skill/list.md +68 -212
  163. package/src/core/commands/skill/recommend.md +216 -0
  164. package/src/core/commands/sprint.md +1 -0
  165. package/src/core/commands/status/undo.md +191 -0
  166. package/src/core/commands/status.md +1 -0
  167. package/src/core/commands/story/edit.md +204 -0
  168. package/src/core/commands/story/view.md +29 -7
  169. package/src/core/commands/story-validate.md +1 -0
  170. package/src/core/commands/story.md +1 -0
  171. package/src/core/commands/tdd-next.md +238 -0
  172. package/src/core/commands/tdd.md +211 -0
  173. package/src/core/commands/team/start.md +10 -6
  174. package/src/core/commands/tests.md +1 -0
  175. package/src/core/commands/verify.md +27 -1
  176. package/src/core/commands/workflow.md +2 -0
  177. package/src/core/experts/_core-expertise.yaml +105 -0
  178. package/src/core/experts/analytics/expertise.yaml +5 -99
  179. package/src/core/experts/codebase-query/expertise.yaml +3 -72
  180. package/src/core/experts/compliance/expertise.yaml +6 -72
  181. package/src/core/experts/database/expertise.yaml +9 -52
  182. package/src/core/experts/documentation/expertise.yaml +7 -140
  183. package/src/core/experts/integrations/expertise.yaml +7 -127
  184. package/src/core/experts/mentor/expertise.yaml +8 -35
  185. package/src/core/experts/monitoring/expertise.yaml +7 -49
  186. package/src/core/experts/performance/expertise.yaml +1 -26
  187. package/src/core/experts/security/expertise.yaml +9 -34
  188. package/src/core/experts/ui/expertise.yaml +6 -36
  189. package/src/core/knowledge/ads/ad-audit-checklist-scoring.md +424 -0
  190. package/src/core/knowledge/ads/ad-optimization-logic.md +590 -0
  191. package/src/core/knowledge/ads/ad-technical-specifications.md +385 -0
  192. package/src/core/knowledge/ads/definitive-advertising-reference-2026.md +506 -0
  193. package/src/core/knowledge/ads/paid-advertising-research-2026.md +445 -0
  194. package/src/core/teams/backend.json +41 -0
  195. package/src/core/teams/frontend.json +41 -0
  196. package/src/core/teams/qa.json +41 -0
  197. package/src/core/teams/solo.json +35 -0
  198. package/src/core/templates/agileflow-metadata.json +20 -1
  199. package/tools/cli/commands/setup.js +85 -3
  200. package/tools/cli/commands/update.js +42 -0
  201. package/tools/cli/installers/ide/_base-ide.js +42 -5
  202. package/tools/cli/installers/ide/claude-code.js +71 -3
  203. package/tools/cli/lib/content-injector.js +160 -12
  204. package/tools/cli/lib/docs-setup.js +1 -1
  205. package/src/core/commands/skill/create.md +0 -698
  206. package/src/core/commands/skill/delete.md +0 -316
  207. package/src/core/commands/skill/edit.md +0 -359
  208. package/src/core/commands/skill/test.md +0 -394
  209. package/src/core/commands/skill/upgrade.md +0 -552
  210. package/src/core/templates/skill-template.md +0 -117
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Generate categorized improvement ideas using multi-expert analysis
3
- argument-hint: "[SCOPE=all|security|perf|code|ux] [DEPTH=quick|deep|ultradeep] [OUTPUT=report|stories|both] [HISTORY=true|false] [FOCUS=IDEA-XXXX]"
3
+ argument-hint: "[SCOPE=all|security|perf|code|ux] [DEPTH=quick|deep|ultradeep|extreme] [OUTPUT=report|stories|both] [HISTORY=true|false] [FOCUS=IDEA-XXXX] [MODEL=haiku|sonnet|opus]"
4
4
  compact_context:
5
5
  priority: high
6
6
  preserve_rules:
@@ -9,7 +9,7 @@ compact_context:
9
9
  - "CRITICAL: Wait for all results before synthesis (use TaskOutput with block=true)"
10
10
  - "CRITICAL: Confidence scoring varies by depth: quick/deep (HIGH=2+ agree) | ultradeep (HIGH=3+ agree)"
11
11
  - "CRITICAL: Check ideation index for duplicates - show NEW vs RECURRING vs IMPLEMENTED"
12
- - "MUST parse arguments: SCOPE (all/security/perf/code/ux) | DEPTH (quick/deep/ultradeep) | OUTPUT (report/stories/both) | HISTORY (true/false) | FOCUS (IDEA-XXXX)"
12
+ - "MUST parse arguments: SCOPE (all/security/perf/code/ux) | DEPTH (quick/deep/ultradeep) | OUTPUT (report/stories/both) | HISTORY (true/false) | FOCUS (IDEA-XXXX) | MODEL (haiku/sonnet/opus)"
13
13
  - "FOCUS mode: All experts analyze the same recurring idea - generate Implementation Brief"
14
14
  - "MUST categorize by domain: Security, Performance, Code Quality, UX, Testing, API/Architecture"
15
15
  - "MUST estimate effort for each idea: High/Medium/Low impact"
@@ -21,6 +21,7 @@ compact_context:
21
21
  - output_mode
22
22
  - history_enabled
23
23
  - focus_idea
24
+ - model
24
25
  - selected_experts
25
26
  - ideas_generated
26
27
  - new_ideas
@@ -194,27 +195,36 @@ Be SPECIFIC - reference actual file paths, function names, and code patterns.
194
195
  ```
195
196
  /agileflow:ideate:new SCOPE=all DEPTH=quick OUTPUT=report
196
197
  /agileflow:ideate:new FOCUS=IDEA-0023 # Deep dive into specific idea
198
+ /agileflow:ideate:new DEPTH=ultradeep MODEL=opus # Ultradeep with Opus in tmux sessions
197
199
  ```
198
200
 
199
201
  **What It Does**: Deploy 4-15 domain experts → Each generates 3-5 ideas → Synthesize with confidence scoring → Categorized report
200
202
 
201
203
  **Arguments**:
202
204
  - `SCOPE=all|security|perf|code|ux` (default: all)
203
- - `DEPTH=quick|deep|ultradeep` (default: quick) — ultradeep uses 13 experts for ~65 ideas
205
+ - `DEPTH=quick|deep|ultradeep` (default: quick) — ultradeep spawns 13 experts as tmux sessions
204
206
  - `OUTPUT=report|stories|both` (default: report)
207
+ - `MODEL=haiku|sonnet|opus` (default: haiku) — model for expert subagents
205
208
 
206
209
  ### Tool Usage Examples
207
210
 
208
- **Task** (deploy expert in parallel):
211
+ **Task** (deploy expert in parallel - include `model` if MODEL specified):
209
212
  ```xml
210
213
  <invoke name="Task">
211
214
  <parameter name="description">Security ideation analysis</parameter>
212
215
  <parameter name="prompt">Generate 3-5 specific improvement ideas for this codebase from a SECURITY perspective...</parameter>
213
216
  <parameter name="subagent_type">agileflow-security</parameter>
217
+ <parameter name="model">opus</parameter>
214
218
  <parameter name="run_in_background">true</parameter>
215
219
  </invoke>
216
220
  ```
217
221
 
222
+ **Ultradeep** (spawn tmux sessions):
223
+ ```bash
224
+ node .agileflow/scripts/spawn-audit-sessions.js --audit=ideate --target=. --focus=all --model=opus --dry-run
225
+ node .agileflow/scripts/spawn-audit-sessions.js --audit=ideate --target=. --focus=all --model=opus
226
+ ```
227
+
218
228
  **TaskOutput** (collect results):
219
229
  ```xml
220
230
  <invoke name="TaskOutput">
@@ -255,40 +265,46 @@ Be SPECIFIC - reference actual file paths, function names, and code patterns.
255
265
 
256
266
  ┌─────────────────────────────────────────────────────────────┐
257
267
  │ IDEATION ORCHESTRATOR │
258
- │ 1. Parse SCOPE to determine which experts
259
- 2. Deploy 4-13 experts IN PARALLEL (13 for ultradeep)
268
+ │ 1. Parse SCOPE, DEPTH, MODEL
269
+ 2a. quick/deep: Deploy 4-13 experts via Task (in-process)
270
+ │ 2b. ultradeep: Spawn 13 tmux sessions via spawn-audit │
260
271
  │ 3. Each expert generates 3-5 improvement ideas │
261
272
  │ 4. Collect and synthesize with confidence scoring │
262
273
  │ 5. Generate categorized report │
263
274
  └─────────────────────────────────────────────────────────────┘
264
275
 
265
- ┌───────────────────┼───────────────────┐
266
-
267
- ┌───────────┐ ┌───────────┐ ┌───────────┐
268
- │ Security │ │Performance│ │ Refactor
269
- │ Expert │ │ Expert │ │ Expert │
270
- │ │ │ │ │ │
271
- 3-5 ideas │ │ 3-5 ideas │ │ 3-5 ideas │
272
- └───────────┘ └───────────┘ └───────────┘
273
-
274
- └───────────────────┼───────────────────┘
275
-
276
+ ┌─────────────┴─────────────┐
277
+
278
+ [quick/deep] [ultradeep]
279
+ Task calls (in-proc) tmux sessions (isolated)
280
+ ┌───────┼───────┐ ┌───────┼───────┐
281
+ ▼ ▼ ▼ ▼
282
+ ┌───────────┐ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐
283
+ │ Security │ │Perf │ │ ... │ │ Sec │ │Perf │ │ ... │ x13
284
+ MODEL=X │ │ │ │ │ │ │ │ │
285
+ │ 3-5 ideas │ │ │ │ │ │ │ │ │ │ │
286
+ └───────────┘ └─────┘ └─────┘ └─────┘ └─────┘ └─────┘
287
+ │ │ │ │ │ │
288
+ └─────────┴───────┘ └───────┴───────┘
289
+ │ │
290
+ └────────────┬───────────┘
291
+
276
292
  ┌─────────────────────────────────────────────────────────────┐
277
293
  │ SYNTHESIS ENGINE │
278
- Find overlapping ideas (HIGH CONFIDENCE) │
279
- Flag unique insights with evidence (MEDIUM) │
280
- Discard vague suggestions (excluded) │
281
- Categorize by domain │
282
- Estimate effort for each idea │
294
+ - Find overlapping ideas (HIGH CONFIDENCE) │
295
+ - Flag unique insights with evidence (MEDIUM) │
296
+ - Discard vague suggestions (excluded) │
297
+ - Categorize by domain │
298
+ - Estimate effort for each idea │
283
299
  └─────────────────────────────────────────────────────────────┘
284
-
285
-
300
+
301
+
286
302
  ┌─────────────────────────────────────────────────────────────┐
287
303
  │ IDEATION REPORT │
288
- 📊 Total Ideas: X (High: Y, Medium: Z)
289
- 🎯 High-Confidence Improvements (agreed by 2+ experts) │
290
- 💡 Medium-Confidence Opportunities (single expert)
291
- 📋 Suggested Stories (if OUTPUT=stories)
304
+ │ Total Ideas: X (High: Y, Medium: Z)
305
+ │ High-Confidence Improvements (agreed by 2+/3+ experts) │
306
+ │ Medium-Confidence Opportunities (single expert)
307
+ │ Suggested Stories (if OUTPUT=stories)
292
308
  └─────────────────────────────────────────────────────────────┘
293
309
  ```
294
310
 
@@ -316,19 +332,92 @@ Parse the input arguments:
316
332
  **DEPTH**:
317
333
  - `quick` (default): Each expert generates 3 ideas, focuses on high-impact only
318
334
  - `deep`: Each expert generates 5 ideas, includes lower-priority items
319
- - `ultradeep`: Deploy 13 experts (SCOPE=all) with 5 ideas each (~65 ideas), comprehensive coverage
335
+ - `ultradeep`: Spawn each expert as a separate Claude Code session in tmux. Uses 13 experts (SCOPE=all) with 5 ideas each (~65 ideas). Requires tmux. Falls back to `deep` if tmux unavailable.
336
+
337
+ > **Note**: `DEPTH=ultradeep` is recommended for comprehensive audits, pre-release reviews, or quarterly codebase assessments. Each expert gets its own Claude session with full context, producing higher-quality analysis than in-process subagents.
338
+
339
+ **MODEL** (default: haiku):
340
+ - `haiku`: Fast and cost-effective. Good for quick/deep ideation.
341
+ - `sonnet`: Balanced quality and speed. Good default for deep analysis.
342
+ - `opus`: Maximum quality. Recommended for ultradeep or high-stakes ideation.
320
343
 
321
- > **Note**: `DEPTH=ultradeep` is recommended for comprehensive audits, pre-release reviews, or quarterly codebase assessments. It deploys significantly more experts and takes longer to complete.
344
+ > The MODEL parameter is passed to each expert subagent. For quick/deep depths, it sets the `model` parameter on Task calls. For ultradeep, it's passed to `spawn-audit-sessions.js` which sets `--model` on each tmux Claude session.
322
345
 
323
346
  **OUTPUT**:
324
347
  - `report` (default): Generate ideation report only
325
348
  - `stories`: Generate stories for high-confidence items
326
349
  - `both`: Report + stories
327
350
 
351
+ ### STEP 1.5: ULTRADEEP MODE (DEPTH=ultradeep)
352
+
353
+ **If `DEPTH=ultradeep`**, use tmux-based session spawning instead of in-process Task calls:
354
+
355
+ 1. Show cost estimate:
356
+ ```bash
357
+ node .agileflow/scripts/spawn-audit-sessions.js --audit=ideate --target=. --focus=FOCUS_KEYS --model=MODEL --dry-run
358
+ ```
359
+ 2. Confirm with user before launching
360
+ 3. Spawn sessions (use `--json` to capture trace ID):
361
+ ```bash
362
+ node .agileflow/scripts/spawn-audit-sessions.js --audit=ideate --target=. --focus=FOCUS_KEYS --model=MODEL --json
363
+ ```
364
+ Parse the JSON output to get `traceId`. Example: `{"ok":true,"traceId":"abc123ef",...}`
365
+ 4. Wait for all analyzers to complete:
366
+ ```bash
367
+ node .agileflow/scripts/lib/tmux-audit-monitor.js wait TRACE_ID --timeout=1800
368
+ ```
369
+ - Exit 0 = all complete (JSON results on stdout)
370
+ - Exit 1 = timeout (partial results on stdout, `missing` array shows what's left)
371
+ - To check progress without blocking: `node .agileflow/scripts/lib/tmux-audit-monitor.js status TRACE_ID`
372
+ - To retry stalled analyzers: `node .agileflow/scripts/lib/tmux-audit-monitor.js retry TRACE_ID`
373
+ 5. Parse `results` array from the JSON output and proceed to STEP 4 (Synthesis).
374
+ 6. If tmux unavailable (spawn exits code 2), fall back to `DEPTH=deep` with warning
375
+
376
+ **EXTREME mode** (DEPTH=extreme):
377
+ Partition-based multi-agent audit. Instead of 1 expert per tmux window, the codebase is split into partitions and each partition runs ALL experts.
378
+ 1. Scan the target directory to understand the codebase structure:
379
+ - Use Glob to find top-level source directories
380
+ - Group related directories into 3-7 logical partitions (coherent domains: auth, api, ui, etc.)
381
+ - If user provided PARTITIONS=N (a number), split into exactly N partitions
382
+ - If user provided PARTITIONS=dir1,dir2,dir3, use those exact directories
383
+ 2. Show the partition plan and agent count to the user, confirm before launching:
384
+ Example: "5 partitions x 13 experts = 65 agents. Estimated cost: $X. Proceed?"
385
+ 3. Spawn sessions with partitions:
386
+ ```bash
387
+ node .agileflow/scripts/spawn-audit-sessions.js --audit=ideate --target=TARGET --depth=extreme --partitions=dir1,dir2,dir3 --focus=FOCUS_KEYS --model=MODEL --json
388
+ ```
389
+ 4. Wait and collect results (same as ultradeep - use tmux-audit-monitor.js)
390
+ 5. Run synthesis on combined results from all partitions (proceed to STEP 4)
391
+
392
+ **PARTITIONS argument** (only used with DEPTH=extreme):
393
+ | Value | Behavior |
394
+ |-------|----------|
395
+ | Not set | AI decides partitions (3-7 based on codebase size) |
396
+ | `PARTITIONS=5` | AI creates exactly 5 partitions |
397
+ | `PARTITIONS=src/auth,src/api,lib` | Use these exact directories |
398
+
399
+ **FOCUS_KEYS mapping from SCOPE**:
400
+
401
+ | SCOPE | FOCUS_KEYS for spawn-audit-sessions.js |
402
+ |-------|---------------------------------------|
403
+ | `all` | `all` (uses all 13 experts) |
404
+ | `security` | `security,api,testing,compliance,monitoring` |
405
+ | `perf` | `performance,database,api,monitoring,analytics` |
406
+ | `code` | `refactor,testing,api,documentation,qa` |
407
+ | `ux` | `ui,accessibility,api,analytics` |
408
+
409
+ > **Skip to STEP 4** after ultradeep collection. Steps 2-3 are only for quick/deep modes.
410
+
411
+ ---
412
+
328
413
  ### STEP 2: DEPLOY EXPERTS IN PARALLEL
329
414
 
415
+ **For quick/deep modes only** (ultradeep uses tmux sessions above).
416
+
330
417
  **CRITICAL**: Deploy ALL experts in a SINGLE message with multiple Task tool calls.
331
418
 
419
+ **If MODEL is specified**, pass it to each Task call via the `model` parameter.
420
+
332
421
  Use this prompt template for each expert:
333
422
 
334
423
  ```
@@ -364,13 +453,14 @@ FORMAT each idea as:
364
453
  ---
365
454
  ```
366
455
 
367
- **Example deployment for SCOPE=all**:
456
+ **Example deployment for SCOPE=all** (add `<parameter name="model">{MODEL}</parameter>` if MODEL is specified):
368
457
 
369
458
  ```xml
370
459
  <invoke name="Task">
371
460
  <parameter name="description">Security ideation</parameter>
372
461
  <parameter name="prompt">[prompt with domain=security]</parameter>
373
462
  <parameter name="subagent_type">agileflow-security</parameter>
463
+ <parameter name="model">{MODEL}</parameter>
374
464
  <parameter name="run_in_background">true</parameter>
375
465
  </invoke>
376
466
 
@@ -378,6 +468,7 @@ FORMAT each idea as:
378
468
  <parameter name="description">Performance ideation</parameter>
379
469
  <parameter name="prompt">[prompt with domain=performance]</parameter>
380
470
  <parameter name="subagent_type">agileflow-performance</parameter>
471
+ <parameter name="model">{MODEL}</parameter>
381
472
  <parameter name="run_in_background">true</parameter>
382
473
  </invoke>
383
474
 
@@ -385,6 +476,7 @@ FORMAT each idea as:
385
476
  <parameter name="description">Code quality ideation</parameter>
386
477
  <parameter name="prompt">[prompt with domain=refactor/code quality]</parameter>
387
478
  <parameter name="subagent_type">agileflow-refactor</parameter>
479
+ <parameter name="model">{MODEL}</parameter>
388
480
  <parameter name="run_in_background">true</parameter>
389
481
  </invoke>
390
482
 
@@ -392,6 +484,7 @@ FORMAT each idea as:
392
484
  <parameter name="description">UX ideation</parameter>
393
485
  <parameter name="prompt">[prompt with domain=ui/ux]</parameter>
394
486
  <parameter name="subagent_type">agileflow-ui</parameter>
487
+ <parameter name="model">{MODEL}</parameter>
395
488
  <parameter name="run_in_background">true</parameter>
396
489
  </invoke>
397
490
 
@@ -399,6 +492,7 @@ FORMAT each idea as:
399
492
  <parameter name="description">Testing ideation</parameter>
400
493
  <parameter name="prompt">[prompt with domain=testing]</parameter>
401
494
  <parameter name="subagent_type">agileflow-testing</parameter>
495
+ <parameter name="model">{MODEL}</parameter>
402
496
  <parameter name="run_in_background">true</parameter>
403
497
  </invoke>
404
498
 
@@ -406,107 +500,42 @@ FORMAT each idea as:
406
500
  <parameter name="description">API/Architecture ideation</parameter>
407
501
  <parameter name="prompt">[prompt with domain=api/architecture]</parameter>
408
502
  <parameter name="subagent_type">agileflow-api</parameter>
503
+ <parameter name="model">{MODEL}</parameter>
409
504
  <parameter name="run_in_background">true</parameter>
410
505
  </invoke>
411
506
  ```
412
507
 
413
- **Example deployment for SCOPE=all DEPTH=ultradeep** (13 experts):
414
-
415
- ```xml
416
- <!-- Deploy ALL 13 experts in a SINGLE message -->
417
- <invoke name="Task">
418
- <parameter name="description">Security ideation</parameter>
419
- <parameter name="prompt">[prompt with domain=security]</parameter>
420
- <parameter name="subagent_type">agileflow-security</parameter>
421
- <parameter name="run_in_background">true</parameter>
422
- </invoke>
423
-
424
- <invoke name="Task">
425
- <parameter name="description">Performance ideation</parameter>
426
- <parameter name="prompt">[prompt with domain=performance]</parameter>
427
- <parameter name="subagent_type">agileflow-performance</parameter>
428
- <parameter name="run_in_background">true</parameter>
429
- </invoke>
430
-
431
- <invoke name="Task">
432
- <parameter name="description">Code quality ideation</parameter>
433
- <parameter name="prompt">[prompt with domain=refactor]</parameter>
434
- <parameter name="subagent_type">agileflow-refactor</parameter>
435
- <parameter name="run_in_background">true</parameter>
436
- </invoke>
437
-
438
- <invoke name="Task">
439
- <parameter name="description">UX ideation</parameter>
440
- <parameter name="prompt">[prompt with domain=ui]</parameter>
441
- <parameter name="subagent_type">agileflow-ui</parameter>
442
- <parameter name="run_in_background">true</parameter>
443
- </invoke>
444
-
445
- <invoke name="Task">
446
- <parameter name="description">Testing ideation</parameter>
447
- <parameter name="prompt">[prompt with domain=testing]</parameter>
448
- <parameter name="subagent_type">agileflow-testing</parameter>
449
- <parameter name="run_in_background">true</parameter>
450
- </invoke>
451
-
452
- <invoke name="Task">
453
- <parameter name="description">API/Architecture ideation</parameter>
454
- <parameter name="prompt">[prompt with domain=api]</parameter>
455
- <parameter name="subagent_type">agileflow-api</parameter>
456
- <parameter name="run_in_background">true</parameter>
457
- </invoke>
508
+ > **Note**: Only include the `<parameter name="model">` line if MODEL was explicitly specified. If not specified, omit it to use the default model.
458
509
 
459
- <!-- Additional ultradeep experts (7 more) -->
460
- <invoke name="Task">
461
- <parameter name="description">Accessibility ideation</parameter>
462
- <parameter name="prompt">[prompt with domain=accessibility]</parameter>
463
- <parameter name="subagent_type">agileflow-accessibility</parameter>
464
- <parameter name="run_in_background">true</parameter>
465
- </invoke>
510
+ **Example deployment for SCOPE=all DEPTH=ultradeep** (13 experts via tmux):
466
511
 
467
- <invoke name="Task">
468
- <parameter name="description">Compliance ideation</parameter>
469
- <parameter name="prompt">[prompt with domain=compliance]</parameter>
470
- <parameter name="subagent_type">agileflow-compliance</parameter>
471
- <parameter name="run_in_background">true</parameter>
472
- </invoke>
512
+ ```bash
513
+ # 1. Dry run to show cost estimate
514
+ node .agileflow/scripts/spawn-audit-sessions.js --audit=ideate --target=. --focus=all --model=opus --dry-run
473
515
 
474
- <invoke name="Task">
475
- <parameter name="description">Database ideation</parameter>
476
- <parameter name="prompt">[prompt with domain=database]</parameter>
477
- <parameter name="subagent_type">agileflow-database</parameter>
478
- <parameter name="run_in_background">true</parameter>
479
- </invoke>
516
+ # 2. After user confirms, spawn sessions
517
+ node .agileflow/scripts/spawn-audit-sessions.js --audit=ideate --target=. --focus=all --model=opus
518
+ ```
480
519
 
481
- <invoke name="Task">
482
- <parameter name="description">Monitoring ideation</parameter>
483
- <parameter name="prompt">[prompt with domain=monitoring]</parameter>
484
- <parameter name="subagent_type">agileflow-monitoring</parameter>
485
- <parameter name="run_in_background">true</parameter>
486
- </invoke>
520
+ Each expert gets its own Claude Code tmux session with full context window. Use the monitor script to track progress:
487
521
 
488
- <invoke name="Task">
489
- <parameter name="description">QA ideation</parameter>
490
- <parameter name="prompt">[prompt with domain=qa]</parameter>
491
- <parameter name="subagent_type">agileflow-qa</parameter>
492
- <parameter name="run_in_background">true</parameter>
493
- </invoke>
522
+ ```bash
523
+ # Check completion status
524
+ node .agileflow/scripts/lib/tmux-audit-monitor.js status TRACE_ID
525
+ # Wait for all to complete (blocks until done or timeout)
526
+ node .agileflow/scripts/lib/tmux-audit-monitor.js wait TRACE_ID --timeout=1800
527
+ # Collect whatever results are ready
528
+ node .agileflow/scripts/lib/tmux-audit-monitor.js collect TRACE_ID
529
+ ```
494
530
 
495
- <invoke name="Task">
496
- <parameter name="description">Analytics ideation</parameter>
497
- <parameter name="prompt">[prompt with domain=analytics]</parameter>
498
- <parameter name="subagent_type">agileflow-analytics</parameter>
499
- <parameter name="run_in_background">true</parameter>
500
- </invoke>
531
+ **For SCOPE-filtered ultradeep** (e.g., SCOPE=security):
501
532
 
502
- <invoke name="Task">
503
- <parameter name="description">Documentation ideation</parameter>
504
- <parameter name="prompt">[prompt with domain=documentation]</parameter>
505
- <parameter name="subagent_type">agileflow-documentation</parameter>
506
- <parameter name="run_in_background">true</parameter>
507
- </invoke>
533
+ ```bash
534
+ node .agileflow/scripts/spawn-audit-sessions.js --audit=ideate --target=. --focus=security,api,testing,compliance,monitoring --model=sonnet
508
535
  ```
509
536
 
537
+ > **Fallback**: If tmux is unavailable, fall back to DEPTH=deep with in-process Task calls (6 experts). Warn the user: "tmux not available, falling back to DEPTH=deep with 6 in-process experts"
538
+
510
539
  ### STEP 3: COLLECT RESULTS
511
540
 
512
541
  Wait for all experts to complete:
@@ -745,13 +774,17 @@ After generating output, present options:
745
774
 
746
775
  ### Example: Ultradeep Execution
747
776
 
748
- **User**: `/agileflow:ideate:new SCOPE=all DEPTH=ultradeep OUTPUT=both`
777
+ **User**: `/agileflow:ideate:new SCOPE=all DEPTH=ultradeep MODEL=opus OUTPUT=both`
749
778
 
750
- **Step 1**: Parse → SCOPE=all (13 experts), DEPTH=ultradeep (5 ideas each), OUTPUT=both
779
+ **Step 1**: Parse → SCOPE=all (13 experts), DEPTH=ultradeep, MODEL=opus, OUTPUT=both
751
780
 
752
- **Step 2**: Deploy 13 experts in parallel (security, performance, refactor, ui, testing, api, accessibility, compliance, database, monitoring, qa, analytics, documentation)
781
+ **Step 1.5**: Ultradeep mode detected:
782
+ - Run dry-run: `node .agileflow/scripts/spawn-audit-sessions.js --audit=ideate --target=. --focus=all --model=opus --dry-run`
783
+ - Show cost estimate to user, confirm before launching
784
+ - Spawn 13 tmux sessions: `node .agileflow/scripts/spawn-audit-sessions.js --audit=ideate --target=. --focus=all --model=opus`
785
+ - Monitor `docs/09-agents/ultradeep/{trace_id}/` for sentinel files
753
786
 
754
- **Step 3**: Collect results (~65 raw ideas)
787
+ **Step 3**: Collect results from sentinel files (~65 raw ideas)
755
788
 
756
789
  **Step 4**: Synthesize with ultradeep thresholds:
757
790
  - 8 ideas mentioned by 3+ experts → HIGH confidence
@@ -771,11 +804,12 @@ After generating output, present options:
771
804
  | Argument | Values | Default | Description |
772
805
  |----------|--------|---------|-------------|
773
806
  | SCOPE | all, security, perf, code, ux | all | Which domains to analyze |
774
- | DEPTH | quick, deep, ultradeep | quick | quick (3 ideas, 6 experts), deep (5 ideas, 6 experts), ultradeep (5 ideas, 13 experts) |
807
+ | DEPTH | quick, deep, ultradeep | quick | quick (3 ideas, 6 experts), deep (5 ideas, 6 experts), ultradeep (5 ideas, 13 experts via tmux) |
775
808
  | OUTPUT | report, stories, both | report | What to generate |
776
809
  | HISTORY | true, false | true | Enable deduplication and history tracking. Set to false for faster runs without history analysis |
777
810
  | SHOW_IMPLEMENTED | true, false | false | Include already-implemented ideas in report (useful for tracking) |
778
811
  | FOCUS | IDEA-XXXX | - | Focus on a specific recurring idea (activates Implementation Brief mode) |
812
+ | MODEL | haiku, sonnet, opus | haiku | Model for expert subagents. Passed to Task calls (quick/deep) or tmux sessions (ultradeep). |
779
813
 
780
814
  {{argument}}
781
815
 
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  description: Analyze change impact across codebase
3
+ phase: planning
3
4
  argument-hint: "[FILES=<paths>] [BASE=<branch>] [RUN_TESTS=true|false]"
4
5
  compact_context:
5
6
  priority: high
@@ -0,0 +1,118 @@
1
+ ---
2
+ description: Deep explanation of code areas - not just what the code does, but WHY it was written this way, with git history and design reasoning
3
+ argument-hint: "[file|function|feature] [DEPTH=quick|thorough]"
4
+ ---
5
+
6
+ # /agileflow:learn:explain
7
+
8
+ Get a deep "why" explanation of code areas. Goes beyond what the code does to explain why it was written this way, what alternatives were considered, and what historical context shaped it.
9
+
10
+ ---
11
+
12
+ ## Quick Reference
13
+
14
+ ```
15
+ /agileflow:learn:explain src/auth/middleware.ts # Explain specific file
16
+ /agileflow:learn:explain handleCheckout # Explain a function
17
+ /agileflow:learn:explain "the caching layer" # Explain a concept/area
18
+ /agileflow:learn:explain app/api/ DEPTH=thorough # Thorough explanation
19
+ ```
20
+
21
+ ---
22
+
23
+ ## How It Works
24
+
25
+ 1. **Find the code** - Locate the target file, function, or feature
26
+ 2. **Read the code** - Understand what it does
27
+ 3. **Check git history** - Find when/why it was written or changed
28
+ 4. **Analyze design decisions** - Explain the "why" behind the approach
29
+ 5. **Surface alternatives** - What other approaches could have been used
30
+ 6. **Present explanation** - Clear, educational explanation with context
31
+
32
+ ---
33
+
34
+ ## Step-by-Step Process
35
+
36
+ ### STEP 1: Parse Arguments
37
+
38
+ ```
39
+ TARGET = file path, function name, or feature description
40
+ DEPTH = quick (3-5 min read) or thorough (10-15 min read)
41
+ ```
42
+
43
+ ### STEP 2: Find and Read Code
44
+
45
+ 1. If file path: read the file directly
46
+ 2. If function name: search codebase for the function
47
+ 3. If feature description: use `Explore` agent to find relevant files
48
+
49
+ ### STEP 3: Analyze Git History
50
+
51
+ ```bash
52
+ git log --follow --oneline {file} # See file history
53
+ git log -p --follow -S "{function}" -- . # Find when function was added/changed
54
+ git blame {file} # See who wrote each line and when
55
+ ```
56
+
57
+ ### STEP 4: Generate Explanation
58
+
59
+ Structure the explanation:
60
+
61
+ ```markdown
62
+ ## What This Code Does
63
+
64
+ {Clear explanation of the code's purpose and behavior}
65
+
66
+ ## Why It's Written This Way
67
+
68
+ {Design reasoning - what constraints or requirements led to this approach}
69
+
70
+ ### Historical Context
71
+ {Git history insights - when it was written, major changes, why changes were made}
72
+
73
+ ### Design Decisions
74
+ | Decision | Choice Made | Why | Alternative Considered |
75
+ |----------|-------------|-----|----------------------|
76
+ | {decision} | {choice} | {reasoning} | {what else could have been done} |
77
+
78
+ ## How It Connects
79
+
80
+ {Data flow diagram showing where this code fits in the system}
81
+
82
+ ```mermaid
83
+ graph LR
84
+ A[Input] --> B[This Code] --> C[Output]
85
+ B --> D[Side Effects]
86
+ ```
87
+
88
+ ## Key Concepts
89
+
90
+ | Concept | Explanation |
91
+ |---------|-------------|
92
+ | {term} | {what it means in this context} |
93
+
94
+ ## Gotchas
95
+
96
+ {Non-obvious behaviors, edge cases, or things to be careful about}
97
+ ```
98
+
99
+ ### STEP 5: Offer Follow-Up
100
+
101
+ ```
102
+ Explanation complete for {target}.
103
+
104
+ Options:
105
+ - Explain a related area
106
+ - Tour the broader system this belongs to
107
+ - See similar patterns elsewhere in the codebase
108
+ - Done
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Related Commands
114
+
115
+ - `/agileflow:learn:tour` - Guided codebase walkthrough
116
+ - `/agileflow:learn:patterns` - Design patterns catalog
117
+ - `/agileflow:learn:glossary` - Domain terminology
118
+ - `/agileflow:context:full` - Full project context