49 KiB
Batch Super-Dev - Interactive Story Selector
AKA: "Mend the Gap" 🚇
Primary Use Case: Gap analysis and reconciliation workflow
This workflow helps you "mind the gap" between story requirements and codebase reality, then "mend the gap" by building only what's truly missing.
What This Workflow Does
- Scans codebase to verify what's actually implemented vs what stories claim
- Finds the gap between story requirements and reality
- Mends the gap by building ONLY what's truly missing (no duplicate work)
- Updates tracking to reflect actual completion status (check boxes, sprint-status)
Common Use Cases
Reconciliation Mode (Most Common):
- Work was done but not properly tracked
- Stories say "build X" but X is 60-80% already done
- Need second set of eyes to find real gaps
- Update story checkboxes to match reality
Greenfield Mode:
- Story says "build X", nothing exists
- Build 100% from scratch with full quality gates
Brownfield Mode:
- Story says "modify X", X exists
- Refactor carefully, add only new requirements
Execution Modes
Sequential (Recommended for Gap Analysis):
- Process stories ONE-BY-ONE in THIS SESSION
- After each story: verify existing code → build only gaps → check boxes → move to next
- Easier to monitor, can intervene if issues found
- Best for reconciliation work
Parallel (For Greenfield Batch Implementation):
- Spawn autonomous Task agents to process stories concurrently
- Faster completion but harder to monitor
- Best when stories are independent and greenfield
The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml You MUST have already loaded and processed: {project-root}/_bmad/bmm/workflows/4-implementation/batch-super-dev/workflow.yaml
⚕️ HOSPITAL-GRADE CODE STANDARDS ⚕️ This code may be used in healthcare settings where LIVES ARE AT STAKE. Every line of code must meet hospital-grade reliability standards. QUALITY >> SPEED. Take 5 hours to do it right, not 1 hour to do it poorly.
Read {sprint_status} file Parse metadata: project, project_key, tracking_system Parse development_status mapFilter stories with status = "ready-for-dev" OR "backlog" Exclude entries that are epics (keys starting with "epic-") or retrospectives (keys ending with "-retrospective") Group by status: ready_for_dev_stories, backlog_stories
Further filter stories to only include those starting with "{filter_by_epic}-" If filter_by_epic = "3", only include stories like "3-1-...", "3-2-...", etc.Sort filtered stories by epic number, then story number (e.g., 1-1, 1-2, 2-1, 3-1) Store as: ready_for_dev_stories (list of story keys)
✅ No available stories found (ready-for-dev or backlog).All stories are either in-progress, review, or done!
Run /bmad_bmm_sprint-status to see current status.
Exit workflow
Combine both lists: available_stories = ready_for_dev_stories + backlog_stories
Read comment field for each story from sprint-status.yaml (text after # on the same line)For each story, verify story file exists using COMPREHENSIVE naming pattern detection:
Parse story_key (e.g., "20-9-megamenu-navigation" or "20-9") to extract: - epic_num: first number (e.g., "20") - story_num: second number (e.g., "9") - optional_suffix: everything after second number (e.g., "-megamenu-navigation" or empty) Input: "20-9-megamenu-navigation" → epic=20, story=9, suffix="-megamenu-navigation" Input: "20-11" → epic=20, story=11, suffix="" Use Glob tool to search for files matching these patterns (in priority order):<pattern n="1">story-{epic_num}.{story_num}.md</pattern>
<example>story-20.9.md (DOT notation, no suffix)</example>
<pattern n="2">story-{epic_num}.{story_num}*.md</pattern>
<example>story-20.9-megamenu-navigation.md (DOT notation WITH suffix - use Glob wildcard)</example>
<pattern n="3">{epic_num}-{story_num}.md</pattern>
<example>20-9.md (HYPHEN notation, no "story-" prefix)</example>
<pattern n="4">{epic_num}-{story_num}*.md</pattern>
<example>20-9-megamenu-navigation.md (HYPHEN notation WITH suffix)</example>
<pattern n="5">story-{story_key}.md</pattern>
<example>story-20-9-megamenu-navigation.md (literal story_key with "story-" prefix)</example>
<pattern n="6">{story_key}.md</pattern>
<example>20-9-megamenu-navigation.md (literal story_key)</example>
<action>Stop at first match and store file_path</action>
<action>If NO match found after all 6 patterns → file_status = ❌ MISSING</action>
<action>If match found → file_status = ✅ EXISTS</action>
Mark stories as: ✅ (file exists), ❌ (file missing), 🔄 (already implemented but not marked done)
## 📦 Available Stories ({{count}}){{#if filter_by_epic}} Filtered by Epic {{filter_by_epic}} {{/if}}
{{#if ready_for_dev_stories.length > 0}}
Ready for Dev ({{ready_for_dev_stories.length}})
{{#each ready_for_dev_stories}} {{@index}}. {{key}} {{file_status_icon}} {{sprint_status}} {{#if comment}}→ {{comment}}{{/if}} {{#if file_path}} File: {{file_path}}{{/if}} {{/each}} {{/if}}
{{#if backlog_stories.length > 0}}
Backlog ({{backlog_stories.length}})
{{#each backlog_stories}} {{@index}}. {{key}} {{file_status_icon}} [BACKLOG] {{#if comment}}→ {{comment}}{{/if}} {{#if file_path}} File: {{file_path}}{{else}} Needs story creation{{/if}} {{/each}} {{/if}}
Legend:
- ✅ Story file exists, ready to implement
- 🔄 Already implemented, just needs status update
- ❌ Story file missing, needs creation first
- [BACKLOG] Story needs gap analysis before implementation
Total: {{count}} stories available Max batch size: {{max_stories}} stories
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔍 VALIDATING STORY FILES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━For each story in available_stories (ready_for_dev + backlog):
Check if story file exists (already done in Step 2)<check if="file_status_icon == '❌' (file missing)">
<check if="story status is BACKLOG">
<output>📝 Story {{story_key}}: BACKLOG - will create basic story file</output>
<action>Mark story as needs_story_creation = true</action>
<action>Mark story.creation_workflow = "/create-story" (lightweight, no gap analysis)</action>
<action>Mark story as validated (will create in next step)</action>
</check>
<check if="story status is ready-for-dev">
<output>❌ Story {{story_key}}: File MISSING but status is ready-for-dev</output>
<action>Mark story for removal from selection</action>
<action>Add to skipped_stories list with reason: "Story file missing (status ready-for-dev but no file)"</action>
</check>
</check>
<check if="file_status_icon == '✅' (file exists)">
<action>Read story file: {{file_path}}</action>
<action>Parse sections and validate BMAD format</action>
<action>Check for all 12 required sections:
1. Business Context
2. Current State
3. Acceptance Criteria
4. Tasks and Subtasks
5. Technical Requirements
6. Architecture Compliance
7. Testing Requirements
8. Dev Agent Guardrails
9. Definition of Done
10. References
11. Dev Agent Record
12. Change Log
</action>
<action>Count sections present: sections_found</action>
<action>Check Current State content length (word count)</action>
<action>Check Acceptance Criteria item count: ac_count</action>
<action>Count unchecked tasks ([ ]) in Tasks/Subtasks: task_count</action>
<action>Look for gap analysis markers (✅/❌) in Current State</action>
<check if="task_count < 3">
<output>
❌ Story {{story_key}}: INVALID - Insufficient tasks ({{task_count}}/3 minimum)
This story has TOO FEW TASKS to be a valid story (found {{task_count}}, need ≥3).
Analysis:
- 0 tasks: Story is a stub or empty
- 1-2 tasks: Too small to represent meaningful feature work
- ≥3 tasks: Minimum valid (MICRO threshold)
Possible causes:
- Story file is incomplete/stub
- Tasks section is empty or malformed
- Story needs proper task breakdown
- Story is too small and should be combined with another
Required action:
- Run /validate-create-story to regenerate with proper task breakdown
- Or manually add tasks to reach minimum of 3 tasks
- Or combine this story with a related story
This story will be SKIPPED. Mark story for removal from selection Add to skipped_stories list with reason: "INVALID - Only {{task_count}} tasks (need ≥3)"
<check if="sections_found < 12 OR Current State < 100 words OR no gap analysis markers OR ac_count < 3">
<output>
⚠️ Story {{story_key}}: File incomplete or invalid
-
Sections: {{sections_found}}/12 {{#if Current State < 100 words}}- Current State: stub ({{word_count}} words, expected ≥100){{/if}} {{#if no gap analysis}}- Gap analysis: missing{{/if}} {{#if ac_count < 3}}- Acceptance Criteria: {{ac_count}} items (expected ≥3){{/if}} {{#if task_count < 3}}- Tasks: {{task_count}} items (expected ≥3){{/if}}
Regenerate story with codebase scan? (yes/no):
⚠️ STORY REGENERATION REQUIRES MANUAL WORKFLOW EXECUTION
Story: {{story_key}} Status: File incomplete or invalid ({{sections_found}}/12 sections)
Problem: Agents cannot invoke /create-story-with-gap-analysis workflow autonomously. Story regeneration requires:
- Interactive user prompts
- Context-heavy codebase scanning
- Gap analysis decision-making
Required Action:
-
Exit this batch execution:
- This story will be skipped
- Batch will continue with valid stories only
-
Backup existing file (optional):
cp {{file_path}} {{file_path}}.backup -
Regenerate story manually:
/create-story-with-gap-analysisWhen prompted, provide:
- Story key: {{story_key}}
-
Validate story format:
./scripts/validate-all-stories.sh -
Re-run batch-super-dev:
- Story will now be properly formatted
Skipping story {{story_key}} from current batch execution.
<action>Mark story for removal from selection</action>
<action>Add to skipped_stories list with reason: "Story regeneration requires manual workflow (agents cannot invoke /create-story)"</action>
<action>Add to manual_actions_required list: "Regenerate {{story_key}} with /create-story-with-gap-analysis"</action>
</check>
<check if="response == 'no'">
<output>⏭️ Skipping story {{story_key}} (file incomplete)</output>
<action>Mark story for removal from selection</action>
<action>Add to skipped_stories list with reason: "User declined regeneration"</action>
</check>
</check>
<check if="sections_found == 12 AND sufficient content">
<output>✅ Story {{story_key}}: Valid (12/12 sections, gap analysis present)</output>
<action>Mark story as validated</action>
</check>
</check>
<check if="file_status_icon == '🔄' (already implemented)">
<output>✅ Story {{story_key}}: Already implemented (will skip or reconcile only)</output>
<action>Mark story as validated (already done)</action>
</check>
Remove skipped stories from ready_for_dev_stories Update count of available stories
⏭️ Skipped Stories ({{skipped_count}}): {{#each skipped_stories}} - {{story_key}}: {{reason}} {{/each}} ❌ No valid stories remaining after validation.All stories were either:
- Missing files (user declined creation)
- Invalid/incomplete (user declined regeneration)
- Already implemented
Run /bmad:bmm:workflows:sprint-status to see status.
Exit workflow
For each validated story:
Read story file: {{file_path}}<action>Count unchecked tasks ([ ]) at top level only in Tasks/Subtasks section → task_count
(See workflow.yaml complexity.task_counting.method = "top_level_only")
</action>
<check if="task_count < 3">
<output>
⚠️ Story {{story_key}}: Cannot score complexity - INSUFFICIENT TASKS ({{task_count}}/3 minimum)
This story was not caught in Step 2.5 validation but has too few tasks. It should have been rejected during validation.
Skipping complexity scoring for this story - marking as INVALID. Set {{story_key}}.complexity = {level: "INVALID", score: 0, task_count: {{task_count}}, reason: "Insufficient tasks ({{task_count}}/3 minimum)"} Continue to next story
<action>Extract file paths mentioned in tasks → file_count</action>
<action>Scan story title and task descriptions for risk keywords using rules from workflow.yaml:
- Case insensitive matching (require_word_boundaries: true)
- Include keyword variants (e.g., "authentication" matches "auth")
- Scan: story_title, task_descriptions, subtask_descriptions
</action>
<action>Calculate complexity score:
- Base score = task_count
- Add 5 for each HIGH risk keyword match (auth, security, payment, migration, database, schema, encryption)
- Add 2 for each MEDIUM risk keyword match (api, integration, external, third-party, cache)
- Add 0 for LOW risk keywords (ui, style, config, docs, test)
- Count each keyword only once (no duplicates)
</action>
<action>Assign complexity level using mutually exclusive decision tree (priority order):
1. Check COMPLEX first (highest priority):
IF (task_count ≥ 16 OR complexity_score ≥ 20 OR has ANY HIGH risk keyword)
THEN level = COMPLEX
2. Else check MICRO (lowest complexity):
ELSE IF (task_count ≤ 3 AND complexity_score ≤ 5 AND file_count ≤ 5)
THEN level = MICRO
3. Else default to STANDARD:
ELSE level = STANDARD
This ensures no overlaps:
- Story with HIGH keyword → COMPLEX (never MICRO or STANDARD)
- Story with 4-15 tasks or >5 files → STANDARD (not MICRO or COMPLEX)
- Story with ≤3 tasks, ≤5 files, no HIGH keywords → MICRO
</action>
<action>Store complexity_level for story: {{story_key}}.complexity = {level, score, task_count, risk_keywords}</action>
Group stories by complexity level
Filter out INVALID stories (those with level="INVALID"): For each INVALID story, add to skipped_stories with reason from complexity object Remove INVALID stories from complexity_groups and ready_for_dev_stories
❌ **Invalid Stories Skipped ({{invalid_count}}):** {{#each invalid_stories}} - {{story_key}}: {{reason}} {{/each}}These stories need to be regenerated with /create-story or /validate-create-story before processing.
📊 **Complexity Analysis Complete**{{#each complexity_groups}} {{level}} Stories ({{count}}): {{#each stories}}
- {{story_key}}: {{task_count}} tasks, score {{score}}{{#if risk_keywords}}, risk: {{risk_keywords}}{{/if}} {{/each}} {{/each}}
Pipeline Routing:
- 🚀 MICRO ({{micro_count}}): Lightweight path - skip gap analysis + code review
- ⚙️ STANDARD ({{standard_count}}): Full pipeline with all quality gates
- 🔒 COMPLEX ({{complex_count}}): Enhanced validation + consider splitting
{{#if complex_count > 0}} ⚠️ Warning: {{complex_count}} complex stories detected. Consider:
-
Breaking into smaller stories before processing
-
Running these separately with extra attention {{/if}} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
❌ No valid stories remaining after complexity analysis.
All stories were either:
- Missing story files (Step 2.5)
- Invalid/incomplete (Step 2.5)
- Zero tasks (Step 2.6)
Run /create-story or /validate-create-story to create proper story files, then rerun /batch-super-dev. Exit workflow
**Select stories to process:**Enter story numbers to process (examples):
- Single:
1 - Multiple:
1,3,5 - Range:
1-5(processes 1,2,3,4,5) - Mixed:
1,3-5,8(processes 1,3,4,5,8) - All:
all(processes all {{count}} stories)
Or:
cancel- Exit without processing
Your selection:
Parse user input
❌ Batch processing cancelled. Exit workflow Set selected_stories = all ready_for_dev_stories Parse selection (handle commas, ranges) Input "1,3-5,8" → indexes [1,3,4,5,8] → map to story keys Map selected indexes to story keys from ready_for_dev_stories Store as: selected_stories ⚠️ You selected {{count}} stories, but max_stories is {{max_stories}}.Only the first {{max_stories}} will be processed. Truncate selected_stories to first max_stories entries
Display confirmation
📋 Selected Stories ({{count}})
{{#each selected_stories}} {{@index}}. {{key}} {{#if is_backlog}}[BACKLOG - needs story creation]{{/if}} {{/each}}
Estimated time: {{count}} stories × 30-60 min/story = {{estimated_hours}} hours
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔍 IMPLEMENTATION READINESS CHECK ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Validating selected stories for quality and completeness...
For each selected story:
Read story file: {{story_file_path}}<check if="story file missing">
<check if="story status is BACKLOG">
<output>⚠️ {{story_key}}: No story file (BACKLOG) - will create during execution</output>
<action>Mark story as needs_creation</action>
<action>Continue to next story</action>
</check>
<check if="story status is ready-for-dev">
<output>❌ {{story_key}}: Story file MISSING but status is ready-for-dev (inconsistent state)</output>
<action>Add to validation_failures list</action>
<action>Continue to next story</action>
</check>
</check>
<check if="story file exists">
<action>Validate story completeness:
- Count sections (need 12)
- Check Current State word count (need ≥100)
- Check gap analysis markers (✅/❌)
- Count Acceptance Criteria (need ≥3)
- Count unchecked tasks (need ≥3)
</action>
<check if="task_count < 3">
<output>❌ {{story_key}}: INSUFFICIENT TASKS ({{task_count}}/3 minimum)</output>
<action>Add to validation_failures: "{{story_key}}: Only {{task_count}} tasks"</action>
</check>
<check if="sections_found < 12 OR missing gap analysis OR ac_count < 3">
<output>⚠️ {{story_key}}: Story incomplete ({{sections_found}}/12 sections{{#if !gap_analysis}}, no gap analysis{{/if}})</output>
<action>Add to validation_warnings: "{{story_key}}: Needs regeneration"</action>
</check>
<check if="all validations pass">
<output>✅ {{story_key}}: Valid and ready</output>
<action>Add to validated_stories list</action>
</check>
</check>
❌ **Validation Failures ({{validation_failures.length}}):**
{{#each validation_failures}}
- {{this}} {{/each}}
These stories CANNOT be processed. Options:
-
Remove them from selection
-
Fix them manually
-
Cancel batch execution
Remove failed stories and continue? (yes/no):
Remove validation_failures from selected_stories ✅ Removed {{validation_failures.length}} invalid stories. Continuing with {{selected_stories.length}} valid stories. ❌ Batch processing cancelled. Please fix story validation issues first. Exit workflow
{{#each validation_warnings}}
- {{this}} {{/each}}
These stories have quality issues but can still be processed. Recommend regenerating with /create-story-with-gap-analysis for better quality.
<ask>Continue with these stories anyway? (yes/no):</ask>
<check if="response == 'no'">
<output>❌ Batch processing cancelled.</output>
<action>Exit workflow</action>
</check>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Implementation Readiness: PASS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
**Validated:** {{validated_stories.length}} stories
**Needs Creation:** {{needs_creation.length}} stories (BACKLOG)
**Quality:** All stories meet minimum standards
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ All stories have files - skipping story creation
Jump to Step 3
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📝 BATCH STORY CREATION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
{{needs_creation.length}} stories need creation (BACKLOG status): {{#each needs_creation}}
- {{story_key}} {{/each}}
These will be created using /create-story (lightweight, no gap analysis). Gap analysis will happen just-in-time during implementation (Step 2 of super-dev-pipeline).
Create these {{needs_creation.length}} story files now? (yes/no):
⏭️ Skipping story creation. These stories will be removed from batch. Remove needs_creation stories from selected_stories<check if="selected_stories.length == 0">
<output>❌ No stories remaining after removing backlog stories. Exiting.</output>
<action>Exit workflow</action>
</check>
For each story in needs_creation:
📝 Creating story {{@index}}/{{needs_creation.length}}: {{story_key}}...<action>Invoke workflow: /bmad_bmm_create-story</action>
<action>Parameters:
- story_key: {{story_key}}
- epic_num: {{epic_num}}
- mode: batch (auto-approve, minimal prompts)
</action>
<check if="story creation succeeded">
<output>✅ Story created: {{story_key}}</output>
<action>Mark story.needs_story_creation = false</action>
</check>
<check if="story creation failed">
<output>❌ Failed to create story: {{story_key}}</output>
<action>Add to failed_creations list</action>
<action>Remove from selected_stories</action>
</check>
⚠️ {{failed_creations.length}} stories failed creation:
{{#each failed_creations}}
- {{this}}
{{/each}}
These will be skipped in batch execution.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✅ Story Creation Complete ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ **Created:** {{needs_creation.length - failed_creations.length}} stories **Failed:** {{failed_creations.length}} stories **Ready for implementation:** {{selected_stories.length}} storiesNote: Gap analysis will happen just-in-time during implementation. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
╔═══════════════════════════════════════════════════════════════════╗ ║ BATCH SUPER-DEV: Execution Mode Selection ║ ╚═══════════════════════════════════════════════════════════════════╝⚕️ HOSPITAL-GRADE CODE STANDARDS ACTIVE ⚕️ Lives are at stake. All code must meet safety-critical reliability standards.
**Choose execution mode:**[I] INTERACTIVE CHECKPOINT MODE (Recommended for oversight) - After each story completes, pause for your review - You approve before proceeding to next story - Allows course correction if issues detected - Best for: Critical features, new team members, complex epics
[A] FULLY AUTONOMOUS MODE (Maximum quality, zero interaction) - Process all selected stories without pausing - ENHANCED quality standards (even more rigorous than interactive) - Hospital-grade code verification at every step - NO shortcuts, NO skimping, NO corner-cutting - Best for: Well-defined stories, experienced implementation
⚠️ AUTONOMOUS MODE = HIGHER QUALITY, NOT LOWER In autonomous mode, quality standards are ENHANCED because there's no human oversight in the loop. Every decision is double-checked.
QUALITY >> DURATION. We prioritize correctness over speed.
Which mode? [I/A]:
Read user input
Set execution_mode = "interactive_checkpoint" ✅ Interactive Checkpoint Mode SelectedAfter each story implementation:
-
Full quality report displayed
-
You approve before next story begins
-
Allows real-time oversight and intervention
Set execution_mode = "fully_autonomous"
⚕️ Fully Autonomous Mode Selected - HOSPITAL-GRADE STANDARDS ENFORCED
Quality enhancements for autonomous mode: ✅ Double validation at each step ✅ Comprehensive error checking ✅ Detailed audit trail generation ✅ Zero-tolerance for shortcuts ✅ Hospital-grade code verification
Processing will continue until ALL selected stories complete. NO human interaction required until completion.
QUALITY OVER SPEED: Taking time to ensure correctness. Activate hospital_grade_mode = true Set quality_multiplier = 1.5
**How should these stories be processed?**Options:
- sequential: Run stories one-by-one in this session (slower, easier to monitor)
- parallel: Spawn Task agents to process stories concurrently (faster, autonomous)
Enter: sequential or parallel
Capture response as: execution_mode
Set parallel_count = 1 Set use_task_agents = false ✅ Sequential mode selected - stories will be processed one-by-one in this session Set use_task_agents = true<ask>
How many agents should run in parallel?
Options:
- 2: Conservative (low resource usage, easier debugging)
- 4: Moderate (balanced performance, recommended)
- 8: Aggressive (higher throughput)
- 10: Maximum (10 agent limit for safety)
- all: Use all stories (max 10 agents)
Enter number (2-10) or 'all':
<action>Capture response as: parallel_count</action>
<action>If parallel_count == 'all': set parallel_count = min(count of selected_stories, 10)</action>
<action>If parallel_count > 10: set parallel_count = 10 (safety limit)</action>
<check if="parallel_count was capped at 10">
<output>⚠️ Requested {{original_count}} agents, capped at 10 (safety limit)</output>
</check>
## ⚙️ Execution Plan
Mode: {{execution_mode}} {{#if use_task_agents}} Task Agents: {{parallel_count}} running concurrently Agent Type: general-purpose (autonomous) {{else}} Sequential processing in current session {{/if}}
Stories to process: {{count}} Estimated total time: {{#if use_task_agents}}
-
With {{parallel_count}} agents: {{estimated_hours / parallel_count}} hours {{else}}
-
Sequential: {{estimated_hours}} hours {{/if}}
Confirm execution plan? (yes/no):
❌ Batch processing cancelled. Exit workflow
For each story in selected_stories:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📦 Story {{current_index}}/{{total_count}}: {{story_key}} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<action>Invoke workflow: /bmad:bmm:workflows:super-dev-pipeline</action>
<action>Parameters: mode=batch, story_key={{story_key}}, complexity_level={{story_key}}.complexity.level</action>
<check if="super-dev-pipeline succeeded">
<output>✅ Implementation complete: {{story_key}}</output>
<action>Execute Step 4.5: Smart Story Reconciliation</action>
<action>Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md</action>
<action>Execute reconciliation with story_key={{story_key}}</action>
<check if="reconciliation succeeded">
<output>✅ COMPLETED: {{story_key}} (reconciled)</output>
<action>Increment completed counter</action>
<check if="execution_mode == 'interactive_checkpoint'">
<action>PAUSE FOR USER REVIEW</action>
<output>
╔═══════════════════════════════════════════════════════════════════╗ ║ INTERACTIVE CHECKPOINT: Story {{story_key}} Complete ║ ╚═══════════════════════════════════════════════════════════════════╝
✅ Story {{story_key}} successfully implemented and reconciled
Quality Summary:
- All tests passing
- Type checks passing
- Linter passing
- Code review completed
- Sprint status updated
Remaining stories: {{remaining}}
Options: [C] Continue to next story [R] Review implementation details [P] Pause batch (exit workflow)
Your choice [C/R/P]:
<action>Read user input</action>
<check if="user selects 'C' or 'c'">
<output>✅ Continuing to next story...</output>
</check>
<check if="user selects 'R' or 'r'">
<output>📋 Implementation Details for {{story_key}}</output>
<action>Display story file, test results, review findings</action>
<output>
Press [C] to continue or [P] to pause: Read user input ✅ Continuing to next story... ⏸️ Batch paused. Run batch-super-dev again to continue with remaining stories. Jump to Step 5 (Summary)
<check if="user selects 'P' or 'p'">
<output>⏸️ Batch paused. Run batch-super-dev again to continue with remaining stories.</output>
<action>Jump to Step 5 (Summary)</action>
</check>
</check>
<check if="execution_mode == 'fully_autonomous'">
<output>✅ {{story_key}} complete. Automatically continuing to next story (autonomous mode)...</output>
</check>
</check>
<check if="reconciliation failed">
<output>⚠️ WARNING: {{story_key}} completed but reconciliation failed</output>
<action>Increment completed counter (implementation was successful)</action>
<action>Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"}</action>
<action>Increment reconciliation_warnings_count</action>
</check>
</check>
<check if="super-dev-pipeline failed">
<output>❌ FAILED: {{story_key}}</output>
<action>Increment failed counter</action>
<action>Add story_key to failed_stories list</action>
<check if="continue_on_failure == false">
<output>⚠️ Stopping batch due to failure (continue_on_failure=false)</output>
<action>Jump to Step 5 (Summary)</action>
</check>
</check>
<check if="display_progress == true">
<output>
Progress: {{completed}} completed, {{failed}} failed, {{remaining}} remaining
<check if="not last story AND pause_between_stories > 0">
<output>⏸️ Pausing {{pause_between_stories}} seconds before next story...</output>
<action>Wait {{pause_between_stories}} seconds</action>
</check>
After all stories processed, jump to Step 5 (Summary)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🚀 PARALLEL PROCESSING STARTED (Semaphore Pattern) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ **Stories:** {{count}} **Mode:** Task agents (autonomous, continuous) **Max concurrent agents:** {{parallel_count}} **Continue on failure:** {{continue_on_failure}} **Pattern:** Worker pool with {{parallel_count}} slots ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━📊 Semaphore Pattern Benefits:
-
No idle time between batches
-
Constant {{parallel_count}} agents running
-
As soon as slot frees → next story starts immediately
-
Faster completion (no batch synchronization delays)
Initialize worker pool state:
- story_queue = selected_stories (all stories to process)
- active_workers = {} (map of worker_id → {story_key, task_id, started_at})
- completed_stories = []
- failed_stories = []
- next_story_index = 0
- max_workers = {{parallel_count}}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔧 Initializing {{max_workers}} worker slots... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
<action>Spawn first {{max_workers}} agents (or fewer if less stories):</action>
<iterate>While next_story_index < min(max_workers, story_queue.length):</iterate>
<action>
story_key = story_queue[next_story_index]
worker_id = next_story_index + 1
Spawn Task agent:
- subagent_type: "general-purpose"
- description: "Implement story {{story_key}}"
- prompt: "Execute super-dev-pipeline workflow for story {{story_key}}.
CRITICAL INSTRUCTIONS:
1. Load workflow.xml: _bmad/core/tasks/workflow.xml
2. Load workflow config: _bmad/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml
3. Execute in BATCH mode with story_key={{story_key}} and complexity_level={{story_key}}.complexity.level
4. Follow all 7 pipeline steps (init, pre-gap, implement, post-validate, code-review, complete, summary)
5. Commit changes when complete
6. Report final status (done/failed) with file list
Story file will be auto-resolved from multiple naming conventions."
- run_in_background: true (non-blocking - critical for semaphore pattern)
Store in active_workers[worker_id]:
story_key: {{story_key}}
task_id: {{returned_task_id}}
started_at: {{timestamp}}
status: "running"
</action>
<action>Increment next_story_index</action>
<output>🚀 Worker {{worker_id}} started: {{story_key}}</output>
<action>After spawning initial workers:</action>
<output>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✅ {{active_workers.size}} workers active 📋 {{story_queue.length - next_story_index}} stories queued ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SEMAPHORE PATTERN: Keep {{max_workers}} agents running continuously<iterate>While active_workers.size > 0 OR next_story_index < story_queue.length:</iterate>
<action>Poll for completed workers (check task outputs non-blocking):</action>
<iterate>For each worker_id in active_workers:</iterate>
<action>Check if worker task completed using TaskOutput(task_id, block=false)</action>
<check if="worker task is still running">
<action>Continue to next worker (don't wait)</action>
</check>
<check if="worker task completed successfully">
<action>Get worker details: story_key = active_workers[worker_id].story_key</action>
<output>✅ Worker {{worker_id}} completed: {{story_key}}</output>
<action>Execute Step 4.5: Smart Story Reconciliation</action>
<action>Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md</action>
<action>Execute reconciliation with story_key={{story_key}}</action>
<check if="reconciliation succeeded">
<output>✅ COMPLETED: {{story_key}} (reconciled)</output>
<action>Add to completed_stories</action>
</check>
<check if="reconciliation failed">
<output>⚠️ WARNING: {{story_key}} completed but reconciliation failed</output>
<action>Add to completed_stories (implementation successful)</action>
<action>Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"}</action>
</check>
<action>Remove worker_id from active_workers (free the slot)</action>
<action>IMMEDIATELY refill slot if stories remain:</action>
<check if="next_story_index < story_queue.length">
<action>story_key = story_queue[next_story_index]</action>
<output>🔄 Worker {{worker_id}} refilled: {{story_key}}</output>
<action>Spawn new Task agent for this worker_id (same parameters as init)</action>
<action>Update active_workers[worker_id] with new task_id and story_key</action>
<action>Increment next_story_index</action>
</check>
</check>
<check if="worker task failed">
<action>Get worker details: story_key = active_workers[worker_id].story_key</action>
<output>❌ Worker {{worker_id}} failed: {{story_key}}</output>
<action>Add to failed_stories</action>
<action>Remove worker_id from active_workers (free the slot)</action>
<check if="continue_on_failure == false">
<output>⚠️ Stopping all workers due to failure (continue_on_failure=false)</output>
<action>Kill all active workers</action>
<action>Clear story_queue</action>
<action>Break worker pool loop</action>
</check>
<check if="continue_on_failure == true AND next_story_index < story_queue.length">
<action>story_key = story_queue[next_story_index]</action>
<output>🔄 Worker {{worker_id}} refilled: {{story_key}} (despite previous failure)</output>
<action>Spawn new Task agent for this worker_id</action>
<action>Update active_workers[worker_id] with new task_id and story_key</action>
<action>Increment next_story_index</action>
</check>
</check>
<action>Display live progress every 30 seconds:</action>
<output>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📊 Live Progress ({{timestamp}}) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✅ Completed: {{completed_stories.length}} ❌ Failed: {{failed_stories.length}} 🔄 Active workers: {{active_workers.size}} 📋 Queued: {{story_queue.length - next_story_index}}
Active stories: {{#each active_workers}} Worker {{@key}}: {{story_key}} (running {{duration}}) {{/each}} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
<action>Sleep 5 seconds before next poll (prevents tight loop)</action>
After worker pool drains (all stories processed), jump to Step 5 (Summary)
Calculate end_time and total_duration Calculate success_rate = (completed / total_count) * 100 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📊 BATCH SUMMARY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ **Total stories:** {{total_count}} **✅ Completed:** {{completed}} **❌ Failed:** {{failed}} **⚠️ Reconciliation warnings:** {{reconciliation_warnings_count}} **Success rate:** {{success_rate}}% **Duration:** {{total_duration}}{{#if failed > 0}} Failed stories: {{#each failed_stories}}
- {{this}} {{/each}}
Retry failed stories:
{{#each failed_stories}}
/bmad:bmm:workflows:super-dev-pipeline mode=batch story_key={{this}}
{{/each}}
{{/if}}
{{#if reconciliation_warnings_count > 0}} ⚠️ Reconciliation warnings (stories completed but status may be inaccurate): {{#each reconciliation_warnings}}
- {{story_key}}: {{warning_message}} {{/each}}
Manual reconciliation needed: Review these stories to ensure checkboxes and status are accurate. Check Dev Agent Record vs Acceptance Criteria/Tasks/DoD sections. {{/if}}
{{#if manual_actions_required.length > 0}} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚠️ MANUAL ACTIONS REQUIRED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
{{manual_actions_required.length}} stories require manual intervention:
{{#each manual_actions_required}}
{{@index}}. {{story_key}}
Action: Regenerate story with proper BMAD format
Command: /create-story-with-gap-analysis
{{/each}}
After completing these actions:
- Validate all stories:
./scripts/validate-all-stories.sh - Re-run batch-super-dev for these stories ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ {{/if}}
Next steps:
- Check sprint-status.yaml - stories should be marked "done" or "review"
- Run tests:
pnpm test - Check coverage:
pnpm test --coverage - Review commits:
git log -{{completed}} - Spot-check 2-3 stories for quality
Run another batch?
/bmad:bmm:workflows:batch-super-dev
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Save batch log to {batch_log} Log contents: start_time, end_time, total_duration, selected_stories, completed_stories, failed_stories, success_rate