Create Diagram - Workflow Instructions
<critical>The workflow execution engine is governed by: {project_root}/.faos/core/tasks/workflow.xml</critical>
<critical>You MUST have already loaded and processed: {installed_path}/workflow.yaml</critical>
<critical>This workflow creates system architecture diagrams, ERDs, UML diagrams, or general technical diagrams in Excalidraw format.</critical>
<workflow>
<step n="0" goal="Contextual Analysis">
<action>Review user's request and extract: diagram type, components/entities, relationships, notation preferences</action>
<check if="ALL requirements clear"><action>Skip to Step 6</action></check>
<check if="SOME requirements clear"><action>Only ask about missing info in Steps 2-3</action></check>
</step>
<step n="1" goal="Assess Depth and Select Visual Pattern">
<action>Based on the user's request, determine the diagram depth level per {{helpers}} Depth Assessment:</action>
<action>Present assessment:
- Simple/Conceptual (10-20 elements): High-level overview, explain a concept
- Standard (20-40 elements): Document a system, show a process
- Comprehensive/Technical (40-80 elements): Detailed audit, implementation guide
</action>
<action>State your assessment: "This looks like a [depth] diagram because [reason]"</action>
<action>Select the best visual pattern from {{helpers}} Visual Pattern Library. For technical diagrams, common patterns are:
- pipeline: For request processing chains, data transformation flows
- tree: For class hierarchies, org structures, inheritance
- fan-out: For API gateways, event distribution, load balancing
- cluster: For microservice groups, technology stacks
- lines-as-structure: For sequence diagrams, dependency graphs
- side-by-side: For current vs proposed, option comparisons
</action>
<action>State: "I recommend the [pattern] pattern because it argues that [specific argument the diagram makes]"</action>
<action>Ask: "Does this depth level and visual pattern match your intent? (yes/adjust)"</action>
<action>WAIT for confirmation</action>
<check if="user says adjust">
<action>Revise depth and/or pattern based on feedback</action>
<action>Confirm revised choices</action>
</check>
</step>
<step n="2" goal="Identify Diagram Type" elicit="true">
<action>Ask: "What type of technical diagram do you need?"</action>
<action>Present options:
1. System Architecture
2. Entity-Relationship Diagram (ERD)
3. UML Class Diagram
4. UML Sequence Diagram
5. UML Use Case Diagram
6. Network Diagram
7. Other
</action>
<action>WAIT for selection</action>
</step>
<step n="3" goal="Gather Requirements" elicit="true">
<action>Ask: "Describe the components/entities and their relationships"</action>
<action>Ask: "What notation standard? (Standard/Simplified/Strict UML-ERD)"</action>
<action>WAIT for user input</action>
<action>Summarize what will be included and confirm with user</action>
</step>
<step n="4" goal="Check for Existing Theme" elicit="true">
<action>Check if theme.json exists at output location</action>
<check if="exists"><action>Ask to use it, load if yes, else proceed to Step 5</action></check>
<check if="not exists"><action>Proceed to Step 5</action></check>
</step>
<step n="5" goal="Create Theme" elicit="true">
<action>Ask: "Choose a color scheme for your diagram:"</action>
<action>Present numbered options:
1. Professional
- Component: #e3f2fd (light blue)
- Database: #e8f5e9 (light green)
- Service: #fff3e0 (light orange)
- Border: #1976d2 (blue)
2. Colorful
- Component: #e1bee7 (light purple)
- Database: #c5e1a5 (light lime)
- Service: #ffccbc (light coral)
- Border: #7b1fa2 (purple)
3. Minimal
- Component: #f5f5f5 (light gray)
- Database: #eeeeee (gray)
- Service: #e0e0e0 (medium gray)
- Border: #616161 (dark gray)
4. Custom - Define your own colors
</action>
<action>WAIT for selection</action>
<action>Create theme.json based on selection, including semantic color mapping per {{helpers}}</action>
<action>Show preview and confirm</action>
</step>
<step n="6" goal="Plan Diagram Structure">
<action>List all components/entities</action>
<action>Map all relationships</action>
<action>Apply the selected visual pattern to the layout plan</action>
<action>Show planned layout</action>
<action>Ask: "Structure looks correct? (yes/no)"</action>
<check if="no"><action>Adjust and repeat</action></check>
</step>
<step n="7" goal="Load Resources">
<action>Load {{templates}} and extract `diagram` section</action>
<action>Load visual_patterns from {{templates}} for the selected pattern</action>
<action>Load {{library}}</action>
<action>Load theme.json and merge with template</action>
<action>Load {{helpers}} for guidelines</action>
</step>
<step n="8" goal="Build Diagram Elements">
<critical>Apply the design philosophy from {{helpers}}: This diagram must ARGUE a point, not just DISPLAY components. Follow the selected visual pattern for layout.</critical>
<critical>Use descriptive string IDs per {{helpers}} ID conventions (e.g., "auth_service_rect" not "rect_1")</critical>
<critical>Prefer free-floating text for section labels, annotations, and callouts. Target less than 30% containerized text per {{helpers}} Text Strategy.</critical>
<substep>For Each Component:
- Generate descriptive string IDs per {{helpers}} ID conventions (e.g., auth_service_rect, auth_service_txt, auth_service_grp)
- Create shape with groupIds
- Calculate text width
- Create text with containerId and matching groupIds
- Add boundElements
- Apply semantic color based on the component's role (primary/secondary/accent) per {{helpers}}
</substep>
<substep>For Each Connection:
- Determine arrow type (straight/elbow)
- Create with startBinding and endBinding
- Update boundElements on both components
- Apply semantic color to arrows (success for happy path, warning for conditional, danger for error)
</substep>
<substep>Add Free-Floating Text:
- Section titles above each logical group
- Annotations near complex relationships
- Version or metadata notes in a corner
</substep>
<substep>Build Order by Type:
- Architecture: Services -> Databases -> Connections -> Labels -> Annotations
- ERD: Entities -> Attributes -> Relationships -> Cardinality -> Annotations
- UML Class: Classes -> Attributes -> Methods -> Relationships -> Notes
- UML Sequence: Actors -> Lifelines -> Messages -> Returns -> Notes
- UML Use Case: Actors -> Use Cases -> Relationships -> Notes
</substep>
<substep>Alignment:
- Snap to 20px grid
- Space: 40px between components, 60px between sections
- Follow the selected visual pattern's layout rules from {{templates}}
</substep>
<check if="planned element count exceeds 30">
<action>Switch to section-by-section generation per {{helpers}} Section-by-Section Generation Protocol</action>
<action>Identify logical sections based on diagram type (e.g., by service layer for architecture)</action>
<action>Generate each section separately, using namespaced seeds</action>
<action>After all sections: merge, validate cross-section arrows, verify boundElements</action>
</check>
<check if="depth is Comprehensive/Technical">
<action>Add evidence artifacts per {{helpers}} Evidence Artifacts guide</action>
<action>Embed real code/JSON/API shapes next to relevant components (max 5)</action>
</check>
</step>
<step n="9" goal="Optimize and Save">
<action>Strip unused elements and elements with isDeleted: true</action>
<action>Save to {{default_output_file}}</action>
</step>
<step n="10" goal="Validate JSON Syntax">
<critical>NEVER delete the file if validation fails - always fix syntax errors</critical>
<action>Run: node -e "JSON.parse(require('fs').readFileSync('{{default_output_file}}', 'utf8')); console.log('Valid JSON')"</action>
<check if="validation fails (exit code 1)">
<action>Read the error message carefully - it shows the syntax error and position</action>
<action>Open the file and navigate to the error location</action>
<action>Fix the syntax error (add missing comma, bracket, or quote as indicated)</action>
<action>Save the file</action>
<action>Re-run validation with the same command</action>
<action>Repeat until validation passes</action>
</check>
<action>Once validation passes, confirm: "Diagram created at {{default_output_file}}. Open to view?"</action>
</step>
<step n="11" goal="Visual Preview (Optional)" optional="true">
<action>Load {{render_validate}}</action>
<action>Run: python3 {{render_script}} {{default_output_file}}</action>
<check if="exit code is 2 (Playwright not installed)">
<action>Skip: "Playwright not available — skipping PNG preview. Diagram is still valid."</action>
</check>
<check if="exit code is 0">
<action>View the generated PNG file</action>
<action>Audit against design vision: Does the diagram ARGUE its point?</action>
<action>Check: overlapping text, misaligned arrows, spacing issues, color rendering</action>
<check if="issues found">
<action>Fix the JSON</action>
<action>Re-render (max 3 cycles)</action>
</check>
<action>Ask: "Keep the PNG preview file? (yes/no)"</action>
</check>
</step>
<step n="12" goal="Validate Content">
<invoke-task>Validate against {{validation}} using {faos}/core/tasks/validate-workflow.xml</invoke-task>
</step>
</workflow>
Quality Checklist
Create Diagram - Validation Checklist
Design Quality
Generation Quality
Element Structure
Layout and Alignment
Connections
Notation and Standards
Theme and Styling
Output Quality
1---2name: excalidraw-diagram3description: Create system architecture diagrams, ERDs, UML diagrams, or general technical diagrams in Excalidraw format.4---56# Create Diagram - Workflow Instructions78```xml9<critical>The workflow execution engine is governed by: {project_root}/.faos/core/tasks/workflow.xml</critical>10<critical>You MUST have already loaded and processed: {installed_path}/workflow.yaml</critical>11<critical>This workflow creates system architecture diagrams, ERDs, UML diagrams, or general technical diagrams in Excalidraw format.</critical>1213<workflow>1415 <step n="0" goal="Contextual Analysis">16 <action>Review user's request and extract: diagram type, components/entities, relationships, notation preferences</action>17 <check if="ALL requirements clear"><action>Skip to Step 6</action></check>18 <check if="SOME requirements clear"><action>Only ask about missing info in Steps 2-3</action></check>19 </step>2021 <step n="1" goal="Assess Depth and Select Visual Pattern">22 <action>Based on the user's request, determine the diagram depth level per {{helpers}} Depth Assessment:</action>23 <action>Present assessment:24 - Simple/Conceptual (10-20 elements): High-level overview, explain a concept25 - Standard (20-40 elements): Document a system, show a process26 - Comprehensive/Technical (40-80 elements): Detailed audit, implementation guide27 </action>28 <action>State your assessment: "This looks like a [depth] diagram because [reason]"</action>29 <action>Select the best visual pattern from {{helpers}} Visual Pattern Library. For technical diagrams, common patterns are:30 - pipeline: For request processing chains, data transformation flows31 - tree: For class hierarchies, org structures, inheritance32 - fan-out: For API gateways, event distribution, load balancing33 - cluster: For microservice groups, technology stacks34 - lines-as-structure: For sequence diagrams, dependency graphs35 - side-by-side: For current vs proposed, option comparisons36 </action>37 <action>State: "I recommend the [pattern] pattern because it argues that [specific argument the diagram makes]"</action>38 <action>Ask: "Does this depth level and visual pattern match your intent? (yes/adjust)"</action>39 <action>WAIT for confirmation</action>40 <check if="user says adjust">41 <action>Revise depth and/or pattern based on feedback</action>42 <action>Confirm revised choices</action>43 </check>44 </step>4546 <step n="2" goal="Identify Diagram Type" elicit="true">47 <action>Ask: "What type of technical diagram do you need?"</action>48 <action>Present options:49 1. System Architecture50 2. Entity-Relationship Diagram (ERD)51 3. UML Class Diagram52 4. UML Sequence Diagram53 5. UML Use Case Diagram54 6. Network Diagram55 7. Other56 </action>57 <action>WAIT for selection</action>58 </step>5960 <step n="3" goal="Gather Requirements" elicit="true">61 <action>Ask: "Describe the components/entities and their relationships"</action>62 <action>Ask: "What notation standard? (Standard/Simplified/Strict UML-ERD)"</action>63 <action>WAIT for user input</action>64 <action>Summarize what will be included and confirm with user</action>65 </step>6667 <step n="4" goal="Check for Existing Theme" elicit="true">68 <action>Check if theme.json exists at output location</action>69 <check if="exists"><action>Ask to use it, load if yes, else proceed to Step 5</action></check>70 <check if="not exists"><action>Proceed to Step 5</action></check>71 </step>7273 <step n="5" goal="Create Theme" elicit="true">74 <action>Ask: "Choose a color scheme for your diagram:"</action>75 <action>Present numbered options:76 1. Professional77 - Component: #e3f2fd (light blue)78 - Database: #e8f5e9 (light green)79 - Service: #fff3e0 (light orange)80 - Border: #1976d2 (blue)8182 2. Colorful83 - Component: #e1bee7 (light purple)84 - Database: #c5e1a5 (light lime)85 - Service: #ffccbc (light coral)86 - Border: #7b1fa2 (purple)8788 3. Minimal89 - Component: #f5f5f5 (light gray)90 - Database: #eeeeee (gray)91 - Service: #e0e0e0 (medium gray)92 - Border: #616161 (dark gray)9394 4. Custom - Define your own colors95 </action>96 <action>WAIT for selection</action>97 <action>Create theme.json based on selection, including semantic color mapping per {{helpers}}</action>98 <action>Show preview and confirm</action>99 </step>100101 <step n="6" goal="Plan Diagram Structure">102 <action>List all components/entities</action>103 <action>Map all relationships</action>104 <action>Apply the selected visual pattern to the layout plan</action>105 <action>Show planned layout</action>106 <action>Ask: "Structure looks correct? (yes/no)"</action>107 <check if="no"><action>Adjust and repeat</action></check>108 </step>109110 <step n="7" goal="Load Resources">111 <action>Load {{templates}} and extract `diagram` section</action>112 <action>Load visual_patterns from {{templates}} for the selected pattern</action>113 <action>Load {{library}}</action>114 <action>Load theme.json and merge with template</action>115 <action>Load {{helpers}} for guidelines</action>116 </step>117118 <step n="8" goal="Build Diagram Elements">119 <critical>Apply the design philosophy from {{helpers}}: This diagram must ARGUE a point, not just DISPLAY components. Follow the selected visual pattern for layout.</critical>120 <critical>Use descriptive string IDs per {{helpers}} ID conventions (e.g., "auth_service_rect" not "rect_1")</critical>121 <critical>Prefer free-floating text for section labels, annotations, and callouts. Target less than 30% containerized text per {{helpers}} Text Strategy.</critical>122123 <substep>For Each Component:124 - Generate descriptive string IDs per {{helpers}} ID conventions (e.g., auth_service_rect, auth_service_txt, auth_service_grp)125 - Create shape with groupIds126 - Calculate text width127 - Create text with containerId and matching groupIds128 - Add boundElements129 - Apply semantic color based on the component's role (primary/secondary/accent) per {{helpers}}130 </substep>131132 <substep>For Each Connection:133 - Determine arrow type (straight/elbow)134 - Create with startBinding and endBinding135 - Update boundElements on both components136 - Apply semantic color to arrows (success for happy path, warning for conditional, danger for error)137 </substep>138139 <substep>Add Free-Floating Text:140 - Section titles above each logical group141 - Annotations near complex relationships142 - Version or metadata notes in a corner143 </substep>144145 <substep>Build Order by Type:146 - Architecture: Services -> Databases -> Connections -> Labels -> Annotations147 - ERD: Entities -> Attributes -> Relationships -> Cardinality -> Annotations148 - UML Class: Classes -> Attributes -> Methods -> Relationships -> Notes149 - UML Sequence: Actors -> Lifelines -> Messages -> Returns -> Notes150 - UML Use Case: Actors -> Use Cases -> Relationships -> Notes151 </substep>152153 <substep>Alignment:154 - Snap to 20px grid155 - Space: 40px between components, 60px between sections156 - Follow the selected visual pattern's layout rules from {{templates}}157 </substep>158159 <check if="planned element count exceeds 30">160 <action>Switch to section-by-section generation per {{helpers}} Section-by-Section Generation Protocol</action>161 <action>Identify logical sections based on diagram type (e.g., by service layer for architecture)</action>162 <action>Generate each section separately, using namespaced seeds</action>163 <action>After all sections: merge, validate cross-section arrows, verify boundElements</action>164 </check>165166 <check if="depth is Comprehensive/Technical">167 <action>Add evidence artifacts per {{helpers}} Evidence Artifacts guide</action>168 <action>Embed real code/JSON/API shapes next to relevant components (max 5)</action>169 </check>170 </step>171172 <step n="9" goal="Optimize and Save">173 <action>Strip unused elements and elements with isDeleted: true</action>174 <action>Save to {{default_output_file}}</action>175 </step>176177 <step n="10" goal="Validate JSON Syntax">178 <critical>NEVER delete the file if validation fails - always fix syntax errors</critical>179 <action>Run: node -e "JSON.parse(require('fs').readFileSync('{{default_output_file}}', 'utf8')); console.log('Valid JSON')"</action>180 <check if="validation fails (exit code 1)">181 <action>Read the error message carefully - it shows the syntax error and position</action>182 <action>Open the file and navigate to the error location</action>183 <action>Fix the syntax error (add missing comma, bracket, or quote as indicated)</action>184 <action>Save the file</action>185 <action>Re-run validation with the same command</action>186 <action>Repeat until validation passes</action>187 </check>188 <action>Once validation passes, confirm: "Diagram created at {{default_output_file}}. Open to view?"</action>189 </step>190191 <step n="11" goal="Visual Preview (Optional)" optional="true">192 <action>Load {{render_validate}}</action>193 <action>Run: python3 {{render_script}} {{default_output_file}}</action>194 <check if="exit code is 2 (Playwright not installed)">195 <action>Skip: "Playwright not available — skipping PNG preview. Diagram is still valid."</action>196 </check>197 <check if="exit code is 0">198 <action>View the generated PNG file</action>199 <action>Audit against design vision: Does the diagram ARGUE its point?</action>200 <action>Check: overlapping text, misaligned arrows, spacing issues, color rendering</action>201 <check if="issues found">202 <action>Fix the JSON</action>203 <action>Re-render (max 3 cycles)</action>204 </check>205 <action>Ask: "Keep the PNG preview file? (yes/no)"</action>206 </check>207 </step>208209 <step n="12" goal="Validate Content">210 <invoke-task>Validate against {{validation}} using {faos}/core/tasks/validate-workflow.xml</invoke-task>211 </step>212213</workflow>214```215216217## Quality Checklist218219# Create Diagram - Validation Checklist220221## Design Quality222223- [ ] Diagram makes a clear visual argument (not just displaying components)224- [ ] Isomorphism Test: Structure communicates without labels225- [ ] Education Test: Unfamiliar viewer learns something in 30 seconds226- [ ] Visual pattern applied consistently throughout the diagram227- [ ] Depth level matches user intent (Simple/Standard/Comprehensive)228- [ ] Free-floating text used for labels and annotations (target <30% containerized)229- [ ] Semantic colors encode element roles (primary/secondary/accent/success/warning/danger)230- [ ] All IDs are descriptive strings (e.g., "auth_service_rect" not "rect_1")231232## Generation Quality233234- [ ] If >30 elements: section-by-section generation used with namespaced seeds235- [ ] Descriptive string IDs follow `{component}_{role}_{type}` pattern236- [ ] Cross-section arrows have valid startBinding and endBinding237- [ ] Evidence artifacts present for Comprehensive/Technical depth (if applicable)238- [ ] Evidence artifacts use dark rectangle styling with monospace text239- [ ] Element count within limit (under 80)240241## Element Structure242243- [ ] All components with labels have matching `groupIds`244- [ ] All text elements have `containerId` pointing to parent component245- [ ] Text width calculated properly (no cutoff)246- [ ] Text alignment appropriate for diagram type247248## Layout and Alignment249250- [ ] All elements snapped to 20px grid251- [ ] Component spacing consistent (40px/60px)252- [ ] Hierarchical alignment maintained253- [ ] No overlapping elements254255## Connections256257- [ ] All arrows have `startBinding` and `endBinding`258- [ ] `boundElements` array updated on connected components259- [ ] Arrow routing avoids overlaps260- [ ] Relationship types clearly indicated261262## Notation and Standards263264- [ ] Follows specified notation standard (UML/ERD/etc)265- [ ] Symbols used correctly266- [ ] Cardinality/multiplicity shown where needed267- [ ] Labels and annotations clear268269## Theme and Styling270271- [ ] Theme colors applied consistently272- [ ] Component types visually distinguishable273- [ ] Text is readable274- [ ] Professional appearance275276## Output Quality277278- [ ] Element count under 80279- [ ] No elements with `isDeleted: true`280- [ ] JSON is valid281- [ ] File saved to correct location282