@torka/claude-workflows 0.2.0 → 0.3.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.
@@ -0,0 +1,437 @@
1
+ ---
2
+ name: 'step-02-orchestrate'
3
+ description: 'Main orchestration loop - execute all stories autonomously with sub-agents'
4
+
5
+ # Path Definitions
6
+ workflow_path: '{project-root}/_bmad/bmm/workflows/4-implementation/implement-epic-with-subagents'
7
+
8
+ # File References
9
+ thisStepFile: '{workflow_path}/steps/step-02-orchestrate.md'
10
+ nextStepFile: '{workflow_path}/steps/step-03-complete.md'
11
+ workflowFile: '{workflow_path}/workflow.md'
12
+
13
+ # Template References
14
+ spawnStoryPrepTemplate: '{workflow_path}/templates/spawn-story-prep.md'
15
+ spawnDevAgentTemplate: '{workflow_path}/templates/spawn-dev-agent.md'
16
+ spawnCodeReviewTemplate: '{workflow_path}/templates/spawn-code-review.md'
17
+
18
+ # Task References
19
+ # (orchestration uses sub-agents, not BMAD tasks)
20
+
21
+ # State files
22
+ sidecarFolder: '{output_folder}/epic-executions'
23
+ sprintStatus: '{implementation_artifacts}/sprint-status.yaml'
24
+
25
+ # Agent references
26
+ storyPrepAgent: '.claude/agents/story-prep-master.md'
27
+ codeReviewAgent: '.claude/agents/principal-code-reviewer.md'
28
+ specialistAgentsFolder: '.claude/agents/vt-bmad-dev-agents/'
29
+ fallbackDevAgent: '_bmad/bmm/agents/dev.md'
30
+
31
+ # Configuration
32
+ coverageThreshold: 80
33
+ maxRetries: 3
34
+ ---
35
+
36
+ # Step 2: Story Orchestration Loop
37
+
38
+ ## STEP GOAL:
39
+
40
+ To autonomously execute all pending stories in the epic by orchestrating specialized sub-agents through the complete implementation pipeline: create → develop → visual-check (UI only) → review → commit → finalize.
41
+
42
+ ## MANDATORY EXECUTION RULES (READ FIRST):
43
+
44
+ ### Universal Rules:
45
+
46
+ - 🛑 NEVER generate content without user input
47
+ - 📖 CRITICAL: Read the complete step file before taking any action
48
+ - 🔄 CRITICAL: When loading next step with 'C', ensure entire file is read
49
+ - 📋 YOU ARE A FACILITATOR, not a content generator
50
+
51
+ ### Orchestrator-Specific Rules (Autonomous Execution):
52
+
53
+ - 🛑 PAUSE execution only on critical blockers or user-required decisions
54
+ - 📖 CRITICAL: Execute stories sequentially, one at a time
55
+ - 🔄 CRITICAL: Update sidecar state after EVERY phase completion
56
+ - 📋 YOU ARE THE ORCHESTRATOR - spawn agents, parse results, manage flow
57
+
58
+ ### Role Reinforcement:
59
+
60
+ - ✅ You are an Epic Execution Orchestrator
61
+ - ✅ You spawn sub-agents with fresh context for each task
62
+ - ✅ You parse handoff messages to determine next actions
63
+ - ✅ You handle failures gracefully with retry or escalation
64
+ - ✅ You output brief progress after each story completion
65
+
66
+ ### Step-Specific Rules:
67
+
68
+ - 🎯 Execute stories in linear order from pending list
69
+ - 🚫 FORBIDDEN to skip phases within a story
70
+ - 💬 Output brief status after each story completes
71
+ - 🚪 ESCALATE to user only when required (blockers, complex failures)
72
+
73
+ ## EXECUTION PROTOCOLS:
74
+
75
+ - 🎯 Update sidecar before each phase starts
76
+ - 💾 Parse agent handoff messages for status
77
+ - 📖 Verify sprint-status matches sidecar state
78
+ - 🚫 NEVER proceed if code review rejected without retry/escalate
79
+
80
+ ## CONTEXT BOUNDARIES:
81
+
82
+ - Sidecar file tracks current story and phase
83
+ - Each agent gets fresh context with specific instructions
84
+ - Sprint-status.yaml is source of truth for story states
85
+ - Handoff messages provide phase completion status
86
+
87
+ ---
88
+
89
+ ## STORY EXECUTION LOOP
90
+
91
+ For each story in `stories_pending`:
92
+
93
+ ### PHASE A: Create Story
94
+
95
+ **Update sidecar:**
96
+ ```yaml
97
+ current_story: "N.M"
98
+ current_phase: "create"
99
+ last_updated: "[timestamp]"
100
+ ```
101
+
102
+ **Spawn agent:**
103
+ ```
104
+ Task tool:
105
+ subagent_type: "general-purpose"
106
+ description: "Create story N.M"
107
+ prompt: |
108
+ You are the story-prep-master agent.
109
+ Load and embody: {storyPrepAgent}
110
+
111
+ Task: Create story N.M from the epic file.
112
+ Epic file: [epic_path]
113
+ Story location: {implementation_artifacts}/stories/
114
+ Sprint status: {sprintStatus}
115
+
116
+ Create a complete, developer-ready story file following BMAD story template.
117
+
118
+ When complete, output handoff in this format:
119
+ === AGENT HANDOFF ===
120
+ agent: story-prep-master
121
+ story: N.M
122
+ status: completed | failed
123
+ story_file: [path to created story]
124
+ blockers: none | [list]
125
+ next_action: proceed | escalate
126
+ === END HANDOFF ===
127
+ ```
128
+
129
+ **Parse handoff:**
130
+ - If status=completed → update sprint-status to `ready-for-dev`, proceed to Phase B
131
+ - If status=failed → handle failure (retry or escalate)
132
+
133
+ ---
134
+
135
+ ### PHASE B: Develop Story
136
+
137
+ **Update sidecar:**
138
+ ```yaml
139
+ current_phase: "dev"
140
+ last_updated: "[timestamp]"
141
+ ```
142
+
143
+ **Select specialist agent:**
144
+ 1. Read story file content (title, tasks, dev notes)
145
+ 2. Scan `{specialistAgentsFolder}` for agents
146
+ 3. For each agent, read `specialty` field and `Specialty Context`
147
+ 4. Match story content against agent specializations
148
+ 5. If match found → use specialist
149
+ 6. If no match → use fallback `{fallbackDevAgent}`
150
+
151
+ **Spawn agent:**
152
+ ```
153
+ Task tool:
154
+ subagent_type: "general-purpose"
155
+ description: "Develop story N.M"
156
+ prompt: |
157
+ You are a specialized developer agent.
158
+ Load and embody: [selected agent path]
159
+
160
+ Task: Implement story N.M completely.
161
+ Story file: [story_path]
162
+ Sprint status: {sprintStatus}
163
+ Project context: [project_context_path if exists]
164
+
165
+ Follow the story's tasks/subtasks exactly.
166
+ Write tests first (red-green-refactor).
167
+ Mark tasks complete as you finish them.
168
+
169
+ Available MCP Tools (use if available):
170
+ - Serena MCP: Code intelligence for navigation, refactoring
171
+ - Context7 MCP: Documentation lookup
172
+
173
+ When complete, output handoff in this format:
174
+ === AGENT HANDOFF ===
175
+ agent: [agent_name]
176
+ story: N.M
177
+ status: completed | failed | blocked
178
+ files_changed:
179
+ - [list of files]
180
+ tests_passed: true | false
181
+ tests_run: [count]
182
+ tests_failed: [count]
183
+ coverage: [percentage]
184
+ has_ui_changes: true | false
185
+ ui_routes_affected: [list of routes or "none"]
186
+ blockers: none | [list]
187
+ next_action: proceed | escalate | retry
188
+ error_summary: null | [description]
189
+ === END HANDOFF ===
190
+ ```
191
+
192
+ **Parse handoff:**
193
+ - If status=completed, tests_passed=true → proceed to Phase B.5 (if has_ui_changes) or Phase C
194
+ - If status=failed, blockers contains critical → escalate to user
195
+ - If tests_passed=false → retry (up to maxRetries)
196
+
197
+ ---
198
+
199
+ ### PHASE B.5: Visual Inspection (Conditional)
200
+
201
+ **Skip this phase if:**
202
+ - `has_ui_changes` is false AND no UI-related files in `files_changed`
203
+ - Chrome extension MCP tools are not available
204
+
205
+ **Update sidecar:**
206
+ ```yaml
207
+ current_phase: "visual"
208
+ last_updated: "[timestamp]"
209
+ ```
210
+
211
+ **Execute visual inspection using Chrome extension MCP:**
212
+
213
+ 1. Ensure dev server is running (`npm run dev` or equivalent)
214
+ 2. For each route in `ui_routes_affected`:
215
+
216
+ ```
217
+ mcp__claude-in-chrome__navigate({ url: "http://localhost:3000{route}", tabId: [tab] })
218
+ mcp__claude-in-chrome__computer({ action: "wait", duration: 2, tabId: [tab] })
219
+ mcp__claude-in-chrome__computer({ action: "screenshot", tabId: [tab] })
220
+ mcp__claude-in-chrome__read_console_messages({ tabId: [tab], onlyErrors: true })
221
+ ```
222
+
223
+ 3. Check for:
224
+ - Visual rendering issues (obvious layout breaks)
225
+ - Console errors related to the changes
226
+ - Basic functionality working
227
+
228
+ **If issues found:**
229
+ - Log issues but don't block (visual issues are noted in code review)
230
+ - Add to handoff: `visual_issues: [list]`
231
+
232
+ **Proceed to Phase C** (Code Review)
233
+
234
+ ---
235
+
236
+ ### PHASE C: Code Review
237
+
238
+ **Update sidecar:**
239
+ ```yaml
240
+ current_phase: "review"
241
+ last_updated: "[timestamp]"
242
+ ```
243
+
244
+ **Spawn agent:**
245
+ ```
246
+ Task tool:
247
+ subagent_type: "general-purpose"
248
+ description: "Review story N.M"
249
+ prompt: |
250
+ You are the principal-code-reviewer agent.
251
+ Load and embody: {codeReviewAgent}
252
+
253
+ Task: Perform thorough code review for story N.M.
254
+ Story file: [story_path]
255
+ Files changed: [from dev handoff]
256
+
257
+ Review for:
258
+ - Code quality and patterns
259
+ - Test coverage and quality
260
+ - Security considerations
261
+ - Performance implications
262
+ - Adherence to project standards
263
+
264
+ When complete, output handoff in this format:
265
+ === CODE REVIEW HANDOFF ===
266
+ agent: principal-code-reviewer
267
+ story: N.M
268
+ review_status: approved | changes_requested | rejected
269
+ findings:
270
+ critical: [count]
271
+ major: [count]
272
+ minor: [count]
273
+ suggestions: [count]
274
+ summary: [brief summary]
275
+ next_action: proceed | fix_required | escalate
276
+ === END HANDOFF ===
277
+ ```
278
+
279
+ **Parse handoff:**
280
+ - If review_status=approved → proceed to Phase D
281
+ - If review_status=changes_requested → go back to Phase B (with review feedback)
282
+ - If review_status=rejected → escalate to user
283
+
284
+ ---
285
+
286
+ ### PHASE D: Git Commit
287
+
288
+ **Update sidecar:**
289
+ ```yaml
290
+ current_phase: "commit"
291
+ last_updated: "[timestamp]"
292
+ ```
293
+
294
+ **Execute git commit:**
295
+ ```bash
296
+ git add .
297
+ git commit -m "feat(story-N.M): [story title]
298
+
299
+ Implemented via implement-epic-with-subagents workflow.
300
+ Agent: [dev_agent_name]
301
+ Coverage: [coverage]%
302
+ Tests: [passed]/[total]
303
+
304
+ Co-Authored-By: [agent_name] <noreply@anthropic.com>"
305
+ ```
306
+
307
+ **Verify commit success** - if fails, log error but continue.
308
+
309
+ ---
310
+
311
+ ### PHASE E: Finalize Story
312
+
313
+ **Update sidecar:**
314
+ ```yaml
315
+ current_story: null
316
+ current_phase: "between_stories"
317
+ stories_completed: [..., "N.M"]
318
+ stories_pending: [remaining stories]
319
+ last_updated: "[timestamp]"
320
+ execution_log:
321
+ - story: "N.M"
322
+ agent: "[dev_agent_used]"
323
+ coverage: [X]
324
+ tests: "[passed]/[total]"
325
+ duration: "[time]"
326
+ completed_at: "[timestamp]"
327
+ ```
328
+
329
+ **Update sprint-status.yaml:**
330
+ - Set story N.M status to `done`
331
+
332
+ **Output progress to user:**
333
+ ```
334
+ ✅ Story N.M: [story title]
335
+ Agent: [agent-name] | Coverage: X% | Tests: P/T | Duration: Xm
336
+ ```
337
+
338
+ **Continue to next story** - loop back to Phase A for next pending story.
339
+
340
+ ---
341
+
342
+ ## FAILURE HANDLING
343
+
344
+ ### On Failure (After Retries Exhausted):
345
+
346
+ 1. Determine failure type from handoff
347
+ 2. Display failure context to user:
348
+
349
+ ```
350
+ ⚠️ Story N.M Failed
351
+
352
+ Phase: [phase where failure occurred]
353
+ Error: [error summary]
354
+ Attempts: [retry count]
355
+
356
+ Context:
357
+ [relevant details from handoff]
358
+
359
+ Options:
360
+ [S] Skip this story and continue
361
+ [X] Stop epic execution
362
+ ```
363
+
364
+ 3. Wait for user decision
365
+ 4. If Skip:
366
+ - Add story to `stories_skipped` in sidecar
367
+ - Update sprint-status to `skipped`
368
+ - Continue to next story
369
+ 5. If Stop:
370
+ - Update sidecar with current state
371
+ - Route to step-03-complete (partial completion)
372
+
373
+ ### On Blocker (Human Decision Required):
374
+
375
+ 1. Display blocker context:
376
+
377
+ ```
378
+ 🛑 Human Decision Required
379
+
380
+ Story: N.M
381
+ Blocker: [blocker description]
382
+
383
+ This requires your input:
384
+ [specific question or decision needed]
385
+ ```
386
+
387
+ 2. Wait for user response
388
+ 3. Apply user's decision
389
+ 4. Continue execution
390
+
391
+ ---
392
+
393
+ ## LOOP COMPLETION
394
+
395
+ When `stories_pending` is empty:
396
+
397
+ 1. Update sidecar:
398
+ ```yaml
399
+ current_phase: "complete"
400
+ completed_at: "[timestamp]"
401
+ ```
402
+
403
+ 2. Output summary:
404
+ ```
405
+ 🎉 Epic Execution Complete!
406
+
407
+ Stories: [completed]/[total]
408
+ Skipped: [count]
409
+ Failed: [count]
410
+
411
+ Proceeding to generate completion report...
412
+ ```
413
+
414
+ 3. Load, read entire file, then execute `{nextStepFile}`
415
+
416
+ ---
417
+
418
+ ## 🚨 SYSTEM SUCCESS/FAILURE METRICS
419
+
420
+ ### ✅ SUCCESS:
421
+
422
+ - All stories processed (completed, skipped, or failed with user decision)
423
+ - Sidecar updated after every phase
424
+ - Sprint-status reflects actual story states
425
+ - Git commits created for completed stories
426
+ - Progress reported after each story
427
+ - Graceful handling of failures
428
+
429
+ ### ❌ SYSTEM FAILURE:
430
+
431
+ - Skipping phases within a story
432
+ - Not updating sidecar state
433
+ - Proceeding after code review rejection without retry/escalate
434
+ - Not parsing handoff messages
435
+ - Silent failures without user notification
436
+
437
+ **Master Rule:** Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.