2025-10-16 21:50:50 -05:00
# Audit Workflow - Workflow Quality Audit Instructions
< critical > The workflow execution engine is governed by: {project-root}/bmad/core/tasks/workflow.xml< / critical >
< critical > You MUST have already loaded and processed: {project-root}/bmad/bmb/workflows/audit-workflow/workflow.yaml< / critical >
< workflow >
2025-10-28 12:47:45 -05:00
< step n = "1" goal = "Load and analyze target workflow" >
< ask > What is the path to the workflow you want to audit? (provide path to workflow.yaml or workflow folder)< / ask >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Load the workflow.yaml file from the provided path< / action >
< action > Identify the workflow type (document, action, interactive, autonomous, meta)< / action >
< action > List all associated files:< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- instructions.md (required for most workflows)
- template.md (if document workflow)
- checklist.md (if validation exists)
- Any data files referenced in yaml
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Load all discovered files< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
Display summary:
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Workflow name and description
- Type of workflow
- Files present
- Module assignment
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< / step >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< step n = "2" goal = "Validate standard config block" >
< action > Check workflow.yaml for the standard config block:< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Required variables:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- `config_source: "{project-root}/bmad/[module]/config.yaml"`
- `output_folder: "{config_source}:output_folder"`
- `user_name: "{config_source}:user_name"`
- `communication_language: "{config_source}:communication_language"`
- `date: system-generated`
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Validate each variable:< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Config Source Check:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- [ ] `config_source` is defined
- [ ] Points to correct module config path
- [ ] Uses {project-root} variable
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Standard Variables Check:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- [ ] `output_folder` pulls from config_source
- [ ] `user_name` pulls from config_source
- [ ] `communication_language` pulls from config_source
- [ ] `date` is set to system-generated
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Record any missing or incorrect config variables< / action >
< template-output > config_issues< / template-output >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action if = "config issues found" > Add to issues list with severity: CRITICAL< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< / step >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< step n = "3" goal = "Analyze YAML/Instruction/Template alignment" >
< action > Extract all variables defined in workflow.yaml (excluding standard config block)< / action >
< action > Scan instructions.md for variable usage: {variable_name} pattern< / action >
< action > Scan template.md for variable usage: {{variable_name}} pattern (if exists)< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Cross-reference analysis:< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**For each yaml variable:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
1. Is it used in instructions.md? (mark as INSTRUCTION_USED)
2. Is it used in template.md? (mark as TEMPLATE_USED)
3. Is it neither? (mark as UNUSED_BLOAT)
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Special cases to ignore:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Standard config variables (config_source, output_folder, user_name, communication_language, date)
- Workflow metadata (name, description, author)
- Path variables (installed_path, template, instructions, validation)
- Web bundle configuration (web_bundle block itself)
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Identify unused yaml fields (bloat)< / action >
< action > Identify hardcoded values in instructions that should be variables< / action >
< template-output > alignment_issues< / template-output >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action if = "unused variables found" > Add to issues list with severity: BLOAT< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< / step >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< step n = "4" goal = "Config variable usage audit" >
< action > Analyze instructions.md for proper config variable usage:< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Communication Language Check:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Search for phrases like "communicate in {communication_language}"
- Check if greetings/responses use language-aware patterns
- Verify NO usage of {{communication_language}} in template headers
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**User Name Check:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Look for user addressing patterns using {user_name}
- Check if summaries or greetings personalize with {user_name}
- Verify optional usage in template metadata (not required)
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Output Folder Check:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Search for file write operations
- Verify all outputs go to {output_folder} or subdirectories
- Check for hardcoded paths like "/output/" or "/generated/"
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Date Usage Check:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Verify date is available for agent date awareness
- Check optional usage in template metadata
- Ensure no confusion between date and model training cutoff
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Nested Tag Reference Check:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Search for XML tag references within tags (e.g., `<action>Scan for <action> tags</action>` )
- Identify patterns like: `<tag-name> tags` , `<tag-name> calls` , `<tag-name>content</tag-name>` within content
- Common problematic tags to check: action, ask, check, template-output, invoke-workflow, goto
- Flag any instances where angle brackets appear in content describing tags
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Best Practice:** Use descriptive text without brackets (e.g., "action tags" instead of "< action > tags")
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Rationale:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Prevents XML parsing ambiguity
- Improves readability for humans and LLMs
- LLMs understand "action tags" = `<action>` tags from context
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Conditional Execution Antipattern Check:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Scan for self-closing check tags: `<check>condition text</check>` (invalid antipattern)
- Detect pattern: check tag on one line, followed by action/ask/goto tags (indicates incorrect nesting)
- Flag sequences like: `<check>If X:</check>` followed by `<action>do Y</action>`
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Correct Patterns:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Single conditional: `<action if="condition">Do something</action>`
- Multiple actions: `<check if="condition">` followed by nested actions with closing `</check>` tag
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Antipattern Example (WRONG):**
```xml
< check > If condition met:< / check >
< action > Do something< / action >
```
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Correct Example:**
```xml
< check if = "condition met" >
< action > Do something< / action >
< action > Do something else< / action >
< / check >
```
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Or for single action:**
```xml
< action if = "condition met" > Do something< / action >
```
2025-10-16 21:50:50 -05:00
2025-11-04 21:16:52 -06:00
< action > Scan instructions.md for nested tag references using pattern: < (action|ask|check|template-output|invoke-workflow|invoke-task|goto|step)> within text content< / action >
2025-10-28 12:47:45 -05:00
< action > Record any instances of nested tag references with line numbers< / action >
< action > Scan instructions.md for conditional execution antipattern: self-closing check tags< / action >
< action > Detect pattern: `<check>.*</check>` on single line (self-closing check)</ action >
< action > Record any antipattern instances with line numbers and suggest corrections< / action >
< action > Record any improper config variable usage< / action >
< template-output > config_usage_issues< / template-output >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action if = "config usage issues found" > Add to issues list with severity: IMPORTANT< / action >
< action if = "nested tag references found" > Add to issues list with severity: CLARITY (recommend using descriptive text without angle brackets)< / action >
< action if = "conditional antipattern found" > Add to issues list with severity: CRITICAL (invalid XML structure - must use action if="" or proper check wrapper)< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< / step >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< step n = "5" goal = "Web bundle validation" optional = "true" >
< check if = "workflow.yaml contains web_bundle section" >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Validate web_bundle structure:< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Path Validation:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- [ ] All paths use bmad/-relative format (NOT {project-root})
- [ ] No {config_source} variables in web_bundle section
- [ ] Paths match actual file locations
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Completeness Check:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- [ ] instructions file listed in web_bundle_files
- [ ] template file listed (if document workflow)
- [ ] validation/checklist file listed (if exists)
- [ ] All data files referenced in yaml listed
- [ ] All files referenced in instructions listed
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Workflow Dependency Scan:**
< action > Scan instructions.md for invoke-workflow tags< / action >
< action > Extract workflow paths from invocations< / action >
< action > Verify each called workflow.yaml is in web_bundle_files< / action >
< action > **CRITICAL**: Check if existing_workflows field is present when workflows are invoked< / action >
< action > If invoke-workflow calls exist, existing_workflows MUST map workflow variables to paths< / action >
< action > Example: If instructions use {core_brainstorming}, web_bundle needs: existing_workflows: - core_brainstorming: "bmad/core/workflows/brainstorming/workflow.yaml"< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**File Reference Scan:**
< action > Scan instructions.md for file references in action tags< / action >
< action > Check for CSV, JSON, YAML, MD files referenced< / action >
< action > Verify all referenced files are in web_bundle_files< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Record any missing files or incorrect paths< / action >
< template-output > web_bundle_issues< / template-output >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action if = "web_bundle issues found" > Add to issues list with severity: CRITICAL< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action if = "no web_bundle section exists" > Note: "No web_bundle configured (may be intentional for local-only workflows)"< / action >
< / check >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< / step >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< step n = "6" goal = "Bloat detection" >
< action > Identify bloat patterns:< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Unused YAML Fields:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Variables defined but not used in instructions OR template
- Duplicate fields between top-level and web_bundle section
- Commented-out variables that should be removed
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Hardcoded Values:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- File paths that should use {output_folder}
- Generic greetings that should use {user_name}
- Language-specific text that should use {communication_language}
- Static dates that should use {date}
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**Redundant Configuration:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Variables that duplicate web_bundle fields
- Metadata repeated across sections
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Calculate bloat metrics:< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- Total yaml fields: {{total_yaml_fields}}
- Used fields: {{used_fields}}
- Unused fields: {{unused_fields}}
- Bloat percentage: {{bloat_percentage}}%
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Record all bloat items with recommendations< / action >
< template-output > bloat_items< / template-output >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action if = "bloat detected" > Add to issues list with severity: CLEANUP< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< / step >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< step n = "7" goal = "Template variable mapping" if = "workflow_type == 'document'" >
< action > Extract all template variables from template.md: {{variable_name}} pattern< / action >
< action > Scan instructions.md for corresponding template-output tags< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Cross-reference mapping:< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**For each template variable:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
1. Is there a matching template-output tag? (mark as MAPPED)
2. Is it a standard config variable? (mark as CONFIG_VAR - optional)
3. Is it unmapped? (mark as MISSING_OUTPUT)
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
**For each template-output tag:**
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
1. Is there a matching template variable? (mark as USED)
2. Is it orphaned? (mark as UNUSED_OUTPUT)
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Verify variable naming conventions:< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
- [ ] All template variables use snake_case
- [ ] Variable names are descriptive (not abbreviated)
- [ ] Standard config variables properly formatted
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action > Record any mapping issues< / action >
< template-output > template_issues< / template-output >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< action if = "template issues found" > Add to issues list with severity: IMPORTANT< / action >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< / step >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< step n = "8" goal = "Generate comprehensive audit report" >
< action > Compile all findings and calculate summary metrics< / action >
< action > Generate executive summary based on issue counts and severity levels< / action >
< template-output > workflow_type< / template-output >
< template-output > overall_status< / template-output >
< template-output > critical_count< / template-output >
< template-output > important_count< / template-output >
< template-output > cleanup_count< / template-output >
< action > Generate status summaries for each audit section< / action >
< template-output > config_status< / template-output >
< template-output > total_variables< / template-output >
< template-output > instruction_usage_count< / template-output >
< template-output > template_usage_count< / template-output >
< template-output > bloat_count< / template-output >
< action > Generate config variable usage status indicators< / action >
< template-output > comm_lang_status< / template-output >
< template-output > user_name_status< / template-output >
< template-output > output_folder_status< / template-output >
< template-output > date_status< / template-output >
< template-output > nested_tag_count< / template-output >
< action > Generate web bundle metrics< / action >
< template-output > web_bundle_exists< / template-output >
< template-output > web_bundle_file_count< / template-output >
< template-output > missing_files_count< / template-output >
< action > Generate bloat metrics< / action >
< template-output > bloat_percentage< / template-output >
< template-output > cleanup_potential< / template-output >
< action > Generate template mapping metrics< / action >
< template-output > template_var_count< / template-output >
< template-output > mapped_count< / template-output >
< template-output > missing_mapping_count< / template-output >
< action > Compile prioritized recommendations by severity< / action >
< template-output > critical_recommendations< / template-output >
< template-output > important_recommendations< / template-output >
< template-output > cleanup_recommendations< / template-output >
< action > Display summary to {user_name} in {communication_language}< / action >
< action > Provide path to full audit report: {output_folder}/audit-report-{{workflow_name}}-{{date}}.md< / action >
< ask > Would you like to:
- View the full audit report
- Fix issues automatically (invoke edit-workflow)
- Audit another workflow
- Exit
< / ask >
2025-10-16 21:50:50 -05:00
2025-10-28 12:47:45 -05:00
< / step >
2025-10-16 21:50:50 -05:00
< / workflow >