# Create Flowchart - Workflow Instructions
```xml
The workflow execution engine is governed by: {project_root}/.bmad/core/tasks/workflow.xml
You MUST have already loaded and processed: {installed_path}/workflow.yaml
This workflow creates a flowchart visualization in Excalidraw format for processes, pipelines, or logic flows.
Before asking any questions, analyze what the user has already told you
Review the user's initial request and conversation history
Extract any mentioned: flowchart type, complexity, decision points, save location
Summarize your understanding
Skip directly to Step 4 (Plan Flowchart Layout)
Note what you already know
Only ask about missing information in Step 1
Proceed with full elicitation in Step 1
Ask Question 1: "What type of process flow do you need to visualize?"
Present numbered options:
1. Business Process Flow - Document business workflows, approval processes, or operational procedures
2. Algorithm/Logic Flow - Visualize code logic, decision trees, or computational processes
3. User Journey Flow - Map user interactions, navigation paths, or experience flows
4. Data Processing Pipeline - Show data transformation, ETL processes, or processing stages
5. Other - Describe your specific flowchart needs
WAIT for user selection (1-5)
Ask Question 2: "How many main steps are in this flow?"
Present numbered options:
1. Simple (3-5 steps) - Quick process with few decision points
2. Medium (6-10 steps) - Standard workflow with some branching
3. Complex (11-20 steps) - Detailed process with multiple decision points
4. Very Complex (20+ steps) - Comprehensive workflow requiring careful layout
WAIT for user selection (1-4)
Store selection in {{complexity}}
Ask Question 3: "Does your flow include decision points (yes/no branches)?"
Present numbered options:
1. No decisions - Linear flow from start to end
2. Few decisions (1-2) - Simple branching with yes/no paths
3. Multiple decisions (3-5) - Several conditional branches
4. Complex decisions (6+) - Extensive branching logic
WAIT for user selection (1-4)
Store selection in {{decision_points}}
Ask Question 4: "Where should the flowchart be saved?"
Present numbered options:
1. Default location - docs/flowcharts/[auto-generated-name].excalidraw
2. Custom path - Specify your own file path
3. Project root - Save in main project directory
4. Specific folder - Choose from existing folders
WAIT for user selection (1-4)
Ask for specific path
WAIT for user input
Store final path in {{default_output_file}}
Check if theme.json exists at output location
Ask: "Found existing theme. Use it? (yes/no)"
WAIT for user response
Load and use existing theme
Skip to Step 4
Proceed to Step 3
Proceed to Step 3
Ask: "Let's create a theme for your flowchart. Choose a color scheme:"
Present numbered options:
1. Professional Blue
- Primary Fill: #e3f2fd (light blue)
- Accent/Border: #1976d2 (blue)
- Decision: #fff3e0 (light orange)
- Text: #1e1e1e (dark gray)
2. Success Green
- Primary Fill: #e8f5e9 (light green)
- Accent/Border: #388e3c (green)
- Decision: #fff9c4 (light yellow)
- Text: #1e1e1e (dark gray)
3. Neutral Gray
- Primary Fill: #f5f5f5 (light gray)
- Accent/Border: #616161 (gray)
- Decision: #e0e0e0 (medium gray)
- Text: #1e1e1e (dark gray)
4. Warm Orange
- Primary Fill: #fff3e0 (light orange)
- Accent/Border: #f57c00 (orange)
- Decision: #ffe0b2 (peach)
- Text: #1e1e1e (dark gray)
5. Custom Colors - Define your own color palette
WAIT for user selection (1-5)
Store selection in {{theme_choice}}
Ask: "Primary fill color (hex code)?"
WAIT for user input
Store in {{custom_colors.primary_fill}}
Ask: "Accent/border color (hex code)?"
WAIT for user input
Store in {{custom_colors.accent}}
Ask: "Decision color (hex code)?"
WAIT for user input
Store in {{custom_colors.decision}}
Create theme.json with selected colors
Show theme preview with all colors
Ask: "Theme looks good?"
Present numbered options:
1. Yes, use this theme - Proceed with theme
2. No, adjust colors - Modify color selections
3. Start over - Choose different preset
WAIT for selection (1-3)
Repeat Step 3
List all steps and decision points based on gathered requirements
Show user the planned structure
Ask: "Structure looks correct? (yes/no)"
WAIT for user response
Adjust structure based on feedback
Repeat this step
Load {{templates}} file
Extract `flowchart` section from YAML
Load {{library}} file
Load theme.json and merge colors with template
Load {{helpers}} for element creation guidelines
Follow guidelines from {{helpers}} for proper element creation
Build ONE section at a time following these rules:
For Each Shape with Label:
1. Generate unique IDs (shape-id, text-id, group-id)
2. Create shape with groupIds: [group-id]
3. Calculate text width: (text.length × fontSize × 0.6) + 20, round to nearest 10
4. Create text element with:
- containerId: shape-id
- groupIds: [group-id] (SAME as shape)
- textAlign: "center"
- verticalAlign: "middle"
- width: calculated width
5. Add boundElements to shape referencing text
For Each Arrow:
1. Determine arrow type needed:
- Straight: For forward flow (left-to-right, top-to-bottom)
- Elbow: For upward flow, backward flow, or complex routing
2. Create arrow with startBinding and endBinding
3. Set startBinding.elementId to source shape ID
4. Set endBinding.elementId to target shape ID
5. Set gap: 10 for both bindings
6. If elbow arrow, add intermediate points for direction changes
7. Update boundElements on both connected shapes
Alignment:
- Snap all x, y to 20px grid
- Align shapes vertically (same x for vertical flow)
- Space elements: 60px between shapes
Build Order:
1. Start point (circle) with label
2. Each process step (rectangle) with label
3. Each decision point (diamond) with label
4. End point (circle) with label
5. Connect all with bound arrows
Strip unused elements and elements with isDeleted: true
Save to {{default_output_file}}
NEVER delete the file if validation fails - always fix syntax errors
Run: node -e "JSON.parse(require('fs').readFileSync('{{default_output_file}}', 'utf8')); console.log('✓ Valid JSON')"
Read the error message carefully - it shows the syntax error and position
Open the file and navigate to the error location
Fix the syntax error (add missing comma, bracket, or quote as indicated)
Save the file
Re-run validation with the same command
Repeat until validation passes
Once validation passes, confirm with user: "Flowchart created at {{default_output_file}}. Open to view?"
Validate against checklist at {{validation}} using {.bmad}/core/tasks/validate-workflow.xml
```