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
@@ -0,0 +1,238 @@
1
+ ---
2
+ description: Advance TDD phase (RED→GREEN→REFACTOR→COMPLETE)
3
+ argument-hint: "[<US-ID>]"
4
+ compact_context:
5
+ priority: high
6
+ preserve_rules:
7
+ - "TDD phase gate: RED→GREEN requires test_status=failing"
8
+ - "TDD phase gate: GREEN→REFACTOR requires test_status=passing"
9
+ - "TDD phase gate: REFACTOR→COMPLETE requires test_status=passing"
10
+ - "Always run /agileflow:verify before attempting phase advance"
11
+ - "Show clear phase transition banner with new phase instructions"
12
+ state_fields:
13
+ - tdd_phase
14
+ - test_status
15
+ ---
16
+
17
+ # /agileflow:tdd-next - Advance TDD Phase
18
+
19
+ Advance to the next TDD phase with gate validation.
20
+
21
+ ---
22
+
23
+ ## STEP 0: Gather Context
24
+
25
+ ```bash
26
+ node .agileflow/scripts/obtain-context.js tdd-next
27
+ ```
28
+
29
+ ---
30
+
31
+ <!-- COMPACT_SUMMARY_START -->
32
+
33
+ ## Compact Summary
34
+
35
+ **Role**: TDD Phase Gate Controller
36
+
37
+ **Critical Rules**:
38
+ 1. Read current `tdd_phase` and `test_status` from status.json
39
+ 2. Validate transition conditions (failing/passing tests)
40
+ 3. Block advancement if conditions not met
41
+ 4. Update `tdd_phase` in status.json on success
42
+ 5. Display new phase instructions
43
+
44
+ **Transitions**:
45
+ - RED → GREEN: `test_status` must be `"failing"`
46
+ - GREEN → REFACTOR: `test_status` must be `"passing"`
47
+ - REFACTOR → RED (new cycle): `test_status` must be `"passing"`
48
+ - REFACTOR → COMPLETE: `test_status` must be `"passing"`
49
+
50
+ <!-- COMPACT_SUMMARY_END -->
51
+
52
+ ## Prompt
53
+
54
+ ROLE: TDD Phase Gate Controller
55
+
56
+ INPUTS
57
+ STORY=<US-ID> Optional - defaults to current in_progress story with active tdd_phase
58
+
59
+ ACTIONS
60
+ 1) Load story and current TDD phase from status.json
61
+ 2) Determine target phase based on current phase
62
+ 3) Validate gate conditions (test_status)
63
+ 4) If gate passes: advance phase, show new instructions
64
+ 5) If gate fails: show blocking message with remedy
65
+
66
+ ---
67
+
68
+ ## Usage
69
+
70
+ ```
71
+ /agileflow:tdd-next # Advance current TDD story
72
+ /agileflow:tdd-next US-0042 # Advance specific story
73
+ ```
74
+
75
+ ## Workflow
76
+
77
+ ### 1. Find Active TDD Story
78
+
79
+ Read `docs/09-agents/status.json`. Find the story:
80
+ - If STORY specified, use that
81
+ - Otherwise, find the story with an active `tdd_phase` (not complete/cancelled)
82
+ - If multiple active, ask user to specify
83
+
84
+ ### 2. Determine Target Phase
85
+
86
+ Based on current phase, determine what to advance to:
87
+
88
+ | Current | Default Next | Alternative |
89
+ |---------|-------------|-------------|
90
+ | RED | GREEN | cancel |
91
+ | GREEN | REFACTOR | cancel |
92
+ | REFACTOR | COMPLETE | RED (new cycle), cancel |
93
+
94
+ For REFACTOR, ask the user:
95
+ ```json
96
+ [
97
+ {"label": "Complete TDD (Recommended)", "description": "All tests pass, code is clean - ready for review"},
98
+ {"label": "Start new RED→GREEN cycle", "description": "More features to add with TDD discipline"},
99
+ {"label": "Cancel TDD", "description": "Exit TDD workflow, keep changes"}
100
+ ]
101
+ ```
102
+
103
+ ### 3. Validate Gate Conditions
104
+
105
+ Check `test_status` in the story against transition requirements:
106
+
107
+ **RED → GREEN** (needs `test_status: "failing"`):
108
+ ```
109
+ Current: 🔴 RED phase
110
+ Target: 🟢 GREEN phase
111
+ Gate: test_status must be "failing"
112
+ Status: test_status = "failing" ✅
113
+
114
+ Advancing to GREEN phase...
115
+ ```
116
+
117
+ **Gate BLOCKED example:**
118
+ ```
119
+ Current: 🔴 RED phase
120
+ Target: 🟢 GREEN phase
121
+ Gate: test_status must be "failing"
122
+ Status: test_status = "passing" ❌
123
+
124
+ 🚫 Cannot advance: Tests must FAIL before moving to GREEN.
125
+
126
+ This means either:
127
+ 1. You haven't written tests yet (write failing tests first)
128
+ 2. Your tests pass because they don't test real behavior
129
+ 3. The implementation already exists
130
+
131
+ Action: Write tests that verify behavior not yet implemented.
132
+ Then run /agileflow:verify to confirm they fail.
133
+ ```
134
+
135
+ **No test_status at all:**
136
+ ```
137
+ 🚫 Cannot advance: No test results found.
138
+
139
+ Run /agileflow:verify first to execute tests and record status.
140
+ Then try /agileflow:tdd-next again.
141
+ ```
142
+
143
+ ### 4. Advance Phase
144
+
145
+ On success, update status.json:
146
+ ```json
147
+ {
148
+ "tdd_phase": "green",
149
+ "tdd_last_transition": "2026-02-25T..."
150
+ }
151
+ ```
152
+
153
+ ### 5. Display New Phase Banner
154
+
155
+ ```
156
+ 🟢 TDD GREEN PHASE - US-0042: [Story Title]
157
+ ══════════════════════════════════════════
158
+
159
+ RED → GREEN transition complete! ✅
160
+
161
+ Write MINIMAL code to make tests pass. Rules:
162
+ • Write the simplest implementation that passes tests
163
+ • Do NOT refactor yet - ugly code is fine
164
+ • Do NOT add features beyond what tests require
165
+ • Do NOT modify test files (except removing .skip())
166
+ • Run tests frequently
167
+
168
+ Next steps:
169
+ 1. Implement code to pass the failing tests
170
+ 2. Run /agileflow:verify to confirm tests PASS
171
+ 3. Run /agileflow:tdd-next to advance to REFACTOR
172
+ ```
173
+
174
+ ### 6. AskUserQuestion
175
+
176
+ After showing the transition result:
177
+
178
+ **Successful advance to GREEN:**
179
+ ```json
180
+ [
181
+ {"label": "Start implementing to pass tests (Recommended)", "description": "Write minimal code - tests define the requirements"},
182
+ {"label": "Review the failing tests first", "description": "Read test files to understand requirements"},
183
+ {"label": "Cancel TDD mode", "description": "Exit TDD workflow, keep test files"}
184
+ ]
185
+ ```
186
+
187
+ **Successful advance to REFACTOR:**
188
+ ```json
189
+ [
190
+ {"label": "Start refactoring (Recommended)", "description": "Tests pass - clean up the code while keeping them green"},
191
+ {"label": "Run logic audit on implementation", "description": "Check for edge cases before refactoring"},
192
+ {"label": "Skip refactor, complete TDD", "description": "Code is clean enough - finish TDD cycle"}
193
+ ]
194
+ ```
195
+
196
+ **Successful COMPLETE:**
197
+ ```json
198
+ [
199
+ {"label": "Run code review (Recommended)", "description": "TDD complete - review before committing"},
200
+ {"label": "Commit changes", "description": "All tests pass, TDD cycle done"},
201
+ {"label": "Start new TDD cycle", "description": "More features to implement for this story"}
202
+ ]
203
+ ```
204
+
205
+ **Gate blocked:**
206
+ ```json
207
+ [
208
+ {"label": "Run /agileflow:verify (Recommended)", "description": "Execute tests to update test_status"},
209
+ {"label": "Review test files", "description": "Check if tests are correctly written"},
210
+ {"label": "Cancel TDD mode", "description": "Exit TDD workflow"}
211
+ ]
212
+ ```
213
+
214
+ ## Error Handling
215
+
216
+ ### No Active TDD Story
217
+ ```
218
+ ❌ No active TDD workflow found.
219
+
220
+ Start TDD with: /agileflow:tdd US-0042
221
+ ```
222
+
223
+ ### Multiple Active TDD Stories
224
+ ```
225
+ ⚠️ Multiple active TDD stories found:
226
+ 🔴 US-0042: Add auth middleware (RED phase)
227
+ 🟢 US-0043: User settings API (GREEN phase)
228
+
229
+ Specify which story: /agileflow:tdd-next US-0042
230
+ ```
231
+
232
+ ---
233
+
234
+ ## Related Commands
235
+
236
+ - `/agileflow:tdd` - Start TDD workflow
237
+ - `/agileflow:verify` - Run tests and update test_status
238
+ - `/agileflow:babysit` - Main implementation workflow
@@ -0,0 +1,211 @@
1
+ ---
2
+ description: Start TDD workflow with RED→GREEN→REFACTOR phases
3
+ phase: implementation
4
+ argument-hint: "<US-ID>"
5
+ compact_context:
6
+ priority: high
7
+ preserve_rules:
8
+ - "TDD WORKFLOW ACTIVE: Enforce RED→GREEN→REFACTOR phases"
9
+ - "RED phase: Write failing tests ONLY - no implementation code"
10
+ - "GREEN phase: Minimal code to make tests pass - no extras"
11
+ - "REFACTOR phase: Clean up while keeping tests green"
12
+ - "Use /agileflow:verify to confirm test status before advancing"
13
+ - "Use /agileflow:tdd-next to advance to next phase"
14
+ - "Phase gates are HARD - cannot skip (RED needs failing tests, GREEN needs passing)"
15
+ state_fields:
16
+ - tdd_phase
17
+ - tdd_cycles
18
+ - test_status
19
+ ---
20
+
21
+ # /agileflow:tdd - Test-Driven Development Workflow
22
+
23
+ Start a TDD workflow for a story, enforcing RED→GREEN→REFACTOR phase discipline.
24
+
25
+ ---
26
+
27
+ ## STEP 0: Gather Context
28
+
29
+ ```bash
30
+ node .agileflow/scripts/obtain-context.js tdd
31
+ ```
32
+
33
+ ---
34
+
35
+ <!-- COMPACT_SUMMARY_START -->
36
+
37
+ ## Compact Summary
38
+
39
+ **Role**: TDD Coach - Enforce test-first development with phase gates
40
+
41
+ **Critical Rules**:
42
+ 1. Start in RED phase - write failing tests first
43
+ 2. Cannot advance to GREEN without failing tests (verified by /agileflow:verify)
44
+ 3. Cannot advance to REFACTOR without passing tests
45
+ 4. Cannot complete without passing tests after refactor
46
+ 5. Track phase in status.json story entry (`tdd_phase` field)
47
+
48
+ **Phase Summary**:
49
+ - 🔴 RED: Write tests that FAIL (test what the code SHOULD do)
50
+ - 🟢 GREEN: Write MINIMAL code to make tests PASS
51
+ - 🔵 REFACTOR: Clean up while keeping tests GREEN
52
+ - ✅ COMPLETE: All tests pass, code is clean
53
+
54
+ <!-- COMPACT_SUMMARY_END -->
55
+
56
+ ## Prompt
57
+
58
+ ROLE: TDD Coach
59
+
60
+ INPUTS
61
+ STORY=<US-ID> Required - story to start TDD for
62
+
63
+ ACTIONS
64
+ 1) Load story from status.json
65
+ 2) Initialize TDD RED phase for the story
66
+ 3) Display phase instructions and constraints
67
+ 4) Guide user through test-first development
68
+
69
+ ---
70
+
71
+ ## Usage
72
+
73
+ ```
74
+ /agileflow:tdd US-0042
75
+ ```
76
+
77
+ ## Workflow
78
+
79
+ ### 1. Initialize
80
+
81
+ Read `docs/09-agents/status.json` and locate the story. Set:
82
+ ```json
83
+ {
84
+ "tdd_phase": "red",
85
+ "tdd_started_at": "2026-02-25T...",
86
+ "tdd_cycles": 1
87
+ }
88
+ ```
89
+
90
+ If the story already has an active `tdd_phase` (not complete/cancelled), resume it instead.
91
+
92
+ ### 2. Display Phase Banner
93
+
94
+ Show the current phase prominently:
95
+
96
+ ```
97
+ 🔴 TDD RED PHASE - US-0042: [Story Title]
98
+ ══════════════════════════════════════════
99
+
100
+ Write FAILING tests first. Rules:
101
+ • Write test files ONLY - no implementation code yet
102
+ • Tests should cover the acceptance criteria
103
+ • Tests MUST fail when run (they test code that doesn't exist)
104
+ • Focus on the public API - what should the code DO?
105
+
106
+ Allowed files: **/*.test.*, **/*.spec.*, **/tests/**, **/fixtures/**
107
+
108
+ Next steps:
109
+ 1. Write your failing tests
110
+ 2. Run /agileflow:verify to confirm tests FAIL
111
+ 3. Run /agileflow:tdd-next to advance to GREEN
112
+ ```
113
+
114
+ ### 3. Phase-Specific Guidance
115
+
116
+ #### 🔴 RED Phase
117
+ - Help user identify WHAT to test based on acceptance criteria
118
+ - Suggest test file names and locations based on project conventions
119
+ - Write test code that exercises the expected API/interface
120
+ - Tests should be meaningful - not just `expect(true).toBe(false)`
121
+ - Use the project's testing framework (detect from package.json, pytest.ini, etc.)
122
+
123
+ #### 🟢 GREEN Phase (after /agileflow:tdd-next)
124
+ - Write the simplest possible implementation to pass tests
125
+ - Resist the urge to over-engineer or optimize
126
+ - If a test needs a complex solution, the test may be too broad
127
+ - Run tests frequently during implementation
128
+
129
+ #### 🔵 REFACTOR Phase (after /agileflow:tdd-next)
130
+ - Extract common patterns into helper functions
131
+ - Improve naming and readability
132
+ - Reduce duplication
133
+ - Run tests after every change - any failure means rollback
134
+
135
+ ### 4. AskUserQuestion Integration
136
+
137
+ After showing the phase banner, present smart options:
138
+
139
+ **RED phase start:**
140
+ ```json
141
+ [
142
+ {"label": "Show acceptance criteria for test planning (Recommended)", "description": "Review AC to identify what tests to write"},
143
+ {"label": "Create test file scaffold", "description": "Generate test file structure based on story requirements"},
144
+ {"label": "Cancel TDD mode", "description": "Exit TDD and use standard implementation workflow"}
145
+ ]
146
+ ```
147
+
148
+ **After tests written (RED):**
149
+ ```json
150
+ [
151
+ {"label": "Run /agileflow:verify to check tests fail (Recommended)", "description": "Tests must fail before advancing to GREEN"},
152
+ {"label": "Write more tests", "description": "Add additional test cases"},
153
+ {"label": "Cancel TDD mode", "description": "Exit TDD workflow"}
154
+ ]
155
+ ```
156
+
157
+ **After verify confirms failing (RED→GREEN):**
158
+ ```json
159
+ [
160
+ {"label": "Advance to GREEN phase (Recommended)", "description": "Tests are failing - ready to write implementation"},
161
+ {"label": "Write more failing tests first", "description": "Add more test coverage before implementing"},
162
+ {"label": "Cancel TDD mode", "description": "Exit TDD workflow"}
163
+ ]
164
+ ```
165
+
166
+ ## Integration Points
167
+
168
+ ### Uses
169
+ - `docs/09-agents/status.json` - Story data and TDD phase tracking
170
+ - `/agileflow:verify` - Test execution and status updates
171
+ - `/agileflow:tdd-next` - Phase advancement
172
+
173
+ ### Used By
174
+ - `/agileflow:babysit` - Can suggest TDD workflow for stories
175
+ - `/agileflow:babysit STRICT=true` - TDD recommended as default approach
176
+
177
+ ## Error Handling
178
+
179
+ ### Story Not Found
180
+ ```
181
+ ❌ Story US-0099 not found in status.json
182
+
183
+ Available stories:
184
+ - US-0042: Add user authentication (ready)
185
+ - US-0043: Implement settings page (in_progress)
186
+ ```
187
+
188
+ ### Already in TDD
189
+ ```
190
+ 🔴 Resuming TDD for US-0042 (RED phase, cycle 1)
191
+
192
+ You're already in TDD mode. Current phase: RED
193
+ Write failing tests, then run /agileflow:tdd-next to advance.
194
+ ```
195
+
196
+ ### No Test Framework Detected
197
+ ```
198
+ ⚠️ No test framework detected for this project.
199
+
200
+ Run /agileflow:tests first to set up testing infrastructure,
201
+ then restart TDD with /agileflow:tdd US-0042.
202
+ ```
203
+
204
+ ---
205
+
206
+ ## Related Commands
207
+
208
+ - `/agileflow:tdd-next` - Advance TDD phase (RED→GREEN→REFACTOR→COMPLETE)
209
+ - `/agileflow:verify` - Run tests and update test_status
210
+ - `/agileflow:tests` - Set up testing infrastructure
211
+ - `/agileflow:babysit` - Main implementation workflow (can integrate TDD)
@@ -43,12 +43,16 @@ node -e "console.log(JSON.stringify({ agentTeams: !!process.env.CLAUDE_CODE_EXPE
43
43
 
44
44
  The argument specifies which team template to use. Available templates are in `.agileflow/teams/`:
45
45
 
46
- | Template | Description |
47
- |----------|-------------|
48
- | `fullstack` | API + UI + Testing specialists |
49
- | `code-review` | Code reviewer + Security + Performance |
50
- | `builder-validator` | Paired builders with validators |
51
- | `logic-audit` | Multi-perspective logic analysis |
46
+ | Template | Description | Best For |
47
+ |----------|-------------|----------|
48
+ | `fullstack` | API + UI + Testing specialists | Full-stack feature development |
49
+ | `backend` | API + Database + Security specialists | Backend/API work |
50
+ | `frontend` | UI + Accessibility + Testing specialists | Frontend/component work |
51
+ | `solo` | Mentor + Testing (lightweight) | Solo developers, learning |
52
+ | `qa` | QA Strategy + Testing + Browser QA | Test coverage, regression |
53
+ | `code-review` | Code reviewer + Security + Performance | Pre-PR quality gates |
54
+ | `builder-validator` | Paired builders with validators | High-reliability features |
55
+ | `logic-audit` | Multi-perspective logic analysis | Complex business logic |
52
56
 
53
57
  If no argument given, use AskUserQuestion to let user choose.
54
58
 
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  description: Set up automated testing infrastructure
3
+ phase: implementation
3
4
  argument-hint: "(no arguments)"
4
5
  compact_context:
5
6
  priority: high
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  description: Run project tests and update story test status
3
+ phase: implementation
3
4
  argument-hint: "[<US-ID>]"
4
5
  compact_context:
5
6
  priority: critical
@@ -259,7 +260,32 @@ Record test verification in current session:
259
260
  }
260
261
  ```
261
262
 
262
- ### 7. Generate Report
263
+ ### 7. AC Coverage Report (Optional)
264
+
265
+ After tests pass, if the current story has acceptance criteria, run the AC-to-test matcher to show coverage:
266
+
267
+ ```bash
268
+ node -e "
269
+ const { matchACToTests } = require('./.agileflow/scripts/lib/ac-test-matcher');
270
+ const result = matchACToTests('{{STORY_ID}}');
271
+ console.log(JSON.stringify(result, null, 2));
272
+ "
273
+ ```
274
+
275
+ Append AC coverage to the verification report:
276
+
277
+ ```
278
+ AC Coverage: 3/5 (60%)
279
+ ✅ AC1: "Create audit command" → matched to audit.test.js (high)
280
+ ✅ AC2: "Accept story ID" → matched to audit.test.js (high)
281
+ ✅ AC3: "Run tests" → matched to verify.test.js (medium)
282
+ ⬜ AC4: "Check AC met" → no matching tests
283
+ ⬜ AC5: "Prompt for learnings" → no matching tests
284
+ ```
285
+
286
+ If no story is specified or story has no AC, skip this section.
287
+
288
+ ### 8. Generate Report
263
289
 
264
290
  **Success Report**:
265
291
  ```
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  description: Define and run parameterized workflow templates
3
+ phase: implementation
3
4
  argument-hint: "<template> [<arguments>]"
4
5
  compact_context:
5
6
  priority: normal
@@ -228,6 +229,7 @@ docs/08-project/workflows/
228
229
  ---
229
230
  name: deploy-staging
230
231
  description: Deploy to staging environment
232
+ phase: implementation
231
233
  arguments:
232
234
  - name: version
233
235
  required: true
@@ -0,0 +1,105 @@
1
+ # Core Expertise - Always-Loaded AgileFlow Knowledge
2
+ # These 3 curated modules contain high-value cross-cutting patterns.
3
+ # Loaded by all agents. Domain-specific files are reference-only (loaded on demand).
4
+
5
+ version: 1.0
6
+ last_updated: 2026-02-26
7
+
8
+ # Module 1: CLI Architecture Patterns
9
+ cli_architecture:
10
+ structure:
11
+ source: packages/cli/src/core/
12
+ commands: "src/core/commands/*.md - Slash commands with frontmatter"
13
+ agents: "src/core/agents/*.md - Spawnable agents with frontmatter"
14
+ experts: "src/core/experts/*/expertise.yaml - Domain knowledge"
15
+ skills: "src/core/skills/ - Skill learnings and marketplace (browse via /skill:recommend)"
16
+
17
+ content_injection:
18
+ description: "Source files use placeholders replaced at install time"
19
+ placeholders:
20
+ - "<!-- {{AGENT_LIST}} --> - Current agent list"
21
+ - "<!-- {{COMMAND_LIST}} --> - Current command list"
22
+ - "<!-- {{SKILL_LIST}} --> - Current skill list"
23
+ pipeline: "content-injector.js -> content-transformer.js -> IDE installer"
24
+
25
+ installers:
26
+ core: "tools/cli/installers/core/installer.js - Copies agents, commands, scripts"
27
+ ide_base: "tools/cli/installers/ide/_base-ide.js - Shared IDE setup logic"
28
+ claude_code: "tools/cli/installers/ide/claude-code.js - Claude Code specific (hooks, agents)"
29
+
30
+ key_conventions:
31
+ - "Commands: frontmatter with description, optional argument-hint"
32
+ - "Agents: frontmatter with name, description, tools, model (no agileflow- prefix in filename)"
33
+ - "Scripts in packages/cli/scripts/ are PUBLISHED (copied to user projects)"
34
+ - "Scripts in root scripts/ are dev-only (NOT published)"
35
+ - "Dynamic counts: run npm run sync-counts after adding commands/agents"
36
+
37
+ # Module 2: Testing Conventions
38
+ testing:
39
+ framework:
40
+ runner: "Jest (packages/cli/__tests__/)"
41
+ command: "npm test from packages/cli/"
42
+ total_tests: "~4373+ tests across 161+ suites"
43
+
44
+ patterns:
45
+ - "Tests mirror source structure: __tests__/lib/ for tools/cli/lib/"
46
+ - "Use jest.mock() for fs, child_process dependencies"
47
+ - "Expertise validation: scripts/validate-expertise.sh"
48
+ - "Story test tracking: status.json test_status field (passing/failing/not_run)"
49
+
50
+ quality_gates:
51
+ - "All tests must pass before commit"
52
+ - "Session Harness: /agileflow:verify runs tests for current story"
53
+ - "/agileflow:baseline marks verified state"
54
+ - "Logic audit: 5 analyzers check edge cases, race conditions, type bugs"
55
+
56
+ known_issues:
57
+ - "api-server port 3456 conflict causes ~10 test failures (pre-existing)"
58
+ - "--legacy-peer-deps required for TensorFlow.js version conflicts"
59
+
60
+ # Module 3: Security Guidelines
61
+ security:
62
+ commit_policy:
63
+ - "NO AI attribution in commits (forbidden: Co-Authored-By AI, emoji robots)"
64
+ - "Clean conventional commits only (feat/fix/chore/docs)"
65
+
66
+ secrets:
67
+ gitignored: [".npmrc", "CLAUDE.md"]
68
+ storage: "NPM_TOKEN in GitHub Secrets, never committed"
69
+
70
+ code_patterns:
71
+ - "Use execFileSync(cmd, [args]) not execSync(`cmd ${var}`) to prevent injection"
72
+ - "Validate PIDs are numeric, ports are numbers, paths don't traverse"
73
+ - "Damage control hooks guard Bash/Edit/Write via PreToolUse"
74
+ - "patterns.yaml defines blocked commands, read-only paths, zero-access paths"
75
+
76
+ hooks:
77
+ exit_codes: "0=allow, 1=error (fail-open), 2=block"
78
+ files:
79
+ - "damage-control/bash-tool-damage-control.js"
80
+ - "damage-control/edit-tool-damage-control.js"
81
+ - "damage-control/write-tool-damage-control.js"
82
+ - "lib/damage-control-utils.js - Shared validation logic"
83
+
84
+ # Data Stores (cross-cutting knowledge)
85
+ data_stores:
86
+ status_json:
87
+ path: "docs/09-agents/status.json"
88
+ schema: "epics (EP-ID keys), stories (US-ID keys)"
89
+ operations: "Read-modify-write with updated timestamp"
90
+ session_state:
91
+ path: "docs/09-agents/session-state.json"
92
+ purpose: "Active command, loop state, smart-detect results"
93
+ archive:
94
+ path: "docs/09-agents/archive/YYYY-MM.json"
95
+ policy: "Completed stories >7 days auto-archived"
96
+ metadata:
97
+ path: "docs/00-meta/agileflow-metadata.json"
98
+ purpose: "Config schema version, feature toggles, profiles"
99
+
100
+ # Release Process
101
+ release:
102
+ command: "./scripts/release.sh <version> <title>"
103
+ version_files: ["packages/cli/package.json", "package.json"]
104
+ ci: ".github/workflows/npm-publish.yml triggered by v*.*.* tags"
105
+ brand_color: "#e8683a"