Execute given workflow by loading its configuration, following instructions, and producing output
Always read COMPLETE files - NEVER use offset/limit when reading any workflow related files
Instructions are MANDATORY - either as file path, steps or embedded list in YAML, XML or markdown
Execute ALL steps in instructions IN EXACT ORDER
Save to template output file after EVERY "template-output" tag
NEVER delegate a step - YOU are responsible for every steps execution
Steps execute in exact numerical order (1, 2, 3...)
Optional steps: Ask user unless #yolo mode active
Template-output tags: Save content → Show user → Get approval before continuing
User must approve each major section before continuing UNLESS #yolo mode active
Read workflow.yaml from provided path
Load config_source (REQUIRED for all modules)
Load external config from config_source path
Resolve all {config_source}: references with values from config
Resolve system variables (date:system-generated) and paths ({project-root}, {installed_path})
Ask user for input of any variables that are still unknown
Instructions: Read COMPLETE file from path OR embedded list (REQUIRED)
If template path → Read COMPLETE template file
If validation path → Note path for later loading when needed
If template: false → Mark as action-workflow (else template-workflow)
Data files (csv, json) → Store paths only, load on-demand when instructions reference them
Resolve default_output_file path with all variables and {{date}}
Create output directory if doesn't exist
If template-workflow → Write template to output file with placeholders
If action-workflow → Skip file creation
For each step in instructions:
If optional="true" and NOT #yolo → Ask user to include
If if="condition" → Evaluate condition
If for-each="item" → Repeat step for each item
If repeat="n" → Repeat step n times
Process step instructions (markdown or XML tags)
Replace {{variables}} with values (ask user if unknown)
action xml tag → Perform the action
check if="condition" xml tag → Conditional block wrapping actions (requires closing </check>)
ask xml tag → Prompt user and WAIT for response
invoke-workflow xml tag → Execute another workflow with given inputs
invoke-task xml tag → Execute specified task
invoke-protocol name="protocol_name" xml tag → Execute reusable protocol from protocols section
goto step="x" → Jump to specified step
Generate content for this section
Save to file (Write first time, Edit subsequent)
Show checkpoint separator: ━━━━━━━━━━━━━━━━━━━━━━━
Display generated content
[a] Advanced Elicitation, [c] Continue, [p] Party-Mode, [y] YOLO the rest of this document only. WAIT for response.
Start the advanced elicitation workflow {project-root}/{bmad_folder}/core/tasks/advanced-elicitation.xml
Continue to next step
Start the party-mode workflow {project-root}/{bmad_folder}/core/workflows/party-mode/workflow.yaml
Enter #yolo mode for the rest of the workflow
If no special tags and NOT #yolo:
Continue to next step? (y/n/edit)
If checklist exists → Run validation
If template: false → Confirm actions completed
Else → Confirm document saved to output path
Report workflow completion
Full user interaction at all decision points
Skip all confirmations and elicitation, minimize prompts and try to produce all of the workflow automatically by
simulating the remaining discussions with an simulated expert user
step n="X" goal="..." - Define step with number and goal
optional="true" - Step can be skipped
if="condition" - Conditional execution
for-each="collection" - Iterate over items
repeat="n" - Repeat n times
action - Required action to perform
action if="condition" - Single conditional action (inline, no closing tag needed)
check if="condition">...</check> - Conditional block wrapping multiple items (closing tag required)
ask - Get user input (wait for response)
goto - Jump to another step
invoke-workflow - Call another workflow
invoke-task - Call a task
invoke-protocol - Execute a reusable protocol (e.g., discover_inputs)
One action with a condition
<action if="condition">Do something</action>
<action if="file exists">Load the file</action>
Cleaner and more concise for single items
Multiple actions/tags under same condition
<check if="condition">
<action>First action</action>
<action>Second action</action>
</check>
<check if="validation fails">
<action>Log error</action>
<goto step="1">Retry</goto>
</check>
Explicit scope boundaries prevent ambiguity
Else/alternative branches
<check if="condition A">...</check>
<check if="else">...</check>
Clear branching logic with explicit blocks
Intelligently load project files (whole or sharded) based on workflow's input_file_patterns configuration
Only execute if workflow.yaml contains input_file_patterns section
Read input_file_patterns from loaded workflow.yaml
For each pattern group (prd, architecture, epics, etc.), note the load_strategy if present
For each pattern in input_file_patterns:
Attempt glob match on 'whole' pattern (e.g., "{output_folder}/*prd*.md")
Load ALL matching files completely (no offset/limit)
Store content in variable: {pattern_name_content} (e.g., {prd_content})
Mark pattern as RESOLVED, skip to next pattern
Determine load_strategy from pattern config (defaults to FULL_LOAD if not specified)
Load ALL files in sharded directory - used for PRD, Architecture, UX, brownfield docs
Use glob pattern to find ALL .md files (e.g., "{output_folder}/*architecture*/*.md")
Load EVERY matching file completely
Concatenate content in logical order (index.md first if exists, then alphabetical)
Store in variable: {pattern_name_content}
Load specific shard using template variable - example: used for epics with {{epic_num}}
Check for template variables in sharded_single pattern (e.g., {{epic_num}})
If variable undefined, ask user for value OR infer from context
Resolve template to specific file path
Load that specific file
Store in variable: {pattern_name_content}
Load index.md, analyze structure and description of each doc in the index, then intelligently load relevant docs
DO NOT BE LAZY - use best judgment to load documents that might have relevant information, even if only a 5% chance
Load index.md from sharded directory
Parse table of contents, links, section headers
Analyze workflow's purpose and objective
Identify which linked/referenced documents are likely relevant
If workflow is about authentication and index shows "Auth Overview", "Payment Setup", "Deployment" → Load auth
docs, consider deployment docs, skip payment
Load all identified relevant documents
Store combined content in variable: {pattern_name_content}
When in doubt, LOAD IT - context is valuable, being thorough is better than missing critical info
Set {pattern_name_content} to empty string
Note in session: "No {pattern_name} files found" (not an error, just unavailable, offer use change to provide)
List all loaded content variables with file counts
✓ Loaded {prd_content} from 1 file: PRD.md
✓ Loaded {architecture_content} from 5 sharded files: architecture/index.md, architecture/system-design.md, ...
✓ Loaded {epics_content} from selective load: epics/epic-3.md
○ No ux_design files found
This gives workflow transparency into what context is available
<step n="0" goal="Discover and load project context">
<invoke-protocol name="discover_inputs" />
</step>
<step n="1" goal="Analyze requirements">
<action>Review {prd_content} for functional requirements</action>
<action>Cross-reference with {architecture_content} for technical constraints</action>
</step>
This is the complete workflow execution engine
You MUST Follow instructions exactly as written and maintain conversation context between steps
If confused, re-read this task, the workflow yaml, and any yaml indicated files