|
1 | 1 | --- |
2 | | -title: "Workflow Customization Guide" |
| 2 | +title: "Workflow Customization" |
3 | 3 | --- |
4 | 4 |
|
5 | | -Customize and optimize workflows with step replacement and hooks. |
| 5 | +Workflows support powerful customization patterns through tri-modal architecture, step replacement, and cross-mode integration. This enables workflows to adapt to your specific project needs while maintaining best practices. |
6 | 6 |
|
7 | | -## Status |
| 7 | +## Tri-Modal Workflow Structure |
8 | 8 |
|
9 | | -:::note[Coming Soon] |
10 | | -Workflow customization is an upcoming capability. This guide will be updated when the feature is available. |
| 9 | +Complex workflows use **tri-modal architecture** — separate flows for create, edit, and validate operations: |
| 10 | + |
| 11 | +```` |
| 12 | +workflow-name/ |
| 13 | +├── workflow.md # Entry point with mode routing |
| 14 | +├── data/ # SHARED standards and reference |
| 15 | +├── steps-c/ # Create (self-contained) |
| 16 | +│ ├── step-01-init.md |
| 17 | +│ └── step-N-complete.md |
| 18 | +├── steps-e/ # Edit (self-contained) |
| 19 | +│ ├── step-01-assess.md |
| 20 | +│ └── step-N-complete.md |
| 21 | +└── steps-v/ # Validate (self-contained) |
| 22 | + └── step-01-validate.md |
| 23 | +```` |
| 24 | + |
| 25 | +### Mode Responsibilities |
| 26 | + |
| 27 | +| Mode | Purpose | Key Patterns | |
| 28 | +|------|---------|--------------| |
| 29 | +| **Create** | Build new entities from scratch | Step-00-conversion for non-compliant input | |
| 30 | +| **Edit** | Modify existing compliant entities | Assess compliance first, route to conversion if needed | |
| 31 | +| **Validate** | Standalone validation against standards | Auto-proceeds through checks, generates report | |
| 32 | + |
| 33 | +**Key principle:** Each mode is self-contained with no shared step files. The `data/` folder is shared to prevent drift. |
| 34 | + |
| 35 | +:::note[When to Use Tri-Modal] |
| 36 | +Use tri-modal for complex workflows requiring quality assurance, long-term maintenance, or non-compliant input handling. Use create-only for simple experimental workflows. |
11 | 37 | ::: |
12 | 38 |
|
13 | | -## What to Expect |
| 39 | +## Cross-Mode Integration |
| 40 | + |
| 41 | +Workflows support seamless integration between modes: |
| 42 | + |
| 43 | +### Edit to Create (Non-Compliant Detection) |
| 44 | + |
| 45 | +When editing detects a non-compliant workflow: |
| 46 | + |
| 47 | +```yaml |
| 48 | +Check workflow compliance: |
| 49 | + - Compliant → Continue to edit steps |
| 50 | + - Non-compliant → Offer conversion |
| 51 | + - IF user accepts: Load steps-c/step-00-conversion.md |
| 52 | +``` |
| 53 | +
|
| 54 | +### Create/Edit to Validation |
| 55 | +
|
| 56 | +After creation or editing, workflows can automatically invoke validation: |
| 57 | +
|
| 58 | +```yaml |
| 59 | +Offer: "Run validation?" |
| 60 | + - IF yes: Load ../steps-v/step-01-validate.md |
| 61 | + - Validation runs standalone, returns report |
| 62 | + - Resume with validation results |
| 63 | +``` |
| 64 | +
|
| 65 | +### Validation to Edit |
| 66 | +
|
| 67 | +Validation reports can be consumed by edit mode for fixes: |
| 68 | +
|
| 69 | +```yaml |
| 70 | +"Fix issues found?" |
| 71 | + - IF yes: Load steps-e/step-01-assess.md with validationReport path |
| 72 | +``` |
| 73 | +
|
| 74 | +## Workflow Conversion |
| 75 | +
|
| 76 | +Workflows can convert non-compliant input to BMad-compliant format through `step-00-conversion`: |
| 77 | + |
| 78 | +**Conversion process:** |
| 79 | +1. Load non-compliant workflow |
| 80 | +2. Extract essence and structure |
| 81 | +3. Create plan with `conversionFrom` metadata |
| 82 | +4. Build compliant workflow |
| 83 | +5. Verify coverage of original functionality |
| 84 | + |
| 85 | +**Coverage tracking:** |
| 86 | + |
| 87 | +```yaml |
| 88 | +# In create step-10-confirmation |
| 89 | +Check workflowPlan metadata: |
| 90 | + - IF conversionFrom exists: |
| 91 | + - Load original workflow |
| 92 | + - Compare each step/instruction |
| 93 | + - Report coverage percentage |
| 94 | + - ELSE (new workflow): |
| 95 | + - Validate all plan requirements implemented |
| 96 | +``` |
| 97 | + |
| 98 | +## Step Replacement and Extension |
| 99 | + |
| 100 | +### Adding Steps |
| 101 | + |
| 102 | +To add a step to an existing workflow: |
| 103 | + |
| 104 | +1. Create new step file: `step-XX-new-step.md` |
| 105 | +2. Update previous step's `nextStepFile` to load the new step |
| 106 | +3. Set the new step's `nextStepFile` to continue the sequence |
| 107 | +4. Validate with `[VW]` or `validate-workflow` |
| 108 | + |
| 109 | +### Replacing Steps |
| 110 | + |
| 111 | +To replace a step entirely: |
| 112 | + |
| 113 | +1. Create replacement step file with same or new name |
| 114 | +2. Update previous step's `nextStepFile` to load replacement |
| 115 | +3. Remove or archive old step file |
| 116 | +4. Validate the workflow |
| 117 | + |
| 118 | +### Extracting to Data Files |
| 119 | + |
| 120 | +When a step exceeds 200-250 lines, extract content to `/data/` files: |
| 121 | + |
| 122 | +**Good candidates for extraction:** |
| 123 | +- Domain-specific reference materials |
| 124 | +- Reusable patterns or examples |
| 125 | +- Configuration data |
| 126 | +- Large lookup tables |
| 127 | + |
| 128 | +## Menu Customization |
| 129 | + |
| 130 | +### Menu Patterns |
| 131 | + |
| 132 | +| Pattern | Use Case | Options | |
| 133 | +|---------|----------|---------| |
| 134 | +| **Standard A/P/C** | Collaborative content generation | Advanced, Party, Continue | |
| 135 | +| **C Only** | Data gathering, simple progression | Continue only | |
| 136 | +| **Branching** | User choice determines path | Custom letters (L/R/F) | |
| 137 | +| **Auto-proceed** | Init steps, validation sequences | No menu | |
| 138 | + |
| 139 | +### Custom Menu Options |
| 140 | + |
| 141 | +Workflows can define custom menu letters: |
| 142 | + |
| 143 | +```markdown |
| 144 | +Display: "**Select:** [L] Load Existing [N] Create New [C] Continue" |
| 145 | +
|
| 146 | +#### Menu Handling Logic: |
| 147 | +- IF L: Load existing document, then execute {stepForExisting} |
| 148 | +- IF N: Create new document, then execute {stepForNew} |
| 149 | +- IF C: Save content, check condition, load appropriate step |
| 150 | +``` |
| 151 | + |
| 152 | +## Template Customization |
| 153 | + |
| 154 | +### Template Types |
| 155 | + |
| 156 | +| Type | Description | Use Case | |
| 157 | +|------|-------------|----------| |
| 158 | +| **Free-form** | Minimal template, progressive append | Most workflows | |
| 159 | +| **Structured** | Single template with placeholders | Consistent formatting needed | |
| 160 | +| **Semi-structured** | Core sections + optional additions | Flexible but organized | |
| 161 | +| **Strict** | Multiple templates, exact definitions | Compliance, regulated industries | |
| 162 | + |
| 163 | +### Template Syntax |
| 164 | + |
| 165 | +```markdown |
| 166 | +{{variable}} # Handlebars style (preferred) |
| 167 | +[variable] # Bracket style (also supported) |
| 168 | +``` |
| 169 | + |
| 170 | +## Output Customization |
| 171 | + |
| 172 | +### Output Patterns |
| 173 | + |
| 174 | +**Plan-then-Build:** |
| 175 | + |
| 176 | +``` |
| 177 | +Step 1 → Creates plan.md |
| 178 | +Step 2 → Appends requirements |
| 179 | +Step 3 → Appends design |
| 180 | +Step 4 → Build step consumes plan |
| 181 | +``` |
| 182 | +
|
| 183 | +**Direct-to-Final:** |
| 184 | +
|
| 185 | +``` |
| 186 | +Step 1 → Creates final-doc.md |
| 187 | +Step 2 → Appends Section 1 |
| 188 | +Step 3 → Appends Section 2 |
| 189 | +Step 4 → Polish step optimizes entire document |
| 190 | +``` |
| 191 | +
|
| 192 | +### Final Polish Step |
| 193 | +
|
| 194 | +For free-form workflows, include a polish step that: |
| 195 | +1. Loads entire document |
| 196 | +2. Reviews for flow and coherence |
| 197 | +3. Reduces duplication |
| 198 | +4. Ensures proper headers |
| 199 | +5. Improves transitions |
14 | 200 |
|
15 | | -Workflow customization will allow you to: |
| 201 | +## Pattern Resources |
16 | 202 |
|
17 | | -- **Replace Steps** - Swap out specific workflow steps with custom implementations |
18 | | -- **Add Hooks** - Inject custom behavior before/after workflow steps |
19 | | -- **Extend Workflows** - Create new workflows based on existing ones |
20 | | -- **Override Behavior** - Customize workflow logic for your project's needs |
| 203 | +| Resource | Description | |
| 204 | +|----------|-------------| |
| 205 | +| [Workflow Patterns](/docs/explanation/workflow-patterns.md) | Step types and structure patterns | |
| 206 | +| [Workflow Schema](/docs/reference/workflow-schema.md) | Technical reference | |
| 207 | +| [Edit Agents and Workflows](/docs/how-to/edit-agents-and-workflows.md) | Step-by-step editing guide | |
0 commit comments