feat: add autonomous-epic workflow for full epic automation

- New /autonomous-epic command processes entire epic
- Just-in-time planning: creates each story before developing
- Auto-develops using super-dev-story or dev-story
- Progress tracking with resume capability
- Git commits after each story completion
- Error handling with retry logic and continue-on-failure
- Epic completion report with statistics
- Estimated: 100K-150K tokens per story

Use cases:
- Overnight epic completion
- CI/CD integration
- Batch sprint processing

Applies to both BMM and BMGD modules
This commit is contained in:
Jonah Schulte 2025-12-26 14:36:38 -05:00
parent cff53fb3d8
commit 9e7b097bb0
7 changed files with 2232 additions and 5 deletions

View File

@ -154,16 +154,37 @@ Ready to merge!
## Implementation Status
- 🚧 **Planned** for BMAD v6.1.0
- Requires: Super-dev mode (v6.0.0-alpha.23)
- Depends on: Robust error handling, progress tracking
- ✅ **IMPLEMENTED** in BMAD v6.0.0-alpha.22+
- Available as: `/autonomous-epic` workflow
- Requires: Gap analysis and super-dev-story workflows
- Status: Ready for testing and feedback
## Usage
```bash
# Load any BMAD agent (PM, Dev, SM)
/autonomous-epic
# Or specify epic number directly:
/autonomous-epic 2
```
See [autonomous-epic workflow README](../src/modules/bmm/workflows/4-implementation/autonomous-epic/README.md) for complete documentation.
## Real-World Usage
**This is production-ready but experimental.** We recommend:
1. Test with small epics first (3-5 stories)
2. Monitor token usage and quality
3. Review completion reports thoroughly
4. Provide feedback to improve the feature
## Contributing
Want to help build autonomous epic processing?
Found issues or have improvements?
See [CONTRIBUTING.md](../CONTRIBUTING.md)
---
**The future: Tell BMAD what you want built, come back when it's done** ✨
**The future is NOW: Tell BMAD "Do Epic 4" and come back when it's done** ✨

View File

@ -0,0 +1,651 @@
# Autonomous Epic Processing
**"Do Epic 4 for me" - Full automation of epic completion**
## What It Does
Autonomous epic processing combines just-in-time planning with automated development:
```
/autonomous-epic 2
→ Creates Story 2.1 → Develops with super-dev-story → Commits → Done ✅
→ Creates Story 2.2 → Develops with super-dev-story → Commits → Done ✅
→ Creates Story 2.3 → Develops with super-dev-story → Commits → Done ✅
...
→ Entire Epic 2 complete! 🎉
```
## How It Works
```
┌──────────────────────────────────────────────────┐
│ Autonomous Epic Processor │
│ │
│ For each story in epic (sequential): │
│ ┌─────────────────────────────────────────────┐ │
│ │ 1. create-story (just-in-time planning) │ │
│ │ ↓ │ │
│ │ 2. super-dev-story (or dev-story) │ │
│ │ ├─ Pre-dev gap analysis │ │
│ │ ├─ Development (TDD) │ │
│ │ ├─ Post-dev gap analysis (super-dev only) │ │
│ │ ├─ Code review (super-dev only) │ │
│ │ └─ Fix issues │ │
│ │ ↓ │ │
│ │ 3. Git commit │ │
│ │ ↓ │ │
│ │ 4. Save progress │ │
│ └─────────────────────────────────────────────┘ │
│ │
│ Epic completion report generated │
└──────────────────────────────────────────────────┘
```
## Usage
### Basic Usage
```bash
# Load any BMAD agent
/autonomous-epic
# Will prompt for epic number:
Enter epic number: 2
# Or provide directly:
/autonomous-epic epic-2
```
### With Defaults
```bash
/autonomous-epic 3
# Uses default settings:
# ✅ super-dev-story (comprehensive quality)
# ✅ Auto-accept gap analysis
# ✅ Create git commits
# ✅ Continue on errors
```
### With Custom Settings
```bash
/autonomous-epic 3
# When prompted:
[C] Custom settings
# Then configure:
# - dev-story or super-dev-story?
# - Auto-accept gap analysis?
# - Create git commits?
# - Halt on error or continue?
```
## Configuration
### Default Settings (workflow.yaml)
```yaml
autonomous_settings:
use_super_dev: true # Use super-dev-story (vs dev-story)
auto_accept_gap_analysis: true # Auto-approve gap analysis
halt_on_error: false # Continue even if story fails
max_retry_per_story: 2 # Retry failed stories
create_git_commits: true # Commit after each story
git_branch_prefix: "auto-epic-" # Branch: auto-epic-{epic_num}
```
### Per-Epic Override
```yaml
# In sprint-status.yaml or epic frontmatter
epic-3:
autonomous_settings:
use_super_dev: false # Use dev-story (faster)
halt_on_error: true # Stop on first failure
```
## Time & Cost Estimates
### Time per Story
| Workflow | Avg Time per Story | Token Usage |
|----------|-------------------|-------------|
| **dev-story** | 20-40 minutes | 50K-100K |
| **super-dev-story** | 25-50 minutes | 80K-150K |
### Epic Estimates
| Epic Size | Time (dev-story) | Time (super-dev) | Tokens |
|-----------|-----------------|------------------|--------|
| Small (3-5 stories) | 1-3 hours | 2-4 hours | 250K-750K |
| Medium (6-10 stories) | 2-7 hours | 3-8 hours | 500K-1.5M |
| Large (11-20 stories) | 4-13 hours | 5-17 hours | 1M-3M |
**Recommendation:** Run overnight for large epics
## Example Session
```
🤖 Autonomous Epic Processing
Enter epic number: 2
📊 Epic 2 Status
Total stories: 8
- Backlog: 5 (will create + develop)
- Ready-for-dev: 2 (will develop)
- In-progress: 1 (will resume)
- Review: 0
- Done: 0
Work Remaining: 8 stories
Estimated Time: 4-6 hours
Estimated Tokens: ~800K-1.2M
Proceed? [Y/C/n]: Y
✅ Starting autonomous epic processing...
📝 Created git branch: auto-epic-2
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Story 1/8: 2-1-user-registration
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Status: backlog
📝 Creating story 2-1-user-registration...
✅ Story created
💻 Developing story using super-dev-story...
Pre-gap: ✅ 0 changes needed
Development: ✅ 8 tasks completed
Post-gap: ✅ All verified
Code review: ✅ No issues
✅ Story complete (42 minutes, 95K tokens)
📝 Committed: a1b2c3d
Progress: 1 ✅ | 0 ❌ | 7 pending
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Story 2/8: 2-2-user-login
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📝 Creating story 2-2-user-login...
✅ Story created
💻 Developing story using super-dev-story...
Pre-gap: ✅ Reusing registration code (3 tasks refined)
Development: ✅ 6 tasks completed
Post-gap: ✅ All verified
Code review: ⚠️ 1 medium issue found
Code review: ✅ Issue fixed
✅ Story complete (38 minutes, 110K tokens)
📝 Committed: d4e5f6g
Progress: 2 ✅ | 0 ❌ | 6 pending
[... continues for all 8 stories ...]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎉 EPIC 2 AUTONOMOUS PROCESSING COMPLETE!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Results:
✅ Stories completed: 8/8
❌ Stories failed: 0
Statistics:
- Total time: 5h 23m
- Files created/modified: 47
- Test coverage: 94%
- Code review issues: 6 (all fixed)
Git Branch: auto-epic-2
Commits: 8
Next Steps:
1. Review completion report
2. Run human code review
3. Merge auto-epic-2
```
## Progress Tracking
### Progress File
Autonomous epic maintains state in `.autonomous-epic-progress.yaml`:
```yaml
epic_num: 2
started: 2025-01-18T10:00:00Z
total_stories: 8
completed_stories:
- 2-1-user-registration
- 2-2-user-login
failed_stories: []
current_story: 2-3-password-reset
status: running
```
### Resume from Interruption
If interrupted (crash, manual stop, timeout):
```bash
/autonomous-epic 2
# Detects existing progress file
# Shows: "Found in-progress epic processing. Resume? [Y/n]"
# Continues from last completed story
```
## Error Handling
### Story Failures
**With `halt_on_error: false` (default):**
```
Story 2.3 fails
→ Logged in failed_stories
→ Continue to Story 2.4
→ Report failures at end
```
**With `halt_on_error: true`:**
```
Story 2.3 fails
→ Stop processing immediately
→ Report error
→ User fixes manually
→ Resume from Story 2.3
```
### Retry Logic
Each story gets {{max_retry_per_story}} attempts (default: 2):
```
Story 2.5 fails
→ Retry 1/2: Attempt again
→ Retry 2/2: Attempt again
→ Max retries: Mark failed, continue to next story
```
## Git Integration
### Automatic Branching
```bash
# Autonomous epic creates:
Branch: auto-epic-{epic_num}
# Example:
/autonomous-epic 3
→ Creates branch: auto-epic-3
```
### Commits per Story
Each story gets its own commit:
```
feat(epic-2): complete story 2-1-user-registration
feat(epic-2): complete story 2-2-user-login
feat(epic-2): complete story 2-3-password-reset
...
```
### Merge When Done
```bash
# After autonomous epic completes:
git checkout main
git merge auto-epic-2
# Or create PR:
gh pr create --base main --head auto-epic-2 --title "Epic 2: User Management"
```
## Completion Report
Generated at: `{{story_dir}}/epic-{{epic_num}}-completion-report.md`
```markdown
# Epic 2 Completion Report
**Generated:** 2025-01-18
**Processing Time:** 5h 23m
**Success Rate:** 100% (8/8 stories)
## Story Summary
| Story | Status | Time | Files | Coverage | Issues |
|-------|--------|------|-------|----------|--------|
| 2.1 | ✅ Done | 42m | 6 | 95% | 0 |
| 2.2 | ✅ Done | 38m | 5 | 92% | 1 |
| 2.3 | ✅ Done | 45m | 7 | 96% | 2 |
...
## Epic Statistics
- Total files: 47 (35 created, 12 modified)
- Average coverage: 94%
- Code review issues: 6 (all resolved)
- Total commits: 8
## Quality Metrics
- Stories passing first time: 6/8 (75%)
- Average fix iterations: 0.25
- Zero critical issues escaped
## Git Branch
Branch: auto-epic-2
Ready to merge
## Recommendations
- All stories met acceptance criteria
- Test coverage exceeds 90% target
- Code review found minimal issues
- Ready for human review and merge
```
## Best Practices
### 1. Epic Sizing
**Recommended epic sizes:**
- **Small (3-5 stories):** Can complete in single session
- **Medium (6-10 stories):** Overnight processing ideal
- **Large (11+ stories):** Consider breaking into sub-epics
### 2. Choosing dev-story vs super-dev-story
**Use super-dev-story for:**
- Security-critical epics
- Customer-facing features
- Complex business logic
- High-stakes production releases
**Use dev-story for:**
- Internal tools
- Experimental features
- Non-critical improvements
- When speed matters more than extra validation
### 3. Monitoring Progress
```bash
# In another terminal, watch progress:
watch -n 10 'cat docs/sprint-artifacts/.autonomous-epic-progress.yaml'
# Or tail completion report:
tail -f docs/sprint-artifacts/epic-2-completion-report.md
```
### 4. Interruption Handling
**Safe to interrupt:**
- Ctrl+C between stories (progress saved)
- Terminal disconnect (can resume)
- Timeout (restarts from last completed)
**Not safe to interrupt:**
- During story development (may leave partial work)
- During git commit (may corrupt repository)
### 5. Resource Management
**Token budgets:**
- Set LLM API limits to prevent runaway costs
- Monitor token usage in real-time
- Consider using dev-story for token savings
**Time management:**
- Run overnight for large epics
- Schedule during low-activity periods
- Use CI/CD for completely automated runs
## Troubleshooting
### "Autonomous epic stuck on one story"
**Cause:** Story has issues preventing completion
**Solution:**
- Check progress file for current_story
- Review that story's dev log
- May need manual intervention
### "Epic processing stopped mid-story"
**Cause:** Interruption during development
**Solution:**
- Check progress file status
- Resume with `/autonomous-epic {epic_num}`
- May need to manually clean up partial work
### "Too many token failures"
**Cause:** Hitting API rate limits
**Solution:**
- Reduce concurrent processing
- Use dev-story instead of super-dev-story
- Increase API tier/limits
### "Git merge conflicts after autonomous epic"
**Cause:** Other changes merged to main during processing
**Solution:**
- Rebase auto-epic branch on latest main
- Resolve conflicts manually
- This is expected for long-running processes
## Safety Features
### Max Retry Protection
Prevents infinite loops:
- Each story: max 2 retries (default)
- After max retries: skip to next story
- Report failures at end
### Progress Checkpoints
After each story:
- Progress file updated
- Git commit created (if enabled)
- Can resume from this point
### Fail-Safe Modes
```yaml
# Conservative (halt on first problem):
halt_on_error: true
max_retry_per_story: 0
# Aggressive (push through everything):
halt_on_error: false
max_retry_per_story: 3
# Balanced (default):
halt_on_error: false
max_retry_per_story: 2
```
## Use Cases
### Use Case 1: Overnight Epic Completion
```bash
# Before leaving office:
/autonomous-epic 4
# Next morning:
# → Epic 100% complete
# → All stories developed
# → All commits created
# → Ready for review
```
### Use Case 2: CI/CD Integration
```bash
# In GitHub Actions:
name: Auto Epic Processing
on:
workflow_dispatch:
inputs:
epic_number:
required: true
jobs:
process-epic:
steps:
- run: npx bmad-method@alpha autonomous-epic ${{ inputs.epic_number }}
```
### Use Case 3: Sprint Automation
```bash
# Monday: Plan all epics for sprint
/sprint-planning
# Tuesday: Auto-process Epic 1
/autonomous-epic 1
# Wednesday: Auto-process Epic 2
/autonomous-epic 2
# Thursday-Friday: Human review and merge
```
## Comparison to Manual Processing
### Manual Workflow
```
Day 1: Create Story 2.1 → Review → Approve (30m)
Day 2: Develop Story 2.1 → Test → Review → Fix → Done (4h)
Day 3: Create Story 2.2 → Review → Approve (30m)
Day 4: Develop Story 2.2 → Test → Review → Fix → Done (3h)
...
8 stories = 16 days minimum (with human bottlenecks)
```
### Autonomous Workflow
```
Day 1 (evening): /autonomous-epic 2
Day 2 (morning): Epic complete, review ready
8 stories = 6 hours machine time + 1-2 days human review
```
**Savings:** ~14 days, 90% reduction in calendar time
## Limitations
### What Autonomous Epic CAN'T Do
- **Complex requirement clarifications** - Needs human for ambiguous requirements
- **Architectural decisions** - Major tech choices need human input
- **UX design decisions** - Visual/interaction design needs human creativity
- **Business logic validation** - Domain expertise often needs human verification
### When to Use Manual Processing
- First epic in new project (learning patterns)
- Experimental features (high uncertainty)
- Stories requiring extensive research
- Complex integrations with unknowns
## Monitoring Output
### Real-Time Progress
```bash
# Terminal output shows:
Story 3/8: 2-3-password-reset
Pre-gap: ✅ 2 tasks refined
Development: ⏳ 2/6 tasks complete
...
```
### Progress File
```bash
# Check progress programmatically:
cat docs/sprint-artifacts/.autonomous-epic-progress.yaml
# Example:
epic_num: 2
status: running
completed_stories: [2-1-user-registration, 2-2-user-login]
current_story: 2-3-password-reset
```
### Completion Report
```bash
# Generated when epic completes:
cat docs/sprint-artifacts/epic-2-completion-report.md
```
## Advanced: Batch Epic Processing
Process multiple epics:
```bash
# Sequential processing:
/autonomous-epic 1
/autonomous-epic 2
/autonomous-epic 3
# Or create meta-workflow for parallel processing
```
## FAQ
### Q: Can I stop autonomous processing mid-epic?
**A:** Yes, Ctrl+C between stories. Progress saved. Resume with `/autonomous-epic {num}`
### Q: What if a story fails?
**A:** Logged in failed_stories. By default, continues to next story. Fix manually later.
### Q: Does this work with existing stories?
**A:** Yes! Picks up any ready-for-dev or in-progress stories and develops them.
### Q: Can I customize per story?
**A:** Not currently. All stories in epic use same settings. Manual development for custom needs.
### Q: What about dependencies between stories?
**A:** Stories processed sequentially, so Story 2.2 can leverage Story 2.1's code (gap analysis handles this!)
### Q: Token budget concerns?
**A:** Use dev-story instead of super-dev-story to reduce token usage by ~30%
## See Also
- [super-dev-story](../super-dev-story/) - Enhanced quality workflow
- [dev-story](../dev-story/) - Standard development workflow
- [gap-analysis](../gap-analysis/) - Standalone audit tool
- [Autonomous Epic Concept](../../../../docs/autonomous-epic-processing.md) - Vision document
---
**Autonomous Epic Processing: "Do Epic 4 for me" is now reality** ✨

View File

@ -0,0 +1,419 @@
<workflow>
<critical>The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml</critical>
<critical>You MUST have already loaded and processed: {installed_path}/workflow.yaml</critical>
<critical>Communicate all responses in {communication_language}</critical>
<critical>🤖 AUTONOMOUS EPIC PROCESSING - Full automation of epic completion!</critical>
<critical>This workflow creates and develops ALL stories in an epic with minimal human intervention</critical>
<step n="1" goal="Initialize autonomous epic processing">
<output>🤖 **Autonomous Epic Processing**
This workflow will automatically:
1. Create all stories in the epic (just-in-time planning)
2. Develop each story with comprehensive validation
3. Commit changes after each story
4. Generate epic completion report
**Time Estimate:** Varies by epic size
- Small epic (3-5 stories): 3-6 hours
- Medium epic (6-10 stories): 6-12 hours
- Large epic (11+ stories): 12-24 hours
**Token Usage:** ~100K-150K per story
- Uses super-dev-story by default (highest quality)
- Auto-accepts gap analysis (minimal prompts)
---
</output>
<check if="{{epic_num}} provided by user">
<action>Use provided epic number</action>
<goto anchor="validate_epic" />
</check>
<ask>Enter epic number to process (e.g., "2", "epic-3"), or [q] to quit:</ask>
<check if="user provides epic number">
<action>Parse epic number from input (handle "2", "epic-2", "Epic 2" formats)</action>
<action>Set {{epic_num}} to parsed number</action>
<goto anchor="validate_epic" />
</check>
<check if="user says q">
<output>👋 Autonomous epic processing cancelled.</output>
<action>HALT</action>
</check>
<anchor id="validate_epic" />
<action>Load {{sprint_status}} file</action>
<action>Find epic-{{epic_num}} entry in development_status</action>
<check if="epic not found in sprint status">
<output>❌ Epic {{epic_num}} not found in sprint-status.yaml
Available epics:
{{list_available_epics}}
Run sprint-planning to initialize sprint tracking.
</output>
<action>HALT</action>
</check>
<action>Get epic status from sprint-status</action>
<check if="epic status is 'done'">
<output>✅ Epic {{epic_num}} is already complete!
All stories marked done. Nothing to process.
</output>
<action>HALT</action>
</check>
<action>Count stories in epic (pattern: {{epic_num}}-*)</action>
<action>Count stories by status:
- backlog: Not yet created
- ready-for-dev: Created but not developed
- in-progress: Partially developed
- review: Developed, pending review
- done: Fully complete
</action>
<output>
📊 **Epic {{epic_num}} Status**
Total stories: {{total_story_count}}
- Backlog: {{backlog_count}} (will create + develop)
- Ready-for-dev: {{ready_count}} (will develop)
- In-progress: {{inprogress_count}} (will resume)
- Review: {{review_count}} (will skip - needs human review)
- Done: {{done_count}} (will skip - already complete)
**Work Remaining:** {{backlog_count + ready_count + inprogress_count}} stories
**Estimated Time:** {{estimated_hours}} hours
**Estimated Tokens:** ~{{estimated_tokens}}K
</output>
</step>
<step n="2" goal="Get user confirmation and settings">
<ask>**Proceed with autonomous processing?**
This will:
- Process {{work_count}} stories automatically
- Use {{dev_workflow}} for development (super-dev-story or dev-story)
- Create git commits after each story
- Take approximately {{estimated_hours}} hours
- Use approximately {{estimated_tokens}}K tokens
Options:
[Y] Yes - Start autonomous processing with default settings
[C] Custom - Let me configure settings first
[n] No - Cancel autonomous processing
</ask>
<check if="user approves with Y">
<action>Use default autonomous_settings from workflow.yaml</action>
<output>✅ Starting autonomous epic processing with defaults...</output>
<goto anchor="create_branch" />
</check>
<check if="user chooses Custom with C">
<ask>Use super-dev-story (comprehensive validation) or dev-story (faster)? [super/dev]:</ask>
<action>Store user choice as {{dev_workflow}}</action>
<ask>Auto-accept gap analysis refinements? [Y/n]:</ask>
<action>Store user choice as {{auto_accept_gap}}</action>
<ask>Create git commits after each story? [Y/n]:</ask>
<action>Store user choice as {{create_commits}}</action>
<ask>Halt on first error or continue? [halt/continue]:</ask>
<action>Store user choice as {{error_handling}}</action>
<output>✅ Custom settings configured. Starting autonomous processing...</output>
<goto anchor="create_branch" />
</check>
<check if="user says no with n">
<output>❌ Autonomous epic processing cancelled.</output>
<action>HALT</action>
</check>
<anchor id="create_branch" />
</step>
<step n="3" goal="Create git branch and initialize progress tracking">
<check if="{{create_commits}} is true">
<action>Check current git branch</action>
<action>Create new branch: {{git_branch_prefix}}{{epic_num}}</action>
<output>📝 Created git branch: {{git_branch_prefix}}{{epic_num}}</output>
</check>
<!-- Initialize progress tracking -->
<action>Create progress file: {{progress_file}}</action>
<action>Write initial progress state:
epic_num: {{epic_num}}
started: {{date}}
total_stories: {{total_story_count}}
completed_stories: []
failed_stories: []
current_story: null
status: running
</action>
<output>🚀 **Autonomous Epic Processing Started**
Epic: {{epic_num}}
Branch: {{git_branch_name}}
Progress tracking: {{progress_file}}
Processing {{work_count}} stories...
</output>
</step>
<step n="4" goal="Process all stories in epic">
<critical>🔄 STORY PROCESSING LOOP - Just-in-time planning + development</critical>
<action>Load {{sprint_status}} file</action>
<action>Find all stories in epic {{epic_num}} (pattern: {{epic_num}}-*)</action>
<action>Sort stories by story number (ascending order)</action>
<action>Filter to stories needing work (backlog, ready-for-dev, in-progress statuses)</action>
<action>Initialize {{story_counter}} = 0</action>
<action>Initialize {{success_count}} = 0</action>
<action>Initialize {{failure_count}} = 0</action>
<!-- STORY LOOP -->
<loop foreach="{{stories_needing_work}}">
<action>Set {{current_story}} = current story from loop</action>
<action>Increment {{story_counter}}</action>
<action>Update progress file with current_story</action>
<output>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Story {{story_counter}}/{{work_count}}: {{current_story.key}}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Status: {{current_story.status}}
Started: {{current_time}}
</output>
<!-- CREATE STORY IF NEEDED -->
<check if="current_story.status == 'backlog'">
<output>📝 Creating story {{current_story.key}}...</output>
<try>
<action>Run create-story workflow for this story</action>
<action>Wait for story file to be created</action>
<output>✅ Story created: {{story_file}}</output>
</try>
<catch>
<output>❌ Failed to create story {{current_story.key}}
Error: {{error_message}}
</output>
<check if="{{halt_on_error}} is true">
<action>Update progress file with failure</action>
<output>🛑 Halting due to error (halt_on_error=true)</output>
<action>HALT</action>
</check>
<check if="{{halt_on_error}} is false">
<action>Add to {{failed_stories}} list</action>
<action>Increment {{failure_count}}</action>
<output>⏭️ Skipping to next story...</output>
<continue>Next story in loop</continue>
</check>
</catch>
</check>
<!-- DEVELOP STORY -->
<output>💻 Developing story {{current_story.key}} using {{dev_workflow}}...</output>
<try>
<check if="{{dev_workflow}} == 'super-dev-story'">
<action>Run super-dev-story workflow with auto-accept mode enabled</action>
</check>
<check if="{{dev_workflow}} == 'dev-story'">
<action>Run dev-story workflow with auto-accept mode enabled</action>
</check>
<action>Wait for story to be marked "review"</action>
<output>✅ Story {{current_story.key}} completed
Status: review
Tasks completed: {{task_count}}
Files changed: {{file_count}}
Time: {{elapsed_time}}
</output>
<!-- CREATE GIT COMMIT -->
<check if="{{create_commits}} is true">
<action>Create git commit for this story:
Message: "feat(epic-{{epic_num}}): complete story {{current_story.key}} - {{story_title}}"
Include: All files changed during story development
</action>
<output>📝 Committed: {{commit_hash}}</output>
</check>
<action>Increment {{success_count}}</action>
<action>Add to progress file completed_stories list</action>
<action>Update progress file with success</action>
</try>
<catch>
<output>❌ Failed to develop story {{current_story.key}}
Error: {{error_message}}
Attempt: {{retry_count}}/{{max_retry_per_story}}
</output>
<check if="{{retry_count}} < {{max_retry_per_story}}">
<output>🔄 Retrying story {{current_story.key}}...</output>
<action>Increment {{retry_count}}</action>
<retry>Retry this story</retry>
</check>
<check if="{{retry_count}} >= {{max_retry_per_story}}">
<output>⚠️ Max retries reached for story {{current_story.key}}</output>
<check if="{{halt_on_error}} is true">
<action>Update progress file with failure and halt</action>
<output>🛑 Halting due to repeated errors (halt_on_error=true)</output>
<action>HALT</action>
</check>
<check if="{{halt_on_error}} is false">
<action>Add to {{failed_stories}} list</action>
<action>Increment {{failure_count}}</action>
<output>⏭️ Skipping to next story...</output>
<continue>Next story in loop</continue>
</check>
</check>
</catch>
<!-- Progress update -->
<output>
Progress: {{success_count}} ✅ | {{failure_count}} ❌ | {{remaining_count}} pending
</output>
</loop>
<!-- After all stories processed -->
<action>Update progress file status: complete</action>
</step>
<step n="5" goal="Epic completion and reporting">
<critical>📊 EPIC COMPLETE - Generate completion report</critical>
<action>Load all completed story files from this epic</action>
<action>Aggregate statistics:
- Total files created/modified
- Total test coverage
- Total code review issues found and fixed
- Total development time
- Success rate
</action>
<action>Generate epic completion report: {{story_dir}}/epic-{{epic_num}}-completion-report.md</action>
<output>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎉 EPIC {{epic_num}} AUTONOMOUS PROCESSING COMPLETE!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
**Results:**
✅ Stories completed: {{success_count}}/{{total_story_count}}
{{if_failures}}
❌ Stories failed: {{failure_count}}
{{list_failed_stories_with_reasons}}
{{endif}}
**Statistics:**
- Total development time: {{total_time}}
- Files created/modified: {{total_files}}
- Test coverage achieved: {{avg_coverage}}%
- Code review issues found: {{total_issues}}
- Code review issues fixed: {{total_fixes}}
**Git Branch:** {{git_branch_name}}
**Commits:** {{commit_count}}
**Completion Report:** {{report_file}}
---
**Next Steps:**
1. Review the completion report
2. Manually review/fix any failed stories
3. Run human code review on the branch
4. Merge {{git_branch_name}} when approved
{{if_failures}}
**Failed Stories Need Attention:**
{{list_failed_stories}}
{{endif}}
</output>
<!-- Update sprint status -->
<check if="{{success_count}} == {{total_story_count}}">
<action>Load {{sprint_status}} file</action>
<action>Update epic-{{epic_num}} status to "done"</action>
<output>✅ Epic {{epic_num}} marked complete in sprint-status.yaml</output>
</check>
<check if="{{failure_count}} > 0">
<output> Epic {{epic_num}} partially complete - some stories failed.
Epic status remains "in-progress" until failed stories resolved.
</output>
</check>
<!-- Final git operations -->
<check if="{{create_commits}} is true">
<output>📝 All changes committed to branch: {{git_branch_name}}
To merge:
git checkout main
git merge {{git_branch_name}}
Or create PR:
gh pr create --base main --head {{git_branch_name}}
</output>
</check>
</step>
<step n="6" goal="Cleanup and user support">
<action>Remove progress file (no longer needed)</action>
<ask>Would you like explanations about:
- How autonomous processing works
- What was implemented in this epic
- Why any stories failed
- How to review and merge the work
- Anything else?
[Enter topic or 'n' to skip]
</ask>
<check if="user asks for explanations">
<action>Provide clear explanations about requested topics</action>
<action>Reference specific stories, code, or decisions</action>
</check>
<output>💡 **Tips for Future Autonomous Processing:**
- Use super-dev-story for critical epics (higher quality, more tokens)
- Use dev-story for experimental epics (faster, fewer tokens)
- Review completion report for patterns and improvements
- Failed stories often indicate unclear requirements
- Monitor token usage and adjust epic size accordingly
**Epic {{epic_num}} processing complete, {user_name}!**
</output>
</step>
</workflow>

View File

@ -0,0 +1,33 @@
name: autonomous-epic
description: "Autonomous epic processing - creates and develops all stories in an epic with minimal human intervention"
author: "BMad"
# Critical variables from config
config_source: "{project-root}/_bmad/bmgd/config.yaml"
user_name: "{config_source}:user_name"
communication_language: "{config_source}:communication_language"
implementation_artifacts: "{config_source}:implementation_artifacts"
story_dir: "{implementation_artifacts}"
# Workflow components
installed_path: "{project-root}/_bmad/bmgd/workflows/4-production/autonomous-epic"
instructions: "{installed_path}/instructions.xml"
progress_file: "{story_dir}/.autonomous-epic-progress.yaml"
# Variables
epic_num: "" # User provides or auto-discover next epic
sprint_status: "{implementation_artifacts}/sprint-status.yaml"
project_context: "**/project-context.md"
# Autonomous mode settings
autonomous_settings:
use_super_dev: true # Use super-dev-story vs dev-story
auto_accept_gap_analysis: true # Auto-approve gap analysis refinements
halt_on_error: false # Continue even if story fails
max_retry_per_story: 2 # Retry failed stories
create_git_commits: true # Commit after each story
git_branch_prefix: "auto-epic-" # Branch name format: auto-epic-{epic_num}
standalone: true
web_bundle: false

View File

@ -0,0 +1,651 @@
# Autonomous Epic Processing
**"Do Epic 4 for me" - Full automation of epic completion**
## What It Does
Autonomous epic processing combines just-in-time planning with automated development:
```
/autonomous-epic 2
→ Creates Story 2.1 → Develops with super-dev-story → Commits → Done ✅
→ Creates Story 2.2 → Develops with super-dev-story → Commits → Done ✅
→ Creates Story 2.3 → Develops with super-dev-story → Commits → Done ✅
...
→ Entire Epic 2 complete! 🎉
```
## How It Works
```
┌──────────────────────────────────────────────────┐
│ Autonomous Epic Processor │
│ │
│ For each story in epic (sequential): │
│ ┌─────────────────────────────────────────────┐ │
│ │ 1. create-story (just-in-time planning) │ │
│ │ ↓ │ │
│ │ 2. super-dev-story (or dev-story) │ │
│ │ ├─ Pre-dev gap analysis │ │
│ │ ├─ Development (TDD) │ │
│ │ ├─ Post-dev gap analysis (super-dev only) │ │
│ │ ├─ Code review (super-dev only) │ │
│ │ └─ Fix issues │ │
│ │ ↓ │ │
│ │ 3. Git commit │ │
│ │ ↓ │ │
│ │ 4. Save progress │ │
│ └─────────────────────────────────────────────┘ │
│ │
│ Epic completion report generated │
└──────────────────────────────────────────────────┘
```
## Usage
### Basic Usage
```bash
# Load any BMAD agent
/autonomous-epic
# Will prompt for epic number:
Enter epic number: 2
# Or provide directly:
/autonomous-epic epic-2
```
### With Defaults
```bash
/autonomous-epic 3
# Uses default settings:
# ✅ super-dev-story (comprehensive quality)
# ✅ Auto-accept gap analysis
# ✅ Create git commits
# ✅ Continue on errors
```
### With Custom Settings
```bash
/autonomous-epic 3
# When prompted:
[C] Custom settings
# Then configure:
# - dev-story or super-dev-story?
# - Auto-accept gap analysis?
# - Create git commits?
# - Halt on error or continue?
```
## Configuration
### Default Settings (workflow.yaml)
```yaml
autonomous_settings:
use_super_dev: true # Use super-dev-story (vs dev-story)
auto_accept_gap_analysis: true # Auto-approve gap analysis
halt_on_error: false # Continue even if story fails
max_retry_per_story: 2 # Retry failed stories
create_git_commits: true # Commit after each story
git_branch_prefix: "auto-epic-" # Branch: auto-epic-{epic_num}
```
### Per-Epic Override
```yaml
# In sprint-status.yaml or epic frontmatter
epic-3:
autonomous_settings:
use_super_dev: false # Use dev-story (faster)
halt_on_error: true # Stop on first failure
```
## Time & Cost Estimates
### Time per Story
| Workflow | Avg Time per Story | Token Usage |
|----------|-------------------|-------------|
| **dev-story** | 20-40 minutes | 50K-100K |
| **super-dev-story** | 25-50 minutes | 80K-150K |
### Epic Estimates
| Epic Size | Time (dev-story) | Time (super-dev) | Tokens |
|-----------|-----------------|------------------|--------|
| Small (3-5 stories) | 1-3 hours | 2-4 hours | 250K-750K |
| Medium (6-10 stories) | 2-7 hours | 3-8 hours | 500K-1.5M |
| Large (11-20 stories) | 4-13 hours | 5-17 hours | 1M-3M |
**Recommendation:** Run overnight for large epics
## Example Session
```
🤖 Autonomous Epic Processing
Enter epic number: 2
📊 Epic 2 Status
Total stories: 8
- Backlog: 5 (will create + develop)
- Ready-for-dev: 2 (will develop)
- In-progress: 1 (will resume)
- Review: 0
- Done: 0
Work Remaining: 8 stories
Estimated Time: 4-6 hours
Estimated Tokens: ~800K-1.2M
Proceed? [Y/C/n]: Y
✅ Starting autonomous epic processing...
📝 Created git branch: auto-epic-2
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Story 1/8: 2-1-user-registration
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Status: backlog
📝 Creating story 2-1-user-registration...
✅ Story created
💻 Developing story using super-dev-story...
Pre-gap: ✅ 0 changes needed
Development: ✅ 8 tasks completed
Post-gap: ✅ All verified
Code review: ✅ No issues
✅ Story complete (42 minutes, 95K tokens)
📝 Committed: a1b2c3d
Progress: 1 ✅ | 0 ❌ | 7 pending
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Story 2/8: 2-2-user-login
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📝 Creating story 2-2-user-login...
✅ Story created
💻 Developing story using super-dev-story...
Pre-gap: ✅ Reusing registration code (3 tasks refined)
Development: ✅ 6 tasks completed
Post-gap: ✅ All verified
Code review: ⚠️ 1 medium issue found
Code review: ✅ Issue fixed
✅ Story complete (38 minutes, 110K tokens)
📝 Committed: d4e5f6g
Progress: 2 ✅ | 0 ❌ | 6 pending
[... continues for all 8 stories ...]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎉 EPIC 2 AUTONOMOUS PROCESSING COMPLETE!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Results:
✅ Stories completed: 8/8
❌ Stories failed: 0
Statistics:
- Total time: 5h 23m
- Files created/modified: 47
- Test coverage: 94%
- Code review issues: 6 (all fixed)
Git Branch: auto-epic-2
Commits: 8
Next Steps:
1. Review completion report
2. Run human code review
3. Merge auto-epic-2
```
## Progress Tracking
### Progress File
Autonomous epic maintains state in `.autonomous-epic-progress.yaml`:
```yaml
epic_num: 2
started: 2025-01-18T10:00:00Z
total_stories: 8
completed_stories:
- 2-1-user-registration
- 2-2-user-login
failed_stories: []
current_story: 2-3-password-reset
status: running
```
### Resume from Interruption
If interrupted (crash, manual stop, timeout):
```bash
/autonomous-epic 2
# Detects existing progress file
# Shows: "Found in-progress epic processing. Resume? [Y/n]"
# Continues from last completed story
```
## Error Handling
### Story Failures
**With `halt_on_error: false` (default):**
```
Story 2.3 fails
→ Logged in failed_stories
→ Continue to Story 2.4
→ Report failures at end
```
**With `halt_on_error: true`:**
```
Story 2.3 fails
→ Stop processing immediately
→ Report error
→ User fixes manually
→ Resume from Story 2.3
```
### Retry Logic
Each story gets {{max_retry_per_story}} attempts (default: 2):
```
Story 2.5 fails
→ Retry 1/2: Attempt again
→ Retry 2/2: Attempt again
→ Max retries: Mark failed, continue to next story
```
## Git Integration
### Automatic Branching
```bash
# Autonomous epic creates:
Branch: auto-epic-{epic_num}
# Example:
/autonomous-epic 3
→ Creates branch: auto-epic-3
```
### Commits per Story
Each story gets its own commit:
```
feat(epic-2): complete story 2-1-user-registration
feat(epic-2): complete story 2-2-user-login
feat(epic-2): complete story 2-3-password-reset
...
```
### Merge When Done
```bash
# After autonomous epic completes:
git checkout main
git merge auto-epic-2
# Or create PR:
gh pr create --base main --head auto-epic-2 --title "Epic 2: User Management"
```
## Completion Report
Generated at: `{{story_dir}}/epic-{{epic_num}}-completion-report.md`
```markdown
# Epic 2 Completion Report
**Generated:** 2025-01-18
**Processing Time:** 5h 23m
**Success Rate:** 100% (8/8 stories)
## Story Summary
| Story | Status | Time | Files | Coverage | Issues |
|-------|--------|------|-------|----------|--------|
| 2.1 | ✅ Done | 42m | 6 | 95% | 0 |
| 2.2 | ✅ Done | 38m | 5 | 92% | 1 |
| 2.3 | ✅ Done | 45m | 7 | 96% | 2 |
...
## Epic Statistics
- Total files: 47 (35 created, 12 modified)
- Average coverage: 94%
- Code review issues: 6 (all resolved)
- Total commits: 8
## Quality Metrics
- Stories passing first time: 6/8 (75%)
- Average fix iterations: 0.25
- Zero critical issues escaped
## Git Branch
Branch: auto-epic-2
Ready to merge
## Recommendations
- All stories met acceptance criteria
- Test coverage exceeds 90% target
- Code review found minimal issues
- Ready for human review and merge
```
## Best Practices
### 1. Epic Sizing
**Recommended epic sizes:**
- **Small (3-5 stories):** Can complete in single session
- **Medium (6-10 stories):** Overnight processing ideal
- **Large (11+ stories):** Consider breaking into sub-epics
### 2. Choosing dev-story vs super-dev-story
**Use super-dev-story for:**
- Security-critical epics
- Customer-facing features
- Complex business logic
- High-stakes production releases
**Use dev-story for:**
- Internal tools
- Experimental features
- Non-critical improvements
- When speed matters more than extra validation
### 3. Monitoring Progress
```bash
# In another terminal, watch progress:
watch -n 10 'cat docs/sprint-artifacts/.autonomous-epic-progress.yaml'
# Or tail completion report:
tail -f docs/sprint-artifacts/epic-2-completion-report.md
```
### 4. Interruption Handling
**Safe to interrupt:**
- Ctrl+C between stories (progress saved)
- Terminal disconnect (can resume)
- Timeout (restarts from last completed)
**Not safe to interrupt:**
- During story development (may leave partial work)
- During git commit (may corrupt repository)
### 5. Resource Management
**Token budgets:**
- Set LLM API limits to prevent runaway costs
- Monitor token usage in real-time
- Consider using dev-story for token savings
**Time management:**
- Run overnight for large epics
- Schedule during low-activity periods
- Use CI/CD for completely automated runs
## Troubleshooting
### "Autonomous epic stuck on one story"
**Cause:** Story has issues preventing completion
**Solution:**
- Check progress file for current_story
- Review that story's dev log
- May need manual intervention
### "Epic processing stopped mid-story"
**Cause:** Interruption during development
**Solution:**
- Check progress file status
- Resume with `/autonomous-epic {epic_num}`
- May need to manually clean up partial work
### "Too many token failures"
**Cause:** Hitting API rate limits
**Solution:**
- Reduce concurrent processing
- Use dev-story instead of super-dev-story
- Increase API tier/limits
### "Git merge conflicts after autonomous epic"
**Cause:** Other changes merged to main during processing
**Solution:**
- Rebase auto-epic branch on latest main
- Resolve conflicts manually
- This is expected for long-running processes
## Safety Features
### Max Retry Protection
Prevents infinite loops:
- Each story: max 2 retries (default)
- After max retries: skip to next story
- Report failures at end
### Progress Checkpoints
After each story:
- Progress file updated
- Git commit created (if enabled)
- Can resume from this point
### Fail-Safe Modes
```yaml
# Conservative (halt on first problem):
halt_on_error: true
max_retry_per_story: 0
# Aggressive (push through everything):
halt_on_error: false
max_retry_per_story: 3
# Balanced (default):
halt_on_error: false
max_retry_per_story: 2
```
## Use Cases
### Use Case 1: Overnight Epic Completion
```bash
# Before leaving office:
/autonomous-epic 4
# Next morning:
# → Epic 100% complete
# → All stories developed
# → All commits created
# → Ready for review
```
### Use Case 2: CI/CD Integration
```bash
# In GitHub Actions:
name: Auto Epic Processing
on:
workflow_dispatch:
inputs:
epic_number:
required: true
jobs:
process-epic:
steps:
- run: npx bmad-method@alpha autonomous-epic ${{ inputs.epic_number }}
```
### Use Case 3: Sprint Automation
```bash
# Monday: Plan all epics for sprint
/sprint-planning
# Tuesday: Auto-process Epic 1
/autonomous-epic 1
# Wednesday: Auto-process Epic 2
/autonomous-epic 2
# Thursday-Friday: Human review and merge
```
## Comparison to Manual Processing
### Manual Workflow
```
Day 1: Create Story 2.1 → Review → Approve (30m)
Day 2: Develop Story 2.1 → Test → Review → Fix → Done (4h)
Day 3: Create Story 2.2 → Review → Approve (30m)
Day 4: Develop Story 2.2 → Test → Review → Fix → Done (3h)
...
8 stories = 16 days minimum (with human bottlenecks)
```
### Autonomous Workflow
```
Day 1 (evening): /autonomous-epic 2
Day 2 (morning): Epic complete, review ready
8 stories = 6 hours machine time + 1-2 days human review
```
**Savings:** ~14 days, 90% reduction in calendar time
## Limitations
### What Autonomous Epic CAN'T Do
- **Complex requirement clarifications** - Needs human for ambiguous requirements
- **Architectural decisions** - Major tech choices need human input
- **UX design decisions** - Visual/interaction design needs human creativity
- **Business logic validation** - Domain expertise often needs human verification
### When to Use Manual Processing
- First epic in new project (learning patterns)
- Experimental features (high uncertainty)
- Stories requiring extensive research
- Complex integrations with unknowns
## Monitoring Output
### Real-Time Progress
```bash
# Terminal output shows:
Story 3/8: 2-3-password-reset
Pre-gap: ✅ 2 tasks refined
Development: ⏳ 2/6 tasks complete
...
```
### Progress File
```bash
# Check progress programmatically:
cat docs/sprint-artifacts/.autonomous-epic-progress.yaml
# Example:
epic_num: 2
status: running
completed_stories: [2-1-user-registration, 2-2-user-login]
current_story: 2-3-password-reset
```
### Completion Report
```bash
# Generated when epic completes:
cat docs/sprint-artifacts/epic-2-completion-report.md
```
## Advanced: Batch Epic Processing
Process multiple epics:
```bash
# Sequential processing:
/autonomous-epic 1
/autonomous-epic 2
/autonomous-epic 3
# Or create meta-workflow for parallel processing
```
## FAQ
### Q: Can I stop autonomous processing mid-epic?
**A:** Yes, Ctrl+C between stories. Progress saved. Resume with `/autonomous-epic {num}`
### Q: What if a story fails?
**A:** Logged in failed_stories. By default, continues to next story. Fix manually later.
### Q: Does this work with existing stories?
**A:** Yes! Picks up any ready-for-dev or in-progress stories and develops them.
### Q: Can I customize per story?
**A:** Not currently. All stories in epic use same settings. Manual development for custom needs.
### Q: What about dependencies between stories?
**A:** Stories processed sequentially, so Story 2.2 can leverage Story 2.1's code (gap analysis handles this!)
### Q: Token budget concerns?
**A:** Use dev-story instead of super-dev-story to reduce token usage by ~30%
## See Also
- [super-dev-story](../super-dev-story/) - Enhanced quality workflow
- [dev-story](../dev-story/) - Standard development workflow
- [gap-analysis](../gap-analysis/) - Standalone audit tool
- [Autonomous Epic Concept](../../../../docs/autonomous-epic-processing.md) - Vision document
---
**Autonomous Epic Processing: "Do Epic 4 for me" is now reality** ✨

View File

@ -0,0 +1,419 @@
<workflow>
<critical>The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml</critical>
<critical>You MUST have already loaded and processed: {installed_path}/workflow.yaml</critical>
<critical>Communicate all responses in {communication_language}</critical>
<critical>🤖 AUTONOMOUS EPIC PROCESSING - Full automation of epic completion!</critical>
<critical>This workflow creates and develops ALL stories in an epic with minimal human intervention</critical>
<step n="1" goal="Initialize autonomous epic processing">
<output>🤖 **Autonomous Epic Processing**
This workflow will automatically:
1. Create all stories in the epic (just-in-time planning)
2. Develop each story with comprehensive validation
3. Commit changes after each story
4. Generate epic completion report
**Time Estimate:** Varies by epic size
- Small epic (3-5 stories): 3-6 hours
- Medium epic (6-10 stories): 6-12 hours
- Large epic (11+ stories): 12-24 hours
**Token Usage:** ~100K-150K per story
- Uses super-dev-story by default (highest quality)
- Auto-accepts gap analysis (minimal prompts)
---
</output>
<check if="{{epic_num}} provided by user">
<action>Use provided epic number</action>
<goto anchor="validate_epic" />
</check>
<ask>Enter epic number to process (e.g., "2", "epic-3"), or [q] to quit:</ask>
<check if="user provides epic number">
<action>Parse epic number from input (handle "2", "epic-2", "Epic 2" formats)</action>
<action>Set {{epic_num}} to parsed number</action>
<goto anchor="validate_epic" />
</check>
<check if="user says q">
<output>👋 Autonomous epic processing cancelled.</output>
<action>HALT</action>
</check>
<anchor id="validate_epic" />
<action>Load {{sprint_status}} file</action>
<action>Find epic-{{epic_num}} entry in development_status</action>
<check if="epic not found in sprint status">
<output>❌ Epic {{epic_num}} not found in sprint-status.yaml
Available epics:
{{list_available_epics}}
Run sprint-planning to initialize sprint tracking.
</output>
<action>HALT</action>
</check>
<action>Get epic status from sprint-status</action>
<check if="epic status is 'done'">
<output>✅ Epic {{epic_num}} is already complete!
All stories marked done. Nothing to process.
</output>
<action>HALT</action>
</check>
<action>Count stories in epic (pattern: {{epic_num}}-*)</action>
<action>Count stories by status:
- backlog: Not yet created
- ready-for-dev: Created but not developed
- in-progress: Partially developed
- review: Developed, pending review
- done: Fully complete
</action>
<output>
📊 **Epic {{epic_num}} Status**
Total stories: {{total_story_count}}
- Backlog: {{backlog_count}} (will create + develop)
- Ready-for-dev: {{ready_count}} (will develop)
- In-progress: {{inprogress_count}} (will resume)
- Review: {{review_count}} (will skip - needs human review)
- Done: {{done_count}} (will skip - already complete)
**Work Remaining:** {{backlog_count + ready_count + inprogress_count}} stories
**Estimated Time:** {{estimated_hours}} hours
**Estimated Tokens:** ~{{estimated_tokens}}K
</output>
</step>
<step n="2" goal="Get user confirmation and settings">
<ask>**Proceed with autonomous processing?**
This will:
- Process {{work_count}} stories automatically
- Use {{dev_workflow}} for development (super-dev-story or dev-story)
- Create git commits after each story
- Take approximately {{estimated_hours}} hours
- Use approximately {{estimated_tokens}}K tokens
Options:
[Y] Yes - Start autonomous processing with default settings
[C] Custom - Let me configure settings first
[n] No - Cancel autonomous processing
</ask>
<check if="user approves with Y">
<action>Use default autonomous_settings from workflow.yaml</action>
<output>✅ Starting autonomous epic processing with defaults...</output>
<goto anchor="create_branch" />
</check>
<check if="user chooses Custom with C">
<ask>Use super-dev-story (comprehensive validation) or dev-story (faster)? [super/dev]:</ask>
<action>Store user choice as {{dev_workflow}}</action>
<ask>Auto-accept gap analysis refinements? [Y/n]:</ask>
<action>Store user choice as {{auto_accept_gap}}</action>
<ask>Create git commits after each story? [Y/n]:</ask>
<action>Store user choice as {{create_commits}}</action>
<ask>Halt on first error or continue? [halt/continue]:</ask>
<action>Store user choice as {{error_handling}}</action>
<output>✅ Custom settings configured. Starting autonomous processing...</output>
<goto anchor="create_branch" />
</check>
<check if="user says no with n">
<output>❌ Autonomous epic processing cancelled.</output>
<action>HALT</action>
</check>
<anchor id="create_branch" />
</step>
<step n="3" goal="Create git branch and initialize progress tracking">
<check if="{{create_commits}} is true">
<action>Check current git branch</action>
<action>Create new branch: {{git_branch_prefix}}{{epic_num}}</action>
<output>📝 Created git branch: {{git_branch_prefix}}{{epic_num}}</output>
</check>
<!-- Initialize progress tracking -->
<action>Create progress file: {{progress_file}}</action>
<action>Write initial progress state:
epic_num: {{epic_num}}
started: {{date}}
total_stories: {{total_story_count}}
completed_stories: []
failed_stories: []
current_story: null
status: running
</action>
<output>🚀 **Autonomous Epic Processing Started**
Epic: {{epic_num}}
Branch: {{git_branch_name}}
Progress tracking: {{progress_file}}
Processing {{work_count}} stories...
</output>
</step>
<step n="4" goal="Process all stories in epic">
<critical>🔄 STORY PROCESSING LOOP - Just-in-time planning + development</critical>
<action>Load {{sprint_status}} file</action>
<action>Find all stories in epic {{epic_num}} (pattern: {{epic_num}}-*)</action>
<action>Sort stories by story number (ascending order)</action>
<action>Filter to stories needing work (backlog, ready-for-dev, in-progress statuses)</action>
<action>Initialize {{story_counter}} = 0</action>
<action>Initialize {{success_count}} = 0</action>
<action>Initialize {{failure_count}} = 0</action>
<!-- STORY LOOP -->
<loop foreach="{{stories_needing_work}}">
<action>Set {{current_story}} = current story from loop</action>
<action>Increment {{story_counter}}</action>
<action>Update progress file with current_story</action>
<output>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Story {{story_counter}}/{{work_count}}: {{current_story.key}}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Status: {{current_story.status}}
Started: {{current_time}}
</output>
<!-- CREATE STORY IF NEEDED -->
<check if="current_story.status == 'backlog'">
<output>📝 Creating story {{current_story.key}}...</output>
<try>
<action>Run create-story workflow for this story</action>
<action>Wait for story file to be created</action>
<output>✅ Story created: {{story_file}}</output>
</try>
<catch>
<output>❌ Failed to create story {{current_story.key}}
Error: {{error_message}}
</output>
<check if="{{halt_on_error}} is true">
<action>Update progress file with failure</action>
<output>🛑 Halting due to error (halt_on_error=true)</output>
<action>HALT</action>
</check>
<check if="{{halt_on_error}} is false">
<action>Add to {{failed_stories}} list</action>
<action>Increment {{failure_count}}</action>
<output>⏭️ Skipping to next story...</output>
<continue>Next story in loop</continue>
</check>
</catch>
</check>
<!-- DEVELOP STORY -->
<output>💻 Developing story {{current_story.key}} using {{dev_workflow}}...</output>
<try>
<check if="{{dev_workflow}} == 'super-dev-story'">
<action>Run super-dev-story workflow with auto-accept mode enabled</action>
</check>
<check if="{{dev_workflow}} == 'dev-story'">
<action>Run dev-story workflow with auto-accept mode enabled</action>
</check>
<action>Wait for story to be marked "review"</action>
<output>✅ Story {{current_story.key}} completed
Status: review
Tasks completed: {{task_count}}
Files changed: {{file_count}}
Time: {{elapsed_time}}
</output>
<!-- CREATE GIT COMMIT -->
<check if="{{create_commits}} is true">
<action>Create git commit for this story:
Message: "feat(epic-{{epic_num}}): complete story {{current_story.key}} - {{story_title}}"
Include: All files changed during story development
</action>
<output>📝 Committed: {{commit_hash}}</output>
</check>
<action>Increment {{success_count}}</action>
<action>Add to progress file completed_stories list</action>
<action>Update progress file with success</action>
</try>
<catch>
<output>❌ Failed to develop story {{current_story.key}}
Error: {{error_message}}
Attempt: {{retry_count}}/{{max_retry_per_story}}
</output>
<check if="{{retry_count}} < {{max_retry_per_story}}">
<output>🔄 Retrying story {{current_story.key}}...</output>
<action>Increment {{retry_count}}</action>
<retry>Retry this story</retry>
</check>
<check if="{{retry_count}} >= {{max_retry_per_story}}">
<output>⚠️ Max retries reached for story {{current_story.key}}</output>
<check if="{{halt_on_error}} is true">
<action>Update progress file with failure and halt</action>
<output>🛑 Halting due to repeated errors (halt_on_error=true)</output>
<action>HALT</action>
</check>
<check if="{{halt_on_error}} is false">
<action>Add to {{failed_stories}} list</action>
<action>Increment {{failure_count}}</action>
<output>⏭️ Skipping to next story...</output>
<continue>Next story in loop</continue>
</check>
</check>
</catch>
<!-- Progress update -->
<output>
Progress: {{success_count}} ✅ | {{failure_count}} ❌ | {{remaining_count}} pending
</output>
</loop>
<!-- After all stories processed -->
<action>Update progress file status: complete</action>
</step>
<step n="5" goal="Epic completion and reporting">
<critical>📊 EPIC COMPLETE - Generate completion report</critical>
<action>Load all completed story files from this epic</action>
<action>Aggregate statistics:
- Total files created/modified
- Total test coverage
- Total code review issues found and fixed
- Total development time
- Success rate
</action>
<action>Generate epic completion report: {{story_dir}}/epic-{{epic_num}}-completion-report.md</action>
<output>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎉 EPIC {{epic_num}} AUTONOMOUS PROCESSING COMPLETE!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
**Results:**
✅ Stories completed: {{success_count}}/{{total_story_count}}
{{if_failures}}
❌ Stories failed: {{failure_count}}
{{list_failed_stories_with_reasons}}
{{endif}}
**Statistics:**
- Total development time: {{total_time}}
- Files created/modified: {{total_files}}
- Test coverage achieved: {{avg_coverage}}%
- Code review issues found: {{total_issues}}
- Code review issues fixed: {{total_fixes}}
**Git Branch:** {{git_branch_name}}
**Commits:** {{commit_count}}
**Completion Report:** {{report_file}}
---
**Next Steps:**
1. Review the completion report
2. Manually review/fix any failed stories
3. Run human code review on the branch
4. Merge {{git_branch_name}} when approved
{{if_failures}}
**Failed Stories Need Attention:**
{{list_failed_stories}}
{{endif}}
</output>
<!-- Update sprint status -->
<check if="{{success_count}} == {{total_story_count}}">
<action>Load {{sprint_status}} file</action>
<action>Update epic-{{epic_num}} status to "done"</action>
<output>✅ Epic {{epic_num}} marked complete in sprint-status.yaml</output>
</check>
<check if="{{failure_count}} > 0">
<output> Epic {{epic_num}} partially complete - some stories failed.
Epic status remains "in-progress" until failed stories resolved.
</output>
</check>
<!-- Final git operations -->
<check if="{{create_commits}} is true">
<output>📝 All changes committed to branch: {{git_branch_name}}
To merge:
git checkout main
git merge {{git_branch_name}}
Or create PR:
gh pr create --base main --head {{git_branch_name}}
</output>
</check>
</step>
<step n="6" goal="Cleanup and user support">
<action>Remove progress file (no longer needed)</action>
<ask>Would you like explanations about:
- How autonomous processing works
- What was implemented in this epic
- Why any stories failed
- How to review and merge the work
- Anything else?
[Enter topic or 'n' to skip]
</ask>
<check if="user asks for explanations">
<action>Provide clear explanations about requested topics</action>
<action>Reference specific stories, code, or decisions</action>
</check>
<output>💡 **Tips for Future Autonomous Processing:**
- Use super-dev-story for critical epics (higher quality, more tokens)
- Use dev-story for experimental epics (faster, fewer tokens)
- Review completion report for patterns and improvements
- Failed stories often indicate unclear requirements
- Monitor token usage and adjust epic size accordingly
**Epic {{epic_num}} processing complete, {user_name}!**
</output>
</step>
</workflow>

View File

@ -0,0 +1,33 @@
name: autonomous-epic
description: "Autonomous epic processing - creates and develops all stories in an epic with minimal human intervention"
author: "BMad"
# Critical variables from config
config_source: "{project-root}/_bmad/bmm/config.yaml"
user_name: "{config_source}:user_name"
communication_language: "{config_source}:communication_language"
implementation_artifacts: "{config_source}:implementation_artifacts"
story_dir: "{implementation_artifacts}"
# Workflow components
installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/autonomous-epic"
instructions: "{installed_path}/instructions.xml"
progress_file: "{story_dir}/.autonomous-epic-progress.yaml"
# Variables
epic_num: "" # User provides or auto-discover next epic
sprint_status: "{implementation_artifacts}/sprint-status.yaml"
project_context: "**/project-context.md"
# Autonomous mode settings
autonomous_settings:
use_super_dev: true # Use super-dev-story vs dev-story
auto_accept_gap_analysis: true # Auto-approve gap analysis refinements
halt_on_error: false # Continue even if story fails
max_retry_per_story: 2 # Retry failed stories
create_git_commits: true # Commit after each story
git_branch_prefix: "auto-epic-" # Branch name format: auto-epic-{epic_num}
standalone: true
web_bundle: false