# 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 1. **Scans codebase** to verify what's actually implemented vs what stories claim 2. **Finds the gap** between story requirements and reality 3. **Mends the gap** by building ONLY what's truly missing (no duplicate work) 4. **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 map Filter 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): story-{epic_num}.{story_num}.md story-20.9.md (DOT notation, no suffix) story-{epic_num}.{story_num}*.md story-20.9-megamenu-navigation.md (DOT notation WITH suffix - use Glob wildcard) {epic_num}-{story_num}.md 20-9.md (HYPHEN notation, no "story-" prefix) {epic_num}-{story_num}*.md 20-9-megamenu-navigation.md (HYPHEN notation WITH suffix) story-{story_key}.md story-20-9-megamenu-navigation.md (literal story_key with "story-" prefix) {story_key}.md 20-9-megamenu-navigation.md (literal story_key) Stop at first match and store file_path If NO match found after all 6 patterns β†’ file_status = ❌ MISSING If match found β†’ file_status = βœ… EXISTS 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) πŸ“ Story {{story_key}}: BACKLOG - will create basic story file Mark story as needs_story_creation = true Mark story.creation_workflow = "/create-story" (lightweight, no gap analysis) Mark story as validated (will create in next step) ❌ Story {{story_key}}: File MISSING but status is ready-for-dev Mark story for removal from selection Add to skipped_stories list with reason: "Story file missing (status ready-for-dev but no file)" Read story file: {{file_path}} Parse sections and validate BMAD format 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 Count sections present: sections_found Check Current State content length (word count) Check Acceptance Criteria item count: ac_count Count unchecked tasks ([ ]) in Tasks/Subtasks: task_count Look for gap analysis markers (βœ…/❌) in Current State ❌ 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)" ⚠️ 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:** 1. **Exit this batch execution:** - This story will be skipped - Batch will continue with valid stories only 2. **Backup existing file (optional):** ``` cp {{file_path}} {{file_path}}.backup ``` 3. **Regenerate story manually:** ``` /create-story-with-gap-analysis ``` When prompted, provide: - Story key: {{story_key}} 4. **Validate story format:** ``` ./scripts/validate-all-stories.sh ``` 5. **Re-run batch-super-dev:** - Story will now be properly formatted **Skipping story {{story_key}} from current batch execution.** Mark story for removal from selection Add to skipped_stories list with reason: "Story regeneration requires manual workflow (agents cannot invoke /create-story)" Add to manual_actions_required list: "Regenerate {{story_key}} with /create-story-with-gap-analysis" ⏭️ Skipping story {{story_key}} (file incomplete) Mark story for removal from selection Add to skipped_stories list with reason: "User declined regeneration" βœ… Story {{story_key}}: Valid (12/12 sections, gap analysis present) Mark story as validated βœ… Story {{story_key}}: Already implemented (will skip or reconcile only) Mark story as validated (already done) 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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ βœ… Story Validation Complete ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ **Validated:** {{validated_count}} stories ready to process {{#if skipped_count > 0}}**Skipped:** {{skipped_count}} stories{{/if}} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ πŸ“Š SCORING STORY COMPLEXITY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ For each validated story: Read story file: {{file_path}} Count unchecked tasks ([ ]) at top level only in Tasks/Subtasks section β†’ task_count (See workflow.yaml complexity.task_counting.method = "top_level_only") ⚠️ 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 Extract file paths mentioned in tasks β†’ file_count 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 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) 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 Store complexity_level for story: {{story_key}}.complexity = {level, score, task_count, risk_keywords} 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}} ⚠️ {{story_key}}: No story file (BACKLOG) - will create during execution Mark story as needs_creation Continue to next story ❌ {{story_key}}: Story file MISSING but status is ready-for-dev (inconsistent state) Add to validation_failures list Continue to next story 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) ❌ {{story_key}}: INSUFFICIENT TASKS ({{task_count}}/3 minimum) Add to validation_failures: "{{story_key}}: Only {{task_count}} tasks" ⚠️ {{story_key}}: Story incomplete ({{sections_found}}/12 sections{{#if !gap_analysis}}, no gap analysis{{/if}}) Add to validation_warnings: "{{story_key}}: Needs regeneration" βœ… {{story_key}}: Valid and ready Add to validated_stories list ❌ **Validation Failures ({{validation_failures.length}}):** {{#each validation_failures}} - {{this}} {{/each}} These stories CANNOT be processed. Options: 1. Remove them from selection 2. Fix them manually 3. 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 ⚠️ **Validation Warnings ({{validation_warnings.length}}):** {{#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. Continue with these stories anyway? (yes/no): ❌ Batch processing cancelled. Exit workflow ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ βœ… 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 ❌ No stories remaining after removing backlog stories. Exiting. Exit workflow For each story in needs_creation: πŸ“ Creating story {{@index}}/{{needs_creation.length}}: {{story_key}}... Invoke workflow: /bmad_bmm_create-story Parameters: - story_key: {{story_key}} - epic_num: {{epic_num}} - mode: batch (auto-approve, minimal prompts) βœ… Story created: {{story_key}} Mark story.needs_story_creation = false ❌ Failed to create story: {{story_key}} Add to failed_creations list Remove from selected_stories ⚠️ {{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}} stories Note: 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 - After each story completes, pause for your review - You approve before proceeding to next story - Allows course correction if issues detected - Best for: When you want to monitor progress [A] FULLY AUTONOMOUS MODE - Process all selected stories without pausing - No human interaction until completion - Best for: When stories are well-defined and you trust the process Which mode? [I/A]: Read user input Set execution_mode = "interactive_checkpoint" βœ… Interactive Checkpoint Mode Selected After 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 **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': Capture response as: parallel_count If parallel_count == 'all': set parallel_count = min(count of selected_stories, 10) If parallel_count > 10: set parallel_count = 10 (safety limit) ⚠️ Requested {{original_count}} agents, capped at 10 (safety limit) ## βš™οΈ 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 Initialize counters: completed=0, failed=0, failed_stories=[], reconciliation_warnings=[], reconciliation_warnings_count=0 Set start_time = current timestamp Jump to Step 4-Parallel (Task Agent execution) Continue to Step 4-Sequential (In-session execution) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ πŸš€ SEQUENTIAL BATCH PROCESSING STARTED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ **Stories:** {{count}} **Mode:** super-dev-pipeline (batch, sequential) **Continue on failure:** {{continue_on_failure}} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ For each story in selected_stories: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ πŸ“¦ Story {{current_index}}/{{total_count}}: {{story_key}} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Invoke workflow: /bmad:bmm:workflows:super-dev-pipeline Parameters: mode=batch, story_key={{story_key}}, complexity_level={{story_key}}.complexity.level βœ… Implementation complete: {{story_key}} ORCHESTRATOR: You must execute reconciliation directly using Bash/Read/Edit tools. Do NOT delegate this to an agent. YOU do it. 1. Use Bash: `git log -3 --oneline | grep "{{story_key}}"` to find commit 2. Use Bash: `git diff HEAD~1 --name-only` to get files changed 3. Use Read: `docs/sprint-artifacts/{{story_key}}.md` to see tasks 4. Use Edit: Check off tasks (change `- [ ]` to `- [x]`) for completed work 5. Use Edit: Fill Dev Agent Record with files/date/summary 6. Use Bash: Verify with `grep -c "^- \[x\]"` (must be > 0) 7. Use Edit: Update sprint-status.yaml to "done" or "review" βœ… COMPLETED: {{story_key}} (reconciled) Increment completed counter PAUSE FOR USER REVIEW ╔═══════════════════════════════════════════════════════════════════╗ β•‘ 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]: Read user input βœ… Continuing to next story... πŸ“‹ Implementation Details for {{story_key}} Display story file, test results, review findings 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) ⏸️ Batch paused. Run batch-super-dev again to continue with remaining stories. Jump to Step 5 (Summary) βœ… {{story_key}} complete. Automatically continuing to next story (autonomous mode)... ⚠️ WARNING: {{story_key}} completed but reconciliation failed Increment completed counter (implementation was successful) Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"} Increment reconciliation_warnings_count ❌ FAILED: {{story_key}} Increment failed counter Add story_key to failed_stories list ⚠️ Stopping batch due to failure (continue_on_failure=false) Jump to Step 5 (Summary) **Progress:** {{completed}} completed, {{failed}} failed, {{remaining}} remaining ⏸️ Pausing {{pause_between_stories}} seconds before next story... Wait {{pause_between_stories}} seconds 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... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Spawn first {{max_workers}} agents (or fewer if less stories): While next_story_index < min(max_workers, story_queue.length): 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" Increment next_story_index πŸš€ Worker {{worker_id}} started: {{story_key}} After spawning initial workers: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ βœ… {{active_workers.size}} workers active πŸ“‹ {{story_queue.length - next_story_index}} stories queued ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SEMAPHORE PATTERN: Keep {{max_workers}} agents running continuously While active_workers.size > 0 OR next_story_index < story_queue.length: Poll for completed workers (check task outputs non-blocking): For each worker_id in active_workers: Check if worker task completed using TaskOutput(task_id, block=false) Continue to next worker (don't wait) Get worker details: story_key = active_workers[worker_id].story_key βœ… Worker {{worker_id}} completed: {{story_key}} ORCHESTRATOR: You must execute reconciliation directly using Bash/Read/Edit tools. 1. Use Bash: `git log -3 --oneline | grep "{{story_key}}"` to find commit 2. Use Bash: `git diff HEAD~1 --name-only` to get files changed 3. Use Read: `docs/sprint-artifacts/{{story_key}}.md` to see tasks 4. Use Edit: Check off tasks (change `- [ ]` to `- [x]`) for completed work 5. Use Edit: Fill Dev Agent Record with files/date/summary 6. Use Bash: Verify with `grep -c "^- \[x\]"` (must be > 0) 7. Use Edit: Update sprint-status.yaml to "done" or "review" βœ… COMPLETED: {{story_key}} (reconciled) Add to completed_stories ⚠️ WARNING: {{story_key}} completed but reconciliation failed Add to completed_stories (implementation successful) Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"} Remove worker_id from active_workers (free the slot) IMMEDIATELY refill slot if stories remain: story_key = story_queue[next_story_index] πŸ”„ Worker {{worker_id}} refilled: {{story_key}} Spawn new Task agent for this worker_id (same parameters as init) Update active_workers[worker_id] with new task_id and story_key Increment next_story_index Get worker details: story_key = active_workers[worker_id].story_key ❌ Worker {{worker_id}} failed: {{story_key}} Add to failed_stories Remove worker_id from active_workers (free the slot) ⚠️ Stopping all workers due to failure (continue_on_failure=false) Kill all active workers Clear story_queue Break worker pool loop story_key = story_queue[next_story_index] πŸ”„ Worker {{worker_id}} refilled: {{story_key}} (despite previous failure) Spawn new Task agent for this worker_id Update active_workers[worker_id] with new task_id and story_key Increment next_story_index Display live progress every 30 seconds: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ πŸ“Š 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}} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Sleep 5 seconds before next poll (prevents tight loop) 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:** ```bash {{#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:** 1. Validate all stories: `./scripts/validate-all-stories.sh` 2. Re-run batch-super-dev for these stories ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ {{/if}} **Next steps:** 1. Check sprint-status.yaml - stories should be marked "done" or "review" 2. Run tests: `pnpm test` 3. Check coverage: `pnpm test --coverage` 4. Review commits: `git log -{{completed}}` 5. 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