Use when starting a diagram from a template or creating reusable diagram templates in Draw.io. Prevents rebuilding complex diagrams from scratch when a template exists. Covers the built-in template catalog (150+), custom template creation, template XML structure, and template modification patterns. Keywords: template, diagram template, custom template, template catalog, reusable diagram, start from template, pre-built diagram, diagram library, save as template.
Use when starting a diagram from a template or creating reusable diagram templates in Draw.io. Prevents rebuilding complex diagrams from scratch when a template exists. Covers the built-in template catalog (150+), custom template creation, template XML structure, and template modification patterns. Keywords: template, diagram template, custom template, template catalog, reusable diagram, start from template, pre-built diagram, diagram library, save as template.
license
MIT
compatibility
Designed for Claude Code. Requires Draw.io / diagrams.net (current).
metadata
{"author":"OpenAEC-Foundation","version":"1.0"}
Draw.io Template Implementation
Purpose
This skill enables correct use of Draw.io templates for starting new diagrams and creating reusable diagram templates. It prevents the most common mistake: rebuilding complex diagrams from scratch when a suitable template exists.
Critical Rules (Memorize These)
ALWAYS use the standard <mxfile> wrapper for template files — NEVER output bare <mxGraphModel> when creating a reusable template.
ALWAYS include both structural cells (id="0" root and id="1" default parent) in every template.
ALWAYS use unique, descriptive cell IDs in templates — NEVER use numeric-only IDs like "2", "3". Use semantic IDs like "header", "process_1", "decision_auth".
ALWAYS include whiteSpace=wrap;html=1; in every shape style within a template.
NEVER hard-code user-specific content in templates — use placeholder text (e.g., "[Process Name]", "[Decision]") that signals replacement.
ALWAYS set grid="1" and guides="1" in the mxGraphModel attributes of every template.
NEVER embed images or external resources in templates — templates MUST be self-contained XML.
Template XML Structure
Full Template File (mxfile wrapper)
A reusable template MUST use the <mxfile> wrapper. This is the format Draw.io saves and loads:
<mxfilehost="app.diagrams.net"modified="2024-01-01T00:00:00.000Z"agent="Claude"type="device"version="21.0.0"><diagramid="template-id"name="Template Name"><mxGraphModeldx="1000"dy="600"grid="1"gridSize="10"guides="1"tooltips="1"connect="1"arrows="1"fold="1"page="1"pageScale="1"pageWidth="1169"pageHeight="827"><root><mxCellid="0" /><mxCellid="1"parent="0" /><!-- Template shapes and edges here --></>
Inline Diagram (mxGraphModel only)
For programmatic generation via MCP tools, use the bare <mxGraphModel>:
<mxGraphModeldx="1000"dy="600"grid="1"gridSize="10"guides="1"tooltips="1"connect="1"arrows="1"fold="1"page="1"pageScale="1"pageWidth="1169"pageHeight="827"><root><mxCellid="0" /><mxCellid="1"parent="0" /><!-- Shapes and edges here --></root></mxGraphModel>
Multi-Page Template
Templates MAY contain multiple pages. Each page is a separate <diagram> element inside the <mxfile>:
Each <diagram> MUST have its own id and name attributes, and each MUST contain its own pair of structural cells (id="0" and id="1").
Built-in Template Categories
Draw.io ships with 150+ templates across these categories:
Category
Contents
Typical Use
Basic
Simple flowcharts, grids, mind maps
General-purpose starting points
Business
Org charts, value chains, SWOT analysis
Business process documentation
Charts
Bar, pie, line charts
Data visualization
Engineering
Circuit diagrams, floor plans
Technical schematics
Flowcharts
Process flows, decision trees, swimlanes
Process modeling
Mindmaps
Mind map layouts
Brainstorming, idea organization
Mockups
Wireframes, UI mockups
User interface design
Network
Network topology, rack diagrams
Infrastructure documentation
Software
UML class, sequence, activity, ER diagrams
Software architecture
Tables
Data tables, comparison grids
Structured data display
Cloud
AWS, Azure, GCP architectures
Cloud infrastructure
BPMN
Business process model notation
Formal process modeling
Lean
Value stream maps, Kanban boards
Lean/Agile workflows
Infographic
Timelines, statistics layouts
Visual communication
Other
Miscellaneous templates
Specialized diagrams
Decision Tree: Template Selection
What kind of diagram do you need?
Process/workflow --> Flowcharts category or BPMN category
Organization chart --> Business category
Software architecture --> Software category (UML, ER)
Network topology --> Network category
Cloud infrastructure --> Cloud category (AWS/Azure/GCP)
Wireframe/UI --> Mockups category
Mind map --> Mindmaps category
Data visualization --> Charts category
None of the above --> Build from scratch using other impl skills
Template Modification Pattern
The standard approach for using a template: keep the structure, swap the content.
Step 1: Start from Template Structure
Select the closest matching template. The template provides:
Layout and positioning (geometry)
Shape types and styles
Connection patterns (edge routing)
Page settings (size, grid, guides)
Step 2: Replace Placeholder Content
Update value attributes with actual content. NEVER change:
Shape styles (unless explicitly required)
Connection routing
Coordinate relationships between shapes
Step 3: Add or Remove Shapes
When the template has more shapes than needed, remove unused cells AND their edges. When the template has fewer shapes than needed, duplicate existing cells with new IDs and adjusted coordinates.
Adding a Shape (Copy Pattern)
<!-- Original template shape --><mxCellid="process_1"value="[Step 1]"style="rounded=0;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;"vertex="1"parent="1"><mxGeometryx="200"y="120"width="140"height="60"as="geometry" /></mxCell><!-- New shape: same style, new ID, adjusted y-coordinate --><mxCellid="process_new"value="Additional Step"style="rounded=0;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;"vertex="1"parent="1"><mxGeometryx="200"y="220"width="140"height="60"as="geometry" /></mxCell>
Removing a Shape
When removing a shape, ALWAYS also remove every edge that references its ID in source or target.
Creating Custom Templates
Reusable Template Checklist
Use the <mxfile> wrapper with host, modified, type attributes.
Set a meaningful name attribute on the <diagram> element.
Use placeholder text in value attributes (e.g., "[Title]", "[Description]").
Include consistent styling across all shapes.
Set page dimensions appropriate for the content (A4 landscape: 1169 x 827, A4 portrait: 827 x 1169).
Enable grid and guides: grid="1" gridSize="10" guides="1".
Use semantic cell IDs that describe the shape purpose.
Include all necessary edges with edgeStyle=orthogonalEdgeStyle.
Template Color Schemes
Use a consistent color scheme across all shapes in a template:
Purpose
Fill Color
Stroke Color
Primary shapes
#dae8fc (light blue)
#6c8ebf
Secondary shapes
#d5e8d4 (light green)
#82b366
Warning/attention
#fff2cc (light yellow)
#d6b656
Error/danger
#f8cecc (light red)
#b85450
Neutral/info
#f5f5f5 (light gray)
#666666
Highlight
#e1d5e7 (light purple)
#9673a6
Page Size Reference
Format
pageWidth
pageHeight
Orientation
A4 Landscape
1169
827
Horizontal
A4 Portrait
827
1169
Vertical
Letter Landscape
1100
850
Horizontal
Letter Portrait
850
1100
Vertical
Infinite Canvas
Omit page attributes
-
Auto-expand
Complete Example: Basic Flowchart Template
A reusable 5-step flowchart template with placeholders: