Use this skill whenever the user wants to create, edit, or manipulate Draw.io diagrams (.drawio, .drawio.svg, .drawio.png, .dio files). Triggers include: any mention of 'draw.io', 'drawio', 'diagram', 'flowchart', 'orgchart', 'architecture diagram', 'sequence diagram', 'network diagram', 'ER diagram', 'UML', 'state machine', 'mind map', or requests to visually represent processes, systems, or relationships. Also use when the user asks to convert text descriptions into visual diagrams, or to modify existing .drawio files. Do NOT use for Mermaid diagrams (.mermaid), SVG hand-coding, image generation, or non-diagram visualizations like charts/graphs (use xlsx or React for those).
A .drawio file is an XML file based on the mxGraph format. It can be opened and edited in VS Code with the Draw.io extension (hediet.vscode-drawio). Files can also use .dio, .drawio.svg, or .drawio.png extensions.
| Task | Approach |
|---|---|
| Create new diagram | Write raw XML in .drawio format — see structure below |
| Edit existing diagram | Parse XML → modify nodes/edges → write back |
| Multi-page diagram | Add multiple <diagram> elements inside <mxfile> |
| Preferred format | .drawio for version control (clean diffs), .drawio.svg for embedding in docs |
Every .drawio file follows this skeleton:
<mxfile host="Claude" modified="2025-01-01T00:00:00.000Z" agent="Claude" version="24.0.0" type="device">
<diagram name="Page-1" id="page1">
<mxGraphModel dx="1422" dy="762" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- All user cells go here, with parent="1" -->
</root>
</mxGraphModel>
</diagram>
</mxfile>
parent="0". It MUST exist.parent="1" (or another layer/group cell).node-1, edge-1, group-1, etc.x increases rightward, y increases downward. Origin (0,0) is the top-left of the canvas.1169x827 for landscape A4, 827x1169 for portrait A4. Adjust dx/dy for canvas scroll offset.A shape is an mxCell with a vertex="1" attribute and an mxGeometry child:
<mxCell id="node-1" value="My Label" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="60" as="geometry" />
</mxCell>
| Shape | Style String |
|---|---|
| Rectangle | rounded=0;whiteSpace=wrap;html=1; |
| Rounded rectangle | rounded=1;whiteSpace=wrap;html=1; |
| Circle / Ellipse | ellipse;whiteSpace=wrap;html=1; |
| Diamond (decision) | rhombus;whiteSpace=wrap;html=1; |
| Cylinder (database) | shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15; |
| Document | shape=document;whiteSpace=wrap;html=1;boundedLbl=1; |
| Parallelogram (I/O) | shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1; |
| Cloud | ellipse;shape=cloud;whiteSpace=wrap;html=1; |
| Hexagon | shape=hexagon;perimeter=hexagonPerimeter2;whiteSpace=wrap;html=1;fixedSize=1; |
| Actor (stick figure) | shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1; |
| Note / Callout | shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;size=15; |
| Rounded process | rounded=1;whiteSpace=wrap;html=1;arcSize=50; |
| Start/End (stadium) | rounded=1;whiteSpace=wrap;html=1;arcSize=50; (with small height) |
| Manual input | shape=manualInput;whiteSpace=wrap;html=1; |
| Container / Group | rounded=0;whiteSpace=wrap;html=1;container=1;collapsible=0; |
| Property | Values | Description |
|---|---|---|
fillColor | #dae8fc, #d5e8d4, none, ... | Background color (hex) |
strokeColor | #6c8ebf, #82b366, none, ... | Border color (hex) |
fontColor | #333333, #FFFFFF, ... | Text color |
fontSize | 12, 14, 18, ... | Font size in points |
fontStyle | 0=normal, 1=bold, 2=italic, 3=bold+italic | Font style bitmask |
strokeWidth | 1, 2, 3, ... | Border thickness |
dashed | 0, 1 | Dashed border |
opacity | 0–100 | Cell opacity |
shadow | 0, 1 | Drop shadow |
align | left, center, right | Horizontal text alignment |
verticalAlign | top, middle, bottom | Vertical text alignment |
whiteSpace | wrap | Enable text wrapping (always include) |
html | 1 | Enable HTML in labels (always include) |
container | 1 | Makes cell a container for child cells |
collapsible | 0, 1 | Whether container can collapse |
Blue theme (default Draw.io):
#dae8fc / Stroke: #6c8ebfGreen theme (success, OK):
#d5e8d4 / Stroke: #82b366Orange theme (warning):
#fff2cc / Stroke: #d6b656Red theme (error, danger):
#f8cecc / Stroke: #b85450Purple theme:
#e1d5e7 / Stroke: #9673a6Gray theme (neutral):
#f5f5f5 / Stroke: #666666Dark / header:
#333333 / Stroke: #000000 / Font: #FFFFFFAn edge is an mxCell with edge="1", connecting a source to a target:
<mxCell id="edge-1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;" edge="1" source="node-1" target="node-2" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
| Style | Description |
|---|---|
edgeStyle=orthogonalEdgeStyle; | Right-angle connectors (most common) |
edgeStyle=elbowEdgeStyle; | Single elbow connector |
edgeStyle=entityRelationEdgeStyle; | ER-diagram style |
curved=1; | Curved lines |
| (no edgeStyle) | Straight line |
| Property | Values |
|---|---|
endArrow=classic; | Standard arrowhead (default) |
endArrow=block; | Filled triangle |
endArrow=open; | Open arrowhead |
endArrow=diamond; | Diamond (aggregation) |
endArrow=diamondThin; | Thin diamond (composition when filled) |
endArrow=none; | No arrow |
startArrow=... | Same options, for start of edge |
endFill=0; | Hollow end arrow |
endFill=1; | Filled end arrow |
startFill=0; | Hollow start arrow |
Add a label to an edge via value="label text", or with a child label cell:
<mxCell id="edge-1" value="yes" style="edgeStyle=orthogonalEdgeStyle;" edge="1" source="node-1" target="node-2" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
To group cells visually (e.g., a swimlane or subsystem box):
<!-- The container -->
<mxCell id="group-1" value="My Group" style="rounded=0;whiteSpace=wrap;html=1;container=1;collapsible=0;fillColor=#f5f5f5;strokeColor=#666666;verticalAlign=top;fontStyle=1;fontSize=14;" vertex="1" parent="1">
<mxGeometry x="50" y="50" width="300" height="200" as="geometry" />
</mxCell>
<!-- Child cells with parent="group-1" — coordinates are relative to the group -->
<mxCell id="node-inside" value="Child" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="group-1">
<mxGeometry x="20" y="40" width="100" height="40" as="geometry" />
</mxCell>
Key: child cells use parent="group-1" and their x/y are relative to the group's top-left corner.
Horizontal swimlane:
<mxCell id="lane-1" value="Department A" style="shape=swimlane;startSize=30;horizontal=1;fillColor=#dae8fc;strokeColor=#6c8ebf;collapsible=0;fontStyle=1;" vertex="1" parent="1">
<mxGeometry x="50" y="50" width="600" height="200" as="geometry" />
</mxCell>
Vertical swimlane: add horizontal=0; to the style.
Row 0 (y=40): [Start]
Row 1 (y=140): [Process A] [Process B]
Row 2 (y=240): [Decision]
Row 3 (y=340): [End]
Use consistent x-spacing: e.g., center column at x=200, left at x=50, right at x=350.
For process flows and pipelines, lay out horizontally:
orthogonalEdgeStyle for clean right-angle connectors.whiteSpace=wrap;html=1; on shapes so labels wrap properly.<mxfile host="Claude" modified="2025-01-01T00:00:00.000Z" agent="Claude" version="24.0.0" type="device">
<diagram name="Flowchart" id="flowchart">
<mxGraphModel dx="1422" dy="762" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="start" value="Start" style="rounded=1;whiteSpace=wrap;html=1;arcSize=50;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="200" y="40" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="process1" value="Process Step" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="200" y="130" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="decision1" value="Condition?" style="rhombus;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
<mxGeometry x="195" y="240" width="130" height="80" as="geometry" />
</mxCell>
<mxCell id="end" value="End" style="rounded=1;whiteSpace=wrap;html=1;arcSize=50;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="200" y="380" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="e1" style="edgeStyle=orthogonalEdgeStyle;" edge="1" source="start" target="process1" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e2" style="edgeStyle=orthogonalEdgeStyle;" edge="1" source="process1" target="decision1" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e3" value="Yes" style="edgeStyle=orthogonalEdgeStyle;" edge="1" source="decision1" target="end" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
For system/architecture diagrams:
container=1) for logical groupings (e.g., "Cloud", "On-Premise").dashed=1;) for async/optional connections.style="text;html=1;fontSize=20;fontStyle=1;align=center;".Use HTML labels for multi-section boxes:
<mxCell id="class-1" value="<b>ClassName</b><hr>- field1: String<br>- field2: int<hr>+ method1()<br>+ method2()" style="rounded=0;whiteSpace=wrap;html=1;align=left;overflow=fill;verticalAlign=top;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="200" height="120" as="geometry" />
</mxCell>
Note: In XML, HTML inside value must be entity-escaped: < → <, > → >.
Draw.io supports HTML in cell values when html=1 is in the style. You MUST entity-escape all HTML:
| Character | Entity |
|---|---|
< | < |
> | > |
& | & |
" | " |
Example: bold + line break:
value="<b>Title</b><br>Subtitle"
Simply add more <diagram> elements:
<mxfile host="Claude">
<diagram name="Overview" id="page1">
<mxGraphModel ...>
<root>...</root>
</mxGraphModel>
</diagram>
<diagram name="Details" id="page2">
<mxGraphModel ...>
<root>...</root>
</mxGraphModel>
</diagram>
</mxfile>
To modify a .drawio file:
mxCell elements.Important: preserve the existing id values to avoid breaking edge connections. When adding new cells, use IDs that don't conflict with existing ones.
Before finalizing a .drawio file, verify:
mxCell id="0" and mxCell id="1" parent="0" are presentvertex cells have <mxGeometry> with x, y, width, heightedge cells reference valid source and target IDsrelative="1"value attributes is entity-escaped (<, >, &)whiteSpace=wrap;html=1; is present on all shape stylesparent, not "1".drawio extension (e.g., diagram.drawio).xmllint --noout file.drawio if available.