npx skills add ...
npx skills add github/awesome-copilot --skill draw-io-diagram-generator
npx skills add github/awesome-copilot --skill draw-io-diagram-generator
Use when creating, editing, or generating draw.io diagram files (.drawio, .drawio.svg, .drawio.png). Covers mxGraph XML authoring, shape libraries, style strings, flowcharts, system architecture, sequence diagrams, ER diagrams, UML class diagrams, network topology, layout strategy, the hediet.vscode-drawio VS Code extension, and the full agent workflow from request to a ready-to-open file.
This skill enables you to generate, edit, and validate draw.io (.drawio) diagram files with
correct mxGraph XML structure. All generated files open immediately in the
Draw.io VS Code extension
(hediet.vscode-drawio) without any manual fixes required. You can also open the files in the draw.io web app or desktop app if you prefer.
Trigger phrases (load this skill when you see these)
.drawio, .drawio.svg, or .drawio.png fileSupported diagram types
| Diagram Type | Template Available | Description |
|---|---|---|
| Flowchart | assets/templates/flowchart.drawio | Process flows with decisions and branches |
| System Architecture | assets/templates/architecture.drawio | Multi-tier / layered service architecture |
| Sequence Diagram | assets/templates/sequence.drawio | Actor lifelines and timed message flows |
| ER Diagram | assets/templates/er-diagram.drawio | Database tables with relationships |
| UML Class Diagram | assets/templates/uml-class.drawio | Classes, interfaces, enums, relationships |
| Network Topology | (use shape library) | Routers, servers, firewalls, subnets |
| BPMN Workflow | (use shape library) | Business process events, tasks, gateways |
| Mind Map | (manual) | Central topic with radiating branches |
hediet.vscode-drawio (extension id). Install with:
.drawio, .drawio.svg, .drawio.pngscripts/Follow these steps in order for every diagram generation task.
Ask or infer:
.drawio file be saved?If the request is ambiguous, infer the most sensible diagram type from context (e.g. "show the tables" → ER diagram, "show how the API call flows" → sequence diagram).
assets/templates/. Copy the template structure and replace placeholder values.Rule: ids
0and1are ALWAYS required and must be the first two cells. Never reuse them.
Before generating XML, sketch the logical placement:
120x60 px for process boxes, 160x80 px for swimlanes1169 x 827 pxVertex cell (every shape):
Edge cell (every connector):
Critical rules:
mxGeometry child with x, y, width, height, as="geometry"source and target matching existing vertex ids — exception: floating edges (e.g. sequence diagram lifelines) use sourcePoint/targetPoint inside <mxGeometry> instead; see §4 Sequence Diagramparent must reference an existing cell idhtml=1 in style when the label contains HTML (<b>, <i>, <br>)& => &, < => <, > => >Use the standard semantic color palette for consistency:
| Purpose | fillColor | strokeColor |
|---|---|---|
| Primary / Info | #dae8fc | #6c8ebf |
| Success / Start | #d5e8d4 | #82b366 |
| Warning / Decision | #fff2cc | #d6b656 |
| Error / End | #f8cecc | #b85450 |
| Neutral | #f5f5f5 | #666666 |
| External / Partner | #e1d5e7 | #9673a6 |
Common style strings by diagram type:
See
references/style-reference.mdfor the complete style key catalog andreferences/shape-libraries.mdfor all shape library names.
.drawio extension"Open
<filename>in VS Code — it will render automatically with the draw.io extension. You can use draw.io's web app or desktop app as well if you prefer."
Key elements: Start (ellipse) => Process (rounded rectangle) => Decision (diamond) => End (ellipse)
Use swimlane containers for each tier. All service boxes are children of their swimlane.
Connectors between tiers use absolute coordinates with
parent="1".
Key elements: Actors (top), Lifelines (dashed vertical lines), Activation boxes, Message arrows.
edge="1" with endArrow=none and dashed=1, no source/target — use sourcePoint/targetPoint in geometryendArrow=block;endFill=1endArrow=open;endFill=0;dashed=1Minimal XML snippet:
Note: Lifelines are floating edges that use
sourcePoint/targetPointin<mxGeometry>instead ofsource/targetattributes. This is the standard draw.io pattern for sequence diagrams.
Use shape=table containers with childLayout=tableLayout. Rows are shape=tableRow cells with portConstraint=eastwest. Columns inside each row are shape=partialRectangle.
Relationship arrows use edgeStyle=entityRelationEdgeStyle:
startArrow=ERone;endArrow=ERonestartArrow=ERone;endArrow=ERmanystartArrow=ERmany;endArrow=ERmanyERmandOne, Optional: ERzeroToOneClass boxes are swimlane containers. Attributes and methods are plain text cells. Dividers are zero-height swimlane children.
Arrow styles by relationship type:
| Relationship | Style String |
|---|---|
| Inheritance (extends) | edgeStyle=orthogonalEdgeStyle;html=1;endArrow=block;endFill=0; |
| Realization (implements) | edgeStyle=orthogonalEdgeStyle;dashed=1;html=1;endArrow=block;endFill=0; |
| Composition | edgeStyle=orthogonalEdgeStyle;html=1;startArrow=diamond;startFill=1;endArrow=none; |
| Aggregation | edgeStyle=orthogonalEdgeStyle;html=1;startArrow=diamond;startFill=0;endArrow=none; |
| Dependency | edgeStyle=orthogonalEdgeStyle;dashed=1;html=1;endArrow=open;endFill=0; |
| Association | edgeStyle=orthogonalEdgeStyle;html=1;endArrow=open;endFill=0; |
Add multiple <diagram> elements for complex systems:
Each page has its own independent cell id namespace. The same id value can appear in different pages without conflict.
When modifying an existing .drawio file:
name attributeUse scripts/add-shape.py to safely add a single shape without editing raw XML:
Layout
Labels
text;strokeColor=none;fillColor=none;fontSize=18;fontStyle=1) at top of every pagewhiteSpace=wrap;html=1 on vertex shapesStyle consistency
edgeStyle=orthogonalEdgeStyle for clean right-angle connectorsFile naming
order-service-flow.drawio, database-schema.drawiodocs/ or architecture/| Problem | Likely Cause | Fix |
|---|---|---|
| File opens blank in VS Code | Missing id=0 or id=1 cell | Add both root cells before any other cells |
| Shape at wrong position | Child inside container — coords are relative | Check parent; adjust x/y relative to container |
| Edge not visible | source or target id does not match any vertex | Verify both ids exist exactly as written |
| Diagram shows "Compressed" | mxGraphModel is base64-encoded | Open in draw.io web, File > Export > XML (uncompressed) |
| Shape style not rendering | Typo in shape= name | Check references/shape-libraries.md for exact style string |
| Label shows escaped HTML | html=0 on a cell with HTML label | Add html=1; to the cell style |
| Container children overlap container edge | Container height too small | Increase container height in mxGeometry |
Before delivering any generated .drawio file, verify:
<mxfile> root element<diagram> has a non-empty id attribute<mxCell id="0" /> is the first cell in every diagram<mxCell id="1" parent="0" /> is the second cell in every diagramid values are unique within each diagramvertex="1" and a child <mxGeometry as="geometry">edge="1" and either: (a) source/target pointing to existing vertex ids, or (b) <mxPoint as="sourcePoint"> and <mxPoint as="targetPoint"> in its <mxGeometry> (floating edge — used for sequence diagram lifelines)parent pointing to an existing idhtml=1 is in the style for any label containing HTML tags&, <, > in attribute values)Run the automated validator:
When delivering a diagram, always provide:
.drawio file written to the requested path"Open
<filename>in VS Code — the draw.io extension will render it automatically. Or you can open it in the draw.io web app or desktop app if you prefer."
"Click any shape to select it. Double-click to edit the label. Drag to reposition."
All companion files are in .github/skills/draw-io-diagram-generator/:
| File | Contents |
|---|---|
references/drawio-xml-schema.md | Complete mxfile / mxGraphModel / mxCell attribute reference, coordinate system, reserved cells, validation rules |
references/style-reference.md | All style keys with allowed values, vertex and edge style keys, shape catalog, semantic color palette |
references/shape-libraries.md | All shape library categories (General, Flowchart, UML, ER, Network, BPMN, Mockup, K8s) with style strings |
assets/templates/flowchart.drawio | Ready-to-use flowchart template |
assets/templates/architecture.drawio | 4-tier system architecture template |
assets/templates/sequence.drawio | 3-actor sequence diagram template |
assets/templates/er-diagram.drawio | 3-table ER diagram with crow's foot relationships |
assets/templates/uml-class.drawio | Interface + 2 classes + enum with relationship arrows |
scripts/validate-drawio.py | Python script to validate XML structure of any .drawio file |
scripts/add-shape.py | Python CLI to add a new shape to an existing diagram |
scripts/README.md | How to use the scripts with examples |