BMAD Epic Deliver (Worktree Edition)
Deliver all incomplete user stories in Epic {ARGUMENT}, each story developed in isolated worktree and merged only after tests pass.
Pre-step: Determine Epic Number
If no epic number is provided ({ARGUMENT} is empty):
- •Read
_bmad-output/implementation-artifacts/sprint-status.yaml - •Find all stories with status not
done(format:X-Y-story-name) - •Extract Epic numbers X from these stories
- •Select the smallest Epic number as
{ARGUMENT} - •Output:
code
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📌 Auto-selected Epic: {ARGUMENT} (has incomplete stories)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Example:
- •Status file has
3-2-llm-prompt-template: backlog,3-3-xxx: in-progress,4-1-xxx: done - •Incomplete Epics: 3
- •Auto-select Epic: 3
Execution Strategy
- •Read all incomplete stories under the Epic
- •Sort by Story number ascending
- •Execute
/bmad-story-worktreefor each story sequentially - •Only start next story after previous one completes
- •If any story fails, stop and preserve current state
Execution Flow
Step 1: Collect Epic Story List
Read sprint-status.yaml, collect all incomplete stories under specified Epic:
code
Task(
subagent_type: general-purpose,
description: "Collect Epic {ARGUMENT} story list",
prompt: "Read _bmad-output/implementation-artifacts/sprint-status.yaml, collect all stories for Epic {ARGUMENT}:
1. Filter entries with key format '{ARGUMENT}-Y-story-name'
2. Keep only stories with status not 'done'
3. Sort by Story number Y ascending
4. Return story list with format:
- Story number: '1.1', '1.2', ...
- Story name
- Current status
If no incomplete stories, return empty list and note 'Epic {ARGUMENT} all stories completed'"
)
Progress output:
code
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 [1/?] Collect Story List
📁 Epic: {ARGUMENT}
📝 Incomplete stories: [count]
🔢 Order: {story-1}, {story-2}, ...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Step 2~N: Deliver Stories Sequentially
For each incomplete story, execute in order:
code
For story {STORY_NUM} (i-th of N total):
Execute /bmad-story-worktree {STORY_NUM}
Wait for completion before continuing to next story
Each story delivery progress:
code
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔄 Story [{i}/{N}]: {STORY_NUM}
📝 Name: {story-name}
⏳ Executing...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[... Execute bmad-story-worktree 8 steps ...]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Story [{i}/{N}]: {STORY_NUM} Complete
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
If any story fails:
code
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
❌ Story [{i}/{N}]: {STORY_NUM} Failed
⚠️ Stopping subsequent story delivery
📁 Please handle manually before continuing
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Final Delivery Report
All complete:
code
╔════════════════════════════════════════════════════════╗
║ 🎉 BMAD Epic Delivery Complete! ║
╠════════════════════════════════════════════════════════╣
║ Epic: {ARGUMENT} ║
║ ║
║ ✅ Story 1: {story-1} - done ║
║ ✅ Story 2: {story-2} - done ║
║ ... ║
║ ✅ Story N: {story-N} - done ║
║ ║
║ 📊 Total: {N}/{N} stories completed ║
║ 🎯 Epic status: done ║
╚════════════════════════════════════════════════════════╝
Partial completion (has failures):
code
╔════════════════════════════════════════════════════════╗
║ ⚠️ BMAD Epic Delivery - Partial Completion ║
╠════════════════════════════════════════════════════════╣
║ Epic: {ARGUMENT} ║
║ ║
║ ✅ Story 1: {story-1} - done ║
║ ✅ Story 2: {story-2} - done ║
║ ❌ Story 3: {story-3} - failed ║
║ ⏸️ Story 4: {story-4} - not started ║
║ ... ║
║ ║
║ 📊 Progress: {completed}/{total} stories completed ║
║ 📁 Failed story: {failed-story} ║
║ 💡 Handle failed story then re-run to continue ║
╚════════════════════════════════════════════════════════╝
Error Handling
If any story delivery fails:
- •Stop subsequent story delivery
- •Preserve failed story's worktree (if any)
- •Output failure information and completed progress
- •Prompt user to handle manually
Resume delivery:
bash
# 1. Manually fix failed story
cd {WORKTREE_PATH}
# Fix issues...
git add . && git commit -m "fix: resolve issues"
cd {ORIGINAL_REPO_PATH}
git merge feature/story-{STORY_NUM}
git worktree remove {WORKTREE_PATH}
# 2. Re-run epic delivery, will auto-skip completed stories
/bmad-epic-worktree {ARGUMENT}
Relationship with bmad-story-worktree
- •bmad-epic-worktree is the batch version of bmad-story-worktree
- •Internally loops to call
/bmad-story-worktree {story-num} - •Each story has independent worktree, independent tests, independent merge
- •Guarantees sequential execution, next starts only after previous completes
- •Each story completion auto-updates: sprint-status.yaml + story design document