# Create Data Flow Diagram - 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 data flow diagrams (DFD) in Excalidraw format.
Review user's request and extract: DFD level, processes, data stores, external entities
Skip to Step 4
Ask: "What level of DFD do you need?"
Present options:
1. Context Diagram (Level 0) - Single process showing system boundaries
2. Level 1 DFD - Major processes and data flows
3. Level 2 DFD - Detailed sub-processes
4. Custom - Specify your requirements
WAIT for selection
Ask: "Describe the processes, data stores, and external entities in your system"
WAIT for user description
Summarize what will be included and confirm with user
Check for existing theme.json, ask to use if exists
Ask: "Choose a DFD color scheme:"
Present numbered options:
1. Standard DFD
- Process: #e3f2fd (light blue)
- Data Store: #e8f5e9 (light green)
- External Entity: #f3e5f5 (light purple)
- Border: #1976d2 (blue)
2. Colorful DFD
- Process: #fff9c4 (light yellow)
- Data Store: #c5e1a5 (light lime)
- External Entity: #ffccbc (light coral)
- Border: #f57c00 (orange)
3. Minimal DFD
- Process: #f5f5f5 (light gray)
- Data Store: #eeeeee (gray)
- External Entity: #e0e0e0 (medium gray)
- Border: #616161 (dark gray)
4. Custom - Define your own colors
WAIT for selection
Create theme.json based on selection
List all processes with numbers (1.0, 2.0, etc.)
List all data stores (D1, D2, etc.)
List all external entities
Map all data flows with labels
Show planned structure, confirm with user
Load {{templates}} and extract `dataflow` section
Load {{library}}
Load theme.json
Load {{helpers}}
Follow standard DFD notation from {{helpers}}
Build Order:
1. External entities (rectangles, bold border)
2. Processes (circles/ellipses with numbers)
3. Data stores (parallel lines or rectangles)
4. Data flows (labeled arrows)
DFD Rules:
- Processes: Numbered (1.0, 2.0), verb phrases
- Data stores: Named (D1, D2), noun phrases
- External entities: Named, noun phrases
- Data flows: Labeled with data names, arrows show direction
- No direct flow between external entities
- No direct flow between data stores
Layout:
- External entities at edges
- Processes in center
- Data stores between processes
- Minimize crossing flows
- Left-to-right or top-to-bottom flow
Verify DFD rules compliance
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
Validate against {{validation}}
```