@torka/claude-workflows 0.2.0 → 0.3.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.
@@ -0,0 +1,434 @@
1
+ ---
2
+ name: 'step-01c-new'
3
+ description: 'Set up new epic execution with optional worktree isolation'
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-01c-new.md'
10
+ orchestrateFile: '{workflow_path}/steps/step-02-orchestrate.md'
11
+ workflowFile: '{workflow_path}/workflow.md'
12
+
13
+ # State files
14
+ sidecarFolder: '{output_folder}/epic-executions'
15
+ sprintStatus: '{implementation_artifacts}/sprint-status.yaml'
16
+
17
+ # Agent references
18
+ storyPrepAgent: '.claude/agents/story-prep-master.md'
19
+ codeReviewAgent: '.claude/agents/principal-code-reviewer.md'
20
+ specialistAgentsFolder: '.claude/agents/vt-bmad-dev-agents/'
21
+ fallbackDevAgent: '_bmad/bmm/agents/dev.md'
22
+ agentCreatorSkill: '.claude/skills/agent-creator/SKILL.md'
23
+
24
+ # Configuration
25
+ baseBranch: 'main'
26
+ ---
27
+
28
+ # Step 1C: New Epic Setup
29
+
30
+ ## STEP GOAL:
31
+
32
+ To set up a fresh epic execution, optionally in an isolated worktree, including mode selection, worktree creation, dependency installation, epic parsing, prerequisite validation, specialist agent creation, and sidecar initialization.
33
+
34
+ ## MANDATORY EXECUTION RULES (READ FIRST):
35
+
36
+ ### Universal Rules:
37
+
38
+ - 🛑 NEVER skip setup steps
39
+ - 📖 CRITICAL: Read the complete step file before taking any action
40
+ - 📋 YOU ARE SETTING UP a new epic execution
41
+
42
+ ### Role Reinforcement:
43
+
44
+ - ✅ You are an Epic Execution Orchestrator
45
+ - ✅ This step handles ALL new epic setup
46
+ - ✅ Guide user through mode selection and epic choice
47
+ - ✅ Ensure all prerequisites are validated before proceeding
48
+
49
+ ### Step-Specific Rules:
50
+
51
+ - 🎯 Focus ONLY on new epic setup
52
+ - 🚫 FORBIDDEN to resume existing work (that's step-01b)
53
+ - 💬 Present clear options for execution mode
54
+ - 🚪 VALIDATE all prerequisites before creating sidecar
55
+
56
+ ## EXECUTION PROTOCOLS:
57
+
58
+ - 🎯 Complete all setup steps in sequence
59
+ - 💾 Create sidecar only after all validation passes
60
+ - 📖 Handle worktree creation and dependency installation
61
+ - 🚫 FORBIDDEN to proceed to orchestration without complete setup
62
+
63
+ ## SETUP SEQUENCE:
64
+
65
+ ### 1. Git Sync Check
66
+
67
+ Before any setup, verify git working directory status:
68
+
69
+ **Execute checks:**
70
+ ```bash
71
+ git status --porcelain # Check for uncommitted changes
72
+ git fetch origin {baseBranch} # Fetch latest from remote
73
+ git rev-list HEAD...origin/{baseBranch} --count # Check commits behind/ahead
74
+ ```
75
+
76
+ **Display results:**
77
+ - ✅ Clean working directory, synced with remote → proceed automatically
78
+ - ⚠️ Uncommitted changes found → list files, ask: "[C] Continue anyway | [S] Stop to commit first"
79
+ - ⚠️ Behind remote by N commits → warn, ask: "[P] Pull first | [C] Continue anyway"
80
+ - ⚠️ Ahead of remote → info only, proceed
81
+
82
+ **If user chooses to stop:** EXIT workflow, preserve no state.
83
+
84
+ ### 2. Execution Mode Selection
85
+
86
+ Check `worktree_mode` setting from workflow.yaml:
87
+ - If `"always"` → skip prompt, set mode = worktree
88
+ - If `"never"` → skip prompt, set mode = main
89
+ - If `"ask"` (default) → show prompt below
90
+
91
+ **Prompt (if asking):**
92
+ ```
93
+ How would you like to run this epic execution?
94
+
95
+ [W] Separate worktree (Recommended)
96
+ • Isolates epic work from main repo
97
+ • Enables parallel development on other tasks
98
+ • Requires session restart in worktree location
99
+ • Creates: ../{project_name}-epic-{N}/
100
+
101
+ [M] Main repository
102
+ • Traditional single-repo approach
103
+ • Blocks main repo during execution
104
+ • No session restart required
105
+ ```
106
+
107
+ **Store selection for later:** `execution_mode: "worktree" | "main"`
108
+
109
+ ### 3. Load Sprint Status
110
+
111
+ Read sprint-status.yaml at `{sprintStatus}`:
112
+
113
+ 1. Parse all epic entries
114
+ 2. Identify epics with status `backlog` or `in-progress`
115
+ 3. For each epic, count stories in backlog/ready-for-dev
116
+
117
+ **Display:**
118
+ ```
119
+ Sprint Status Summary:
120
+ Epic 2: Complete Authentication (8 stories) - backlog
121
+ Epic 3: User Onboarding (7 stories) - backlog
122
+ ...
123
+ ```
124
+
125
+ ### 4. Select Epic to Execute
126
+
127
+ **If user provided specific epic in initial message:**
128
+ - Use that epic, confirm selection
129
+
130
+ **If multiple epics available:**
131
+ - Display list with story counts
132
+ - Ask: "Which epic would you like to execute?"
133
+ - Options: [1] Epic 2 | [2] Epic 3 | ... | [A] All (sequential)
134
+
135
+ **Locate epic file:**
136
+ - Search `{implementation_artifacts}` for epic-N-*.md matching selection
137
+ - Parse and validate epic file
138
+
139
+ ### 5. Worktree Creation (if mode = worktree)
140
+
141
+ **Skip this section if execution_mode = "main"**
142
+
143
+ **5.1 Generate paths:**
144
+ - Sanitize epic name: lowercase, replace spaces with hyphens, remove special chars
145
+ - Branch name: `feature/epic-{epic_number}-{sanitized_epic_name}`
146
+ - Worktree directory: `../{project_name}-epic-{epic_number}-{sanitized_epic_name}`
147
+
148
+ **5.2 Create worktree:**
149
+ ```bash
150
+ git worktree add -b {branch_name} {worktree_directory}
151
+ ```
152
+
153
+ **If creation fails:**
154
+ - Branch exists: "[U] Use existing branch | [D] Delete and recreate | [A] Abort"
155
+ - Directory exists: "[R] Remove and recreate | [A] Abort"
156
+ - Display error, ask user to resolve, retry
157
+
158
+ **5.3 Install dependencies:**
159
+ ```bash
160
+ cd {worktree_directory}
161
+ # Auto-detect package manager or use configured dependency_command
162
+ npm install # or yarn, pnpm, bun
163
+ cd -
164
+ ```
165
+
166
+ **5.4 Store worktree config (for sidecar later):**
167
+ ```yaml
168
+ worktree_config:
169
+ enabled: true
170
+ worktree_path: "{absolute_worktree_path}"
171
+ worktree_relative: "{relative_worktree_path}"
172
+ main_repo_path: "{current_repo_path}"
173
+ branch_name: "{branch_name}"
174
+ dependencies_installed: true
175
+ created_at: "{timestamp}"
176
+ ```
177
+
178
+ ### 6. Create Feature Branch (if mode = main)
179
+
180
+ **Skip this section if execution_mode = "worktree"**
181
+
182
+ Create dedicated branch for this epic's work:
183
+
184
+ 1. Generate branch name: `feature/epic-{epic_number}-{sanitized_epic_name}`
185
+ 2. Execute: `git checkout -b {branch_name}`
186
+
187
+ **If branch creation fails:** Display error, ask user to resolve, retry.
188
+
189
+ ### 7. Load and Parse Epic
190
+
191
+ Once epic path is confirmed:
192
+
193
+ 1. Read the complete epic file
194
+ 2. Parse all stories using pattern: `### Story N.M:`
195
+ 3. Extract for each story:
196
+ - Story number (N.M)
197
+ - Story title
198
+ - Acceptance criteria summary
199
+ 4. Build story execution list
200
+
201
+ **Display parsed stories:**
202
+ ```
203
+ Found X stories in epic:
204
+ - Story N.1: [title]
205
+ - Story N.2: [title]
206
+ ...
207
+ ```
208
+
209
+ ### 8. Validate Prerequisites
210
+
211
+ Check all required components exist:
212
+
213
+ **Agents:**
214
+ - [ ] story-prep-master agent at `{storyPrepAgent}`
215
+ - [ ] principal-code-reviewer agent at `{codeReviewAgent}`
216
+ - [ ] Fallback dev agent at `{fallbackDevAgent}`
217
+
218
+ **Specialist Agents (Optional):**
219
+ - [ ] Check `{specialistAgentsFolder}` for available specialists
220
+ - List found specialists with their specialties
221
+
222
+ **MCP Tools:**
223
+ - [ ] Context-7 MCP available (check via tool availability)
224
+
225
+ **Files:**
226
+ - [ ] Sprint-status.yaml exists at `{sprintStatus}`
227
+ - [ ] Project-context.md exists (optional, search `**/project-context.md`)
228
+
229
+ **Display validation results:**
230
+ ```
231
+ Prerequisites Check:
232
+ ✅ story-prep-master agent
233
+ ✅ principal-code-reviewer agent
234
+ ✅ Fallback dev agent
235
+ ✅ Specialist agents folder (X specialists found)
236
+ ✅ Context-7 MCP
237
+ ✅ Sprint-status.yaml
238
+ ⚪ Project-context.md (optional, not found)
239
+ ```
240
+
241
+ If any required prerequisite fails → display error and stop.
242
+
243
+ ### 9. Create Specialist Agents
244
+
245
+ Analyze epic and create specialized dev agents for the stories:
246
+
247
+ **9.1 Analyze Epic Stories:**
248
+ - Read each story title and description from epic file
249
+ - Identify technical domains: frontend, backend, API, database, auth, etc.
250
+ - Group stories by primary domain
251
+
252
+ **9.2 Invoke Agent Creator:**
253
+ Load and follow `{agentCreatorSkill}` steps 1-4:
254
+ - Skip Step 0 (registry check) - always create fresh for this epic
255
+ - Step 1: Context already gathered from epic analysis
256
+ - Step 2: Design agents based on story domains
257
+ - Step 3: Skip community research (use built-in patterns)
258
+ - Step 4: Create agent files
259
+
260
+ **Note:** If execution_mode = "worktree", create agents in the WORKTREE directory.
261
+
262
+ **9.3 Register Created Agents:**
263
+ Store for sidecar:
264
+ ```yaml
265
+ specialist_agents_created:
266
+ - name: "auth-specialist"
267
+ path: ".claude/agents/vt-bmad-dev-agents/auth-specialist.md"
268
+ stories: ["2.1", "2.3", "2.6"]
269
+ - name: "frontend-forms"
270
+ path: ".claude/agents/vt-bmad-dev-agents/frontend-forms.md"
271
+ stories: ["2.2", "2.4", "2.5"]
272
+ ```
273
+
274
+ **9.4 Display Summary:**
275
+ ```
276
+ Created X specialist agents for this epic:
277
+ - auth-specialist (3 stories)
278
+ - frontend-forms (3 stories)
279
+ - general-dev (2 stories - fallback)
280
+ ```
281
+
282
+ ### 10. Create Sidecar State File
283
+
284
+ Ensure sidecar folder exists:
285
+ ```bash
286
+ mkdir -p {sidecarFolder}
287
+ ```
288
+
289
+ Initialize the execution state file at `{sidecarFolder}/epic-{epic_number}-state.yaml`:
290
+
291
+ ```yaml
292
+ epic_execution_state:
293
+ epic_file: "{epic_path}"
294
+ epic_name: "{parsed_epic_name}"
295
+ epic_number: {N}
296
+ total_stories: {X}
297
+ current_story: null
298
+ current_phase: "initialized" # or "awaiting_session_restart" if worktree
299
+ stories_completed: []
300
+ stories_pending: ["N.1", "N.2", ...]
301
+ stories_skipped: []
302
+ stories_failed: []
303
+ execution_log: []
304
+ started_at: "{timestamp}"
305
+ last_updated: "{timestamp}"
306
+
307
+ execution_mode:
308
+ type: "worktree" | "main"
309
+ selected_at: "{timestamp}"
310
+
311
+ worktree_config:
312
+ enabled: true | false
313
+ worktree_path: "{path}" # if worktree
314
+ worktree_relative: "{relative_path}" # if worktree
315
+ main_repo_path: "{main_repo}" # if worktree
316
+ branch_name: "{branch}"
317
+ dependencies_installed: true | false
318
+ created_at: "{timestamp}"
319
+
320
+ git_workflow:
321
+ branch_name: "{branch_name}"
322
+ base_branch: "main"
323
+ created_at: "{timestamp}"
324
+
325
+ specialist_agents_created:
326
+ - name: "{agent_name}"
327
+ path: "{agent_path}"
328
+ stories: ["N.1", "N.2"]
329
+
330
+ specialist_agents_available:
331
+ - name: "{agent_name}"
332
+ specialty: "{specialty}"
333
+
334
+ configuration:
335
+ coverage_threshold: 80
336
+ max_retries: 3
337
+ auto_commit: true
338
+
339
+ cleanup:
340
+ marked_for_removal: false
341
+ agents_cleaned: false
342
+ ```
343
+
344
+ ### 11. Route Based on Execution Mode
345
+
346
+ #### If Worktree Mode:
347
+
348
+ Update sidecar: `current_phase: "awaiting_session_restart"`
349
+
350
+ Display:
351
+ ```
352
+ ═══════════════════════════════════════════════════════════════
353
+ WORKTREE READY
354
+ ═══════════════════════════════════════════════════════════════
355
+
356
+ Epic worktree created and configured!
357
+
358
+ 📁 Worktree Location:
359
+ {worktree_path}
360
+
361
+ 🔧 Dependencies installed: ✅
362
+ 🤖 Specialist agents created: {count} agents
363
+
364
+ ═══════════════════════════════════════════════════════════════
365
+
366
+ NEXT STEPS:
367
+
368
+ 1. Open a NEW terminal/Claude Code session
369
+ 2. Navigate to: cd {worktree_path}
370
+ 3. Run: claude (or your Claude Code command)
371
+ 4. Execute: /implement-epic-with-subagents
372
+
373
+ The workflow will automatically resume from where we left off.
374
+
375
+ ═══════════════════════════════════════════════════════════════
376
+ ```
377
+
378
+ **STOP EXECUTION** - Workflow pauses here. Do not proceed to step-02.
379
+
380
+ #### If Main Repo Mode:
381
+
382
+ Update sidecar: `current_phase: "executing"`
383
+
384
+ Display execution plan summary:
385
+ ```
386
+ **Epic Execution Plan**
387
+
388
+ **Epic:** {epic_name}
389
+ **Stories:** {X} total
390
+ **Agents:** 3 orchestrated agents per story
391
+ **Estimated Flow:**
392
+
393
+ For each story:
394
+ 1. Create story file (story-prep-master)
395
+ 2. Implement with TDD (specialist or dev agent)
396
+ 3. Visual inspection (UI stories only)
397
+ 4. Code review (principal-code-reviewer)
398
+ 5. Git commit (pre-commit hooks run tests)
399
+ 6. Update status
400
+
401
+ **Ready to begin autonomous execution?**
402
+
403
+ [C] Start Epic Execution
404
+ ```
405
+
406
+ **If user confirms [C]:**
407
+ → Load, read entire file, then execute `{orchestrateFile}`
408
+
409
+ ---
410
+
411
+ ## 🚨 SYSTEM SUCCESS/FAILURE METRICS
412
+
413
+ ### ✅ SUCCESS:
414
+
415
+ - Execution mode selected appropriately
416
+ - Worktree created and dependencies installed (if worktree mode)
417
+ - Epic file loaded and parsed successfully
418
+ - All required prerequisites validated
419
+ - Specialist agents created
420
+ - Sidecar state file created with all required fields
421
+ - Correct routing: pause for worktree OR proceed to orchestration
422
+
423
+ ### ❌ SYSTEM FAILURE:
424
+
425
+ - Skipping mode selection
426
+ - Not creating worktree when mode = worktree
427
+ - Not installing dependencies in worktree
428
+ - Proceeding without epic file validation
429
+ - Not checking for existing sidecar state
430
+ - Skipping prerequisite validation
431
+ - Starting execution without user confirmation
432
+ - Not creating sidecar state file
433
+
434
+ **Master Rule:** Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.