Files
BMAD-METHOD/src/modules/bmm/workflows/2-plan-workflows/tech-spec/instructions.md

272 lines
9.8 KiB
Markdown
Raw Normal View History

# PRD Workflow - Small Projects (Level 0-1)
<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>
2025-10-17 19:46:25 -05:00
<critical>Communicate all responses in {communication_language} and language MUST be tailored to {user_skill_level}</critical>
<critical>Generate all documents in {document_output_language}</critical>
<critical>This is the SMALL instruction set for Level 0-1 projects - tech-spec with story generation</critical>
<critical>Level 0: tech-spec + single user story | Level 1: tech-spec + epic/stories</critical>
<critical>Project analysis already completed - proceeding directly to technical specification</critical>
<critical>NO PRD generated - uses tech_spec_template + story templates</critical>
2025-10-17 19:46:25 -05:00
<critical>DOCUMENT OUTPUT: Technical, precise, definitive. Specific versions only. User skill level ({user_skill_level}) affects conversation style ONLY, not document content.</critical>
feat: add universal document sharding support with dual-strategy loading Implement comprehensive document sharding system across all BMM workflows enabling 90%+ token savings for large multi-epic projects through selective loading optimization. ## Document Sharding System ### Core Features - **Universal Support**: All 12 BMM workflows (Phase 1-4) handle both whole and sharded documents - **Dual Loading Strategy**: Full Load (Phase 1-3) vs Selective Load (Phase 4) - **Automatic Discovery**: Workflows detect format transparently (whole → sharded priority) - **Efficiency Optimization**: 90%+ token reduction for 10+ epic projects in Phase 4 ### Implementation Details **Phase 1-3 Workflows (7 workflows) - Full Load Strategy:** - product-brief, prd, gdd, create-ux-design, tech-spec, architecture, solutioning-gate-check - Load entire sharded documents when present - Transparent to user experience - Better organization for large projects **Phase 4 Workflows (5 workflows) - Selective Load Strategy:** - sprint-planning (Full Load exception - needs all epics) - epic-tech-context, create-story, story-context, code-review (Selective Load) - Load ONLY the specific epic needed (e.g., epic-3.md for Epic 3 stories) - Massive efficiency: Skip loading 9 other epics in 10-epic project ### Workflow Enhancements **Added to all workflows:** - `input_file_patterns` in workflow.yaml with wildcard discovery - Document Discovery section in instructions.md - Support for sharded index + section files - Brownfield `docs/index.md` support **Pattern standardization:** ```yaml input_file_patterns: document: whole: "{output_folder}/*doc*.md" sharded: "{output_folder}/*doc*/index.md" sharded_single: "{output_folder}/*doc*/section-{{id}}.md" # Selective load ``` ### Retrospective Workflow Major Overhaul Transformed retrospective into immersive, interactive team experience: **Epic Discovery Priority (Fixed):** - Priority 1: Check sprint-status.yaml for last completed epic - Priority 2: Ask user directly - Priority 3: Scan stories folder (last resort) **New Capabilities:** - Deep story analysis: Extract dev notes, mistakes, review feedback, lessons learned - Previous retro integration: Track action items, verify lessons applied - Significant change detection: Alert when discoveries require epic updates - Intent-based facilitation: Natural conversation vs scripted phrases - Party mode protocol: Clear speaker identification (Name (Role): dialogue) - Team dynamics: Drama, disagreements, diverse perspectives, authentic conflict **Structure:** - 12 whole-number steps (no decimals) - Highly interactive with constant user engagement - Cross-references previous retro for accountability - Synthesizes patterns across all stories - Detects architectural assumption changes ## Documentation **Created:** - `docs/document-sharding-guide.md` - Comprehensive 300+ line guide - What is sharding, when to use it (token thresholds) - How sharding works (discovery system, loading strategies) - Using shard-doc tool - Full Load vs Selective Load patterns - Complete examples and troubleshooting - Custom workflow integration patterns **Updated:** - `README.md` - Added Document Sharding feature section - `docs/index.md` - Added under Advanced Topics → Optimization - `src/modules/bmm/workflows/README.md` - Added sharding section with usage - `src/modules/bmb/workflows/create-workflow/workflow-creation-guide.md` - Added complete implementation patterns for workflow builders **Documentation levels:** 1. Overview (README.md) - Quick feature highlight 2. User guide (BMM workflows README) - Practical usage 3. Reference (document-sharding-guide.md) - Complete details 4. Builder guide (workflow-creation-guide.md) - Implementation patterns ## Efficiency Gains **Example: 10-Epic Project** Before sharding: - epic-tech-context for Epic 3: Load all 10 epics (~50k tokens) - create-story for Epic 3: Load all 10 epics (~50k tokens) - story-context for Epic 3: Load all 10 epics (~50k tokens) After sharding with selective load: - epic-tech-context for Epic 3: Load Epic 3 only (~5k tokens) = 90% reduction - create-story for Epic 3: Load Epic 3 only (~5k tokens) = 90% reduction - story-context for Epic 3: Load Epic 3 only (~5k tokens) = 90% reduction ## Breaking Changes None - fully backward compatible. Workflows work with existing whole documents. ## Files Changed **Workflows Updated (25 files):** - 7 Phase 1-3 workflows: Added full load sharding support - 5 Phase 4 workflows: Added selective load sharding support - 1 retrospective workflow: Complete overhaul with sharding support **Documentation (5 files):** - Created: document-sharding-guide.md - Updated: README.md, docs/index.md, BMM workflows README, BMB workflow-creation-guide - Removed: Old conversion report (obsolete) ## Future Extensibility - BMB workflows now aware of sharding patterns - Custom modules can easily implement sharding support - Standard patterns documented for consistency - No need to explain concept in future development
2025-11-02 00:13:33 -05:00
## 📚 Input Document Discovery
This workflow may reference: product brief, research documents, or brownfield project documentation.
**Discovery Process** (execute for each referenced document):
1. **Search for whole document first** - Use fuzzy file matching to find the complete document
2. **Check for sharded version** - If whole document not found, look for `{doc-name}/index.md`
3. **If sharded version found**:
- Read `index.md` to understand the document structure
- Read ALL section files listed in the index
- Treat the combined content as if it were a single document
4. **Brownfield projects**: The `document-project` workflow always creates `{output_folder}/docs/index.md`
**Priority**: If both whole and sharded versions exist, use the whole document.
**Fuzzy matching**: Be flexible with document names - users may use variations in naming conventions.
<step n="0" goal="Validate workflow readiness" tag="workflow-status">
<action>Check if {output_folder}/bmm-workflow-status.yaml exists</action>
<check if="status file not found">
<output>No workflow status file found. Tech-spec workflow can run standalone or as part of BMM workflow path.</output>
<output>**Recommended:** Run `workflow-init` first for project context tracking and workflow sequencing.</output>
<ask>Continue in standalone mode or exit to run workflow-init? (continue/exit)</ask>
<check if="continue">
<action>Set standalone_mode = true</action>
</check>
<check if="exit">
<action>Exit workflow</action>
</check>
2025-10-15 23:10:33 -05:00
</check>
<check if="status file found">
<action>Load the FULL file: {output_folder}/bmm-workflow-status.yaml</action>
<action>Parse workflow_status section</action>
<action>Check status of "tech-spec" workflow</action>
<action>Get project_level from YAML metadata</action>
<action>Find first non-completed workflow (next expected workflow)</action>
2025-10-15 23:10:33 -05:00
2025-10-17 16:44:06 -05:00
<check if="project_level >= 2">
<output>**Incorrect Workflow for Level {{project_level}}**
2025-10-17 16:44:06 -05:00
Tech-spec is for Level 0-1 projects. Level 2-4 should use PRD workflow.
2025-10-15 23:10:33 -05:00
2025-10-17 16:44:06 -05:00
**Correct workflow:** `prd` (PM agent)
</output>
<action>Exit and redirect to prd</action>
</check>
2025-10-15 23:10:33 -05:00
<check if="tech-spec status is file path (already completed)">
<output>⚠️ Tech-spec already completed: {{tech-spec status}}</output>
<ask>Re-running will overwrite the existing tech-spec. Continue? (y/n)</ask>
<check if="n">
<output>Exiting. Use workflow-status to see your next step.</output>
<action>Exit workflow</action>
</check>
</check>
2025-10-15 23:10:33 -05:00
<check if="tech-spec is not the next expected workflow">
<output>⚠️ Next expected workflow: {{next_workflow}}. Tech-spec is out of sequence.</output>
<ask>Continue with tech-spec anyway? (y/n)</ask>
<check if="n">
<output>Exiting. Run {{next_workflow}} instead.</output>
<action>Exit workflow</action>
</check>
2025-10-17 16:44:06 -05:00
</check>
<action>Set standalone_mode = false</action>
2025-10-15 23:10:33 -05:00
</check>
2025-10-17 16:44:06 -05:00
</step>
<step n="1" goal="Confirm project scope and update tracking">
<action>Use {{project_level}} from status data</action>
2025-10-17 16:44:06 -05:00
<action>Update Workflow Status:</action>
<template-output file="{{status_file_path}}">current_workflow</template-output>
<check if="project_level == 0">
2025-10-17 16:44:06 -05:00
<action>Set to: "tech-spec (Level 0 - generating tech spec)"</action>
</check>
<check if="project_level == 1">
2025-10-17 16:44:06 -05:00
<action>Set to: "tech-spec (Level 1 - generating tech spec)"</action>
</check>
2025-10-17 16:44:06 -05:00
<template-output file="{{status_file_path}}">progress_percentage</template-output>
<action>Set to: 20%</action>
<action>Save {{status_file_path}}</action>
<check if="project_level == 0">
<action>Confirm Level 0 - Single atomic change</action>
<ask>Please describe the specific change/fix you need to implement:</ask>
</check>
<check if="project_level == 1">
<action>Confirm Level 1 - Coherent feature</action>
<ask>Please describe the feature you need to implement:</ask>
</check>
</step>
<step n="2" goal="Generate DEFINITIVE tech spec">
<critical>Generate tech-spec.md - this is the TECHNICAL SOURCE OF TRUTH</critical>
<critical>ALL TECHNICAL DECISIONS MUST BE DEFINITIVE - NO AMBIGUITY ALLOWED</critical>
2025-10-17 16:44:06 -05:00
<action>Update progress:</action>
<template-output file="{{status_file_path}}">progress_percentage</template-output>
<action>Set to: 40%</action>
<action>Save {{status_file_path}}</action>
2025-10-15 21:17:09 -05:00
<action>Initialize and write out tech-spec.md using tech_spec_template</action>
<critical>DEFINITIVE DECISIONS REQUIRED:</critical>
**BAD Examples (NEVER DO THIS):**
- "Python 2 or 3" ❌
- "Use a logger like pino or winston" ❌
**GOOD Examples (ALWAYS DO THIS):**
- "Python 3.11" ✅
- "winston v3.8.2 for logging" ✅
**Source Tree Structure**: EXACT file changes needed
<template-output file="tech-spec.md">source_tree</template-output>
**Technical Approach**: SPECIFIC implementation for the change
<template-output file="tech-spec.md">technical_approach</template-output>
**Implementation Stack**: DEFINITIVE tools and versions
<template-output file="tech-spec.md">implementation_stack</template-output>
**Technical Details**: PRECISE change details
<template-output file="tech-spec.md">technical_details</template-output>
**Testing Approach**: How to verify the change
<template-output file="tech-spec.md">testing_approach</template-output>
**Deployment Strategy**: How to deploy the change
<template-output file="tech-spec.md">deployment_strategy</template-output>
<invoke-task halt="true">{project-root}/bmad/core/tasks/adv-elicit.xml</invoke-task>
</step>
<step n="3" goal="Validate cohesion" optional="true">
<action>Offer to run cohesion validation</action>
<ask>Tech-spec complete! Before proceeding to implementation, would you like to validate project cohesion?
**Cohesion Validation** checks:
- Tech spec completeness and definitiveness
- Feature sequencing and dependencies
- External dependencies properly planned
- User/agent responsibilities clear
- Greenfield/brownfield-specific considerations
Run cohesion validation? (y/n)</ask>
<check if="yes">
<action>Load {installed_path}/checklist.md</action>
<action>Review tech-spec.md against "Cohesion Validation (All Levels)" section</action>
<action>Focus on Section A (Tech Spec), Section D (Feature Sequencing)</action>
<action>Apply Section B (Greenfield) or Section C (Brownfield) based on field_type</action>
<action>Generate validation report with findings</action>
</check>
</step>
<step n="4" goal="Generate user stories based on project level">
2025-10-17 16:44:06 -05:00
<action>Use {{project_level}} from status data</action>
<check if="project_level == 0">
<action>Invoke instructions-level0-story.md to generate single user story</action>
<action>Story will be saved to user-story.md</action>
<action>Story links to tech-spec.md for technical implementation details</action>
</check>
<check if="project_level == 1">
<action>Invoke instructions-level1-stories.md to generate epic and stories</action>
2025-10-14 20:20:55 -05:00
<action>Epic and stories will be saved to epics.md
<action>Stories link to tech-spec.md implementation tasks</action>
</check>
</step>
<step n="5" goal="Finalize and determine next steps">
<action>Confirm tech-spec is complete and definitive</action>
<check if="project_level == 0">
<action>Confirm user-story.md generated successfully</action>
</check>
<check if="project_level == 1">
2025-10-14 20:20:55 -05:00
<action>Confirm epics.md generated successfully</action>
</check>
## Summary
<check if="project_level == 0">
- **Level 0 Output**: tech-spec.md + user-story.md
- **No PRD required**
- **Direct to implementation with story tracking**
</check>
<check if="project_level == 1">
2025-10-14 20:20:55 -05:00
- **Level 1 Output**: tech-spec.md + epics.md
- **No PRD required**
- **Ready for sprint planning with epic/story breakdown**
</check>
## Next Steps
<check if="standalone_mode != true">
<action>Load the FULL file: {output_folder}/bmm-workflow-status.yaml</action>
<action>Find workflow_status key "tech-spec"</action>
<critical>ONLY write the file path as the status value - no other text, notes, or metadata</critical>
<action>Update workflow_status["tech-spec"] = "{output_folder}/bmm-tech-spec-{{date}}.md"</action>
<action>Save file, preserving ALL comments and structure including STATUS DEFINITIONS</action>
<action>Find first non-completed workflow in workflow_status (next workflow to do)</action>
<action>Determine next agent from path file based on next workflow</action>
</check>
<output>**✅ Tech-Spec Complete, {user_name}!**
**Deliverables Created:**
<check if="project_level == 0">
- ✅ tech-spec.md - Technical specification
- ✅ user-story.md - Single user story
</check>
<check if="project_level == 1">
- ✅ tech-spec.md - Technical specification
- ✅ epics.md - Epic and story breakdown
</check>
**Next Steps:**
- **Next required:** {{next_workflow}} ({{next_agent}} agent)
- **Optional:** Create test plan or document UI changes if applicable
Check status anytime with: `workflow-status`
</output>
</step>
</workflow>