agentleFS
joserprietojoserprieto/ai-skills/skills/drawio-uml-shapes/SKILL.md

drawio-uml-shapes

Skill2 starsChanged 10 months agoMITView on GitHub

Use when generating or editing draw.io diagrams with UML shapes. Provides correct shape-to-style mappings for deployment, component, sequence, state machine, package, and class diagrams. Also use when asking about "draw.io shapes", "UML diagram styles", "drawio XML generation", "diagram shape reference", or "UML notation in draw.io".

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 5 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Not yet distinguished: whether the stencils fail because shape libraries are not loaded in headless export, or because the names changed.

    line 50
  2. Distinctive:

    All defaults use the Tailwind Slate palette for a clean, neutral appearance.

    line 96
  3. Distinctive:

    All edges should use orthogonal routing unless there is a specific reason not to.

    line 350
  4. Very specific:

    Jump style on crossing edges: Add jumpStyle=arc;jumpSize=8.

    line 360
  5. Distinctive:

    Layout order matters: Place related shapes near each other to minimize edge lengths.

    line 362
  6. Very specific:

    Port positioning: Use exitX, exitY, entryX, entryY to control which side of a shape an edge connects to.

    line 364
  7. Very specific:

    Waypoints: Add explicit waypoints (Array<mxPoint> in geometry) to route edges around obstacles when automatic routing fails.

    line 366
  8. Distinctive:

    Rule of thumb: If more than 2 edges cross at the same point, reorganize the layout.

    line 374
  9. Very specific:

    Prefer it to jumpStyle=arc whenever the graph is a tree.

    line 381
  10. Very specific:

    Keep the model on gridSize: sizes as grid multiples and every coordinate snapped.

    line 385
  11. Very specific:

    Page size: Default 1920x1080 fits widescreen.

    line 450

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Draw.io UML Shape Reference

Brand-agnostic UML shape reference for draw.io XML generation. Covers six UML diagram types with correct shape-to-style mappings, verified by export against draw.io Desktop 31.1.8.

Core principle: Shapes encode UML semantics. Colors encode project semantics. Never mix them.

Read this before generating anything

Four things were measured on 31.1.8 that contradict how this skill was written for 24.x. Each one fails silently — the export succeeds and the result is wrong.

MeasuredConsequence
mxgraph.uml.* stencils render as plain rectangles in CLI exportUse the native fallbacks below, not the stencil names
--layout applies to the first page only, ignoring -pSplit multi-page files before laying out
Pages are numbered from 1 (0-based before v27.0.2)A 24.x script exports the wrong page
ELK destroys containers and ports; it helps flat graphsSee layout-reference.md §1 before delegating layout

The stencil trap

Verified 2026-08-18 by exporting a probe with every catalogued shape. These six produce an unstyled rectangle — no component tabs, no artifact fold, no signal pentagon:

mxgraph.uml.component · mxgraph.uml.artifact · mxgraph.uml.node · mxgraph.uml.port · mxgraph.uml25.sendSig · mxgraph.uml25.recSig

These render correctly and are what this skill now prefers:

cube · cylinder3 · doubleCircle · note · umlDestroy · folder · swimlane · umlLifeline · umlFrame · rounded · rhombus · ellipse

The fallback is not a workaround, it is valid UML. The standard admits both the component symbol and a plain rectangle carrying a «component» stereotype. Where a stencil fails, use a rectangle plus the stereotype in the label — it survives export, and it reads the same.

Not yet distinguished: whether the stencils fail because shape libraries are not loaded in headless export, or because the names changed. Until that is known, do not assume the app preview reflects what the CLI will produce.

When to use

  • Generating or editing draw.io diagrams with UML notation
  • Need correct draw.io shape names and style strings for UML elements
  • Building diagram generators or templates programmatically
  • Validating existing diagrams against UML standards

When NOT to use

  • Non-UML diagram types (ERD, BPMN, flowcharts, mind maps)
  • Brand or styling decisions (load your project's brand skill instead)
  • AWS/Azure/GCP infrastructure icons (use cloud-specific shape libraries)

Companion files

  • shapes-reference.md — complete shape catalog, all style strings and XML examples.
  • layout-reference.md — when to delegate layout to ELK and when not, CLI traps, hand placement.
  • layouts/flow-down.json, layouts/flow-right.json — calibrated layout profiles for --layout.
  • layouts/probes/ — the synthetic diagrams each profile was validated against. Re-export these after any draw.io upgrade and look at them.
  • dod-reference.md — per-type DoD and the structural validation checklist.

Supported diagram types

Deployment, Component, Sequence, State Machine, Package/Class, Activity.

Semantic Color System

This skill uses a 3-layer architecture to separate UML semantics from visual branding:

Layer 3: Brand Override (optional) — your project's brand skill
Layer 2: Semantic Roles (this skill) — category-appserver, semantic-critical, etc.
Layer 1: Draw.io Style Strings (shapes-reference.md) — exact shape+color combos

Layer 1 defines the raw draw.io style properties. Layer 2 assigns meaningful names to color combinations so diagrams communicate intent. Layer 3 lets any project override the defaults with its own brand palette without touching diagram structure.

Semantic role table

All defaults use the Tailwind Slate palette for a clean, neutral appearance.

RolePurposeDefault FillDefault Stroke
surface-deviceDevice backgrounds#F1F5F9#475569
surface-defaultArtifacts, default fills#FFFFFF#475569
surface-mutedSubtle backgrounds#F8FAFC#CBD5E1
text-primaryMain text—#1E293B
text-secondarySecondary text—#475569
category-appserverApp servers, JVMs, runtimes#FFFBEB#D97706
category-databaseDatabase engines#EBF5FB#2563EB
category-brokerMessage brokers#F5F3FF#7C3AED
category-proxyReverse proxies, LBs#F0FDF4#16A34A
category-containerContainer runtimes#FFF7ED#EA580C
category-infraInfra daemons, schedulers#F1F5F9#64748B
semantic-criticalEOL, alerts, failures#FEF2F2#DC2626
semantic-warningWarnings, caution#FFFBEB#D97706
semantic-successOK, healthy, target#F0FDF4#16A34A
semantic-infoInformational#EFF6FF#2563EB
special-deployspecDeployment specifications#FEF3C7#D97706
special-schemaDatabase schemas#EBF5FB#2563EB

Typography defaults

  • Font family: Sans-serif (brand layer overrides this)
  • Font stack for SVG export: Sans-serif, Helvetica, Arial, sans-serif
  • Typography scale:
    • Titles: 14-16px, bold (fontStyle=1)
    • Elements: 9-11px, regular
    • Details and edge labels: 7-8px

Embedding fonts offline

fontFamily=X alone falls back to the default face wherever X is not installed — CLI and PNG/SVG exports on another machine included. Embed the whole family (every weight and italics) as a data:text/css fontSource. Embed only the declared weights: layout-reference.md §5.

Brand override mechanism

To apply your project's brand, load a brand skill that provides a mapping from semantic roles to your brand's color tokens and font family. The brand skill overrides the defaults above without modifying any diagram structure or UML shape selections.

A brand skill should provide a table mapping semantic roles to brand tokens:

Semantic RoleBrand TokenBrand Value
surface-devicebrand.primary.bg#yourcolor
text-primarybrand.primary.text#yourcolor
semantic-criticalbrand.danger.bg#yourcolor
category-databasebrand.accent.bg#yourcolor

The brand skill replaces only fillColor, strokeColor, fontColor, and fontFamily values. Shape names, geometry, and structural properties remain unchanged.

Decision tree: which diagram?

digraph which_diagram {
  rankdir=TB;
  "What are you documenting?" [shape=diamond];
  "Physical/virtual topology" [shape=box,label="Deployment §1"];
  "Logical modules and interfaces" [shape=box,label="Component §2"];
  "Message flow over time" [shape=box,label="Sequence §3"];
  "Entity lifecycle" [shape=box,label="State Machine §4"];
  "Code structure" [shape=box,label="Package/Class §5"];
  "Process workflow" [shape=box,label="Activity §6"];
  "What are you documenting?" -> "Physical/virtual topology" [label="hardware, VMs, containers"];
  "What are you documenting?" -> "Logical modules and interfaces" [label="services, APIs"];
  "What are you documenting?" -> "Message flow over time" [label="request/response, auth"];
  "What are you documenting?" -> "Entity lifecycle" [label="states, transitions"];
  "What are you documenting?" -> "Code structure" [label="classes, packages"];
  "What are you documenting?" -> "Process workflow" [label="steps, decisions"];
}
IntentDiagramKey Elements
Where does software run?DeploymentDevice, ExecutionEnvironment, Artifact
How do modules connect?ComponentComponent, Interface, Port
How do actors interact over time?SequenceLifeline, Message, Combined Fragment
What states does an entity traverse?State MachineState, Transition, Pseudostate
How is code organized?Package/ClassPackage, Class, Association
What steps form a process?ActivityAction, Decision, Fork/Join

Quick reference by diagram type

Deployment diagram

Purpose: Show where software artifacts run on physical or virtual infrastructure.

Key elements:

Elementdraw.io ShapeUML
Deviceshape=cube;direction=south;size=102.0+
ExecutionEnvironmentrect + «executionEnvironment» label2.0+
Artifactrect + «artifact» label2.0+
DeploymentSpecrect + «deploymentSpec» (italic)2.0+
Database [custom]shape=cylinder3;size=8custom
Schema [custom]rect + «schema» labelcustom

Containment rules:

  • Device can contain ExecutionEnvironment, Artifact, other Devices
  • ExecutionEnvironment can contain Artifact, other ExecutionEnvironments
  • Artifact can contain nested Artifacts
  • DeploymentSpec attaches to Artifact (usually as sibling with dependency edge)
  • Database is a Device variant (cylinder representation)
  • Schema nests inside Database

See shapes-reference.md §1 for all style strings and XML examples.

Component diagram

Purpose: Show logical modules, their interfaces, and dependencies.

Key elements:

Elementdraw.io ShapeUML
Componentrect + «component» label1.x+
Subsystemshape=folder;tabWidth=802.0+
Provided Interfaceellipse (16px) or edge endArrow=oval2.0+
Required Interfaceedge endArrow=halfCircle2.0+
Portsmall rect on the parent boundary2.0+

Containment rules:

  • Subsystem can contain Components and other Subsystems
  • Component can contain other Components
  • Port attaches to the boundary of a Component
  • Provided Interface connects from a Port or Component boundary
  • Required Interface connects to a Port or Component boundary

See shapes-reference.md §2 for all style strings and XML examples.

Sequence diagram

Purpose: Show message flow between participants over time.

Key elements:

Elementdraw.io ShapeUML
Lifelineshape=umlLifeline1.x+
Synchronous Messageedge endArrow=block;endFill=11.x+
Asynchronous Messageedge endArrow=open;endFill=01.x+
Reply Messageedge dashed=1;endArrow=open1.x+
Combined Fragmentshape=umlFrame2.0+
Activation Boxthin rect on lifeline1.x+
Destructionshape=umlDestroy2.0+

Containment rules:

  • Lifeline is a top-level participant (uses container=1)
  • Activation Box is a child of Lifeline
  • Messages connect between Lifelines or Activation Boxes
  • Combined Fragment contains message sequences
  • Destruction marker is placed at the end of a Lifeline

See shapes-reference.md §3 for all style strings and XML examples.

State machine diagram

Purpose: Show the lifecycle states and transitions of an entity.

Key elements:

Elementdraw.io ShapeUML
Simple Staterounded=1;arcSize=401.x+
Initial Pseudostateellipse (filled, 20px)1.x+
Final Stateshape=doubleCircle1.x+
Composite Stateswimlane;rounded=11.x+
Choicerhombus1.x+
Fork/Joinfilled bar (4px height)1.x+
History (H/H*)ellipse with label1.x+

Containment rules:

  • Composite State can contain Simple States, pseudostates, and nested Composite States
  • Initial Pseudostate must have exactly one outgoing transition
  • Final State has no outgoing transitions
  • Fork/Join bars split or merge concurrent transitions
  • History pseudostates exist only inside Composite States

See shapes-reference.md §4 for all style strings and XML examples.

Package/Class diagram

Purpose: Show code organization, class structure, and relationships.

Key elements:

Elementdraw.io ShapeUML
Packageshape=folder;tabWidth=801.x+
Classswimlane;startSize=261.x+
Interfaceswimlane;startSize=40 (with stereotype)1.x+
Generalizationedge endArrow=block;endFill=01.x+
Compositionedge endArrow=diamond;endFill=11.x+
Aggregationedge endArrow=diamond;endFill=01.x+
Realizationedge dashed=1;endArrow=block;endFill=01.x+

Containment rules:

  • Package can contain Classes, Interfaces, and other Packages
  • Class has compartments: name, attributes, methods (separated by line cells)
  • Interface is a Class variant with <<interface>> stereotype
  • Generalization, Composition, Aggregation are edges between Classes

See shapes-reference.md §5 for all style strings and XML examples.

Activity diagram

Purpose: Show process workflows, decisions, and parallel execution.

Key elements:

Elementdraw.io ShapeUML
Actionrounded=1;arcSize=202.0+
Decision/Mergerhombus1.x+
Fork/Joinfilled bar1.x+
Initialellipse (filled, 20px)1.x+
Finalshape=doubleCircle1.x+
Swimlaneshape=swimlane;startSize=301.x+
Signal Sendshape=step;perimeter=stepPerimeter2.0+
Signal Receiveshape=step;direction=west2.0+

Containment rules:

  • Swimlane contains Actions, Decisions, and other flow elements
  • Fork/Join bars split or merge parallel flows
  • Decision must have guards on all outgoing edges
  • Merge combines alternative flows back into one

See shapes-reference.md §6 for all style strings and XML examples.

Common elements

Notes and constraints

Note shape:

shape=note;size=15;whiteSpace=wrap;html=1;fillColor=#FFFBEB;strokeColor=#D97706;fontFamily=Sans-serif;fontSize=8;fontColor=#1E293B;

Constraints use the note shape with {constraint text} format inside the label.

Edge routing (default: orthogonal)

All edges should use orthogonal routing unless there is a specific reason not to.

edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;

Edge crossing prevention (MANDATORY)

Edges MUST NOT visually intersect each other. Apply these strategies in order:

  1. Jump style on crossing edges: Add jumpStyle=arc;jumpSize=8; to edges that must cross another. This renders a small arc where edges intersect, making the diagram readable.
  2. Layout order matters: Place related shapes near each other to minimize edge lengths. Edges between adjacent elements rarely cross.
  3. Port positioning: Use exitX, exitY, entryX, entryY to control which side of a shape an edge connects to. Distribute connection points to avoid bunching.
  4. Waypoints: Add explicit waypoints (Array<mxPoint> in geometry) to route edges around obstacles when automatic routing fails.
# Edge with jump arcs for crossings:
edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;jumpStyle=arc;jumpSize=8;

Rule of thumb: If more than 2 edges cross at the same point, reorganize the layout. Edge jumps are a fallback, not a substitute for good spatial arrangement.

Tree / hierarchy layout — zero crossings by construction

For trees and strict hierarchies you can guarantee zero crossings without jump arcs: contiguous subtree bands, plus one vertical bus per parent with pinned exitX/entryX and explicit waypoints. Prefer it to jumpStyle=arc whenever the graph is a tree. Full method: layout-reference.md §1.

Geometry on the grid

Keep the model on gridSize: sizes as grid multiples and every coordinate snapped; ≥2 cells of separation; height derived from line count; width fitted per column, not per box; a small absolute corner radius; verticalAlign=middle by default; and zero overlaps, verified mechanically rather than by eye. Rules table: layout-reference.md §2.

Edge types table

TypeendArrowendFilldashedUML Meaning
Dependencyopen01"uses"
Associationnone—0"connected to"
Directed associationopen00navigable end
Generalizationblock00"is-a"
Realizationblock01"implements"
Compositiondiamond10"owns" (lifecycle)
Aggregationdiamond00"has" (shared)

Edge label positioning

  • verticalAlign=bottom for labels above the line
  • verticalAlign=top for labels below the line
  • Multiplicity labels use align=left or align=right at endpoints

Definition of done and validation

Per-type DoD checklists (deployment, sequence, state machine, component, package/class, activity) and the structural validation checklist live in dod-reference.md. Run them against a finished diagram before calling it done.

Common mistakes

MistakeFix
Using shape=mxgraph.uml.node for DeviceUse shape=cube;direction=south;size=10
Using shape=cube for ExecutionEnvironmentUse a rect with an «executionEnvironment» label
Omitting edgeStyle=orthogonalEdgeStyleAlways set edgeStyle — bare edges cross shapes
Using any mxgraph.uml.* stencilRenders as a plain rectangle in CLI export — use the native fallback
Hardcoding brand colors in style stringsUse semantic role defaults; brand skill overrides
Absolute geometry for nested cellsChild geometry is relative to parent
Missing recursiveResize=0 on containersChildren auto-resize unexpectedly
Missing container=1 on grouping shapesChildren not recognized as nested — breaks move/select
Missing collapsible=0 on UML containersUser can accidentally collapse aggregate contents
Self-closing edges (no <mxGeometry> child)Add <mxGeometry relative="1" as="geometry" /> child to EVERY edge. Self-closing edges (<mxCell ... edge="1" ... />) cause the "infinite scroll in corner" bug — draw.io opens the file with the viewport in an empty area far from the content. The edge must look like: <mxCell ... edge="1" ...><mxGeometry relative="1" as="geometry" /></mxCell>
Edges crossing without jump arcsAdd jumpStyle=arc;jumpSize=8; to crossing edges
Using shape=ellipse for final stateUse shape=doubleCircle for bullseye
Omitting container=1 on lifelinesActivation boxes won't nest correctly
Using filled arrow for async messagesAsync = open arrow (endFill=0), sync = filled (endFill=1)
Missing dashed=1 on reply messagesReply messages are ALWAYS dashed
Confusing aggregation and compositionAggregation = hollow diamond, Composition = filled diamond

Gotchas

SVG font fallback: draw.io SVG exports reference fonts by name. If Sans-serif is unavailable, the browser uses its default. For embedded SVGs, use the full stack: fontFamily=Sans-serif,Helvetica,Arial,sans-serif;

Compression: draw.io saves compressed (deflate+base64) by default. For programmatic generation, save uncompressed XML.

Edge routing with nested parents: Edges between cells in different parent containers may route oddly. jettySize=auto helps calculate optimal connection points.

Cell ID uniqueness: IDs must be unique within the entire <root>. Use {diagram-prefix}-{element} pattern (e.g., dep-appserver, seq-user-lifeline).

Page size: Default 1920x1080 fits widescreen. For print: 1169x827 (A3 landscape) or 827x1169 (A3 portrait).

HTML in labels: Style strings with html=1 expect HTML-encoded labels: &lt;b&gt;text&lt;/b&gt; for bold, &#xa; for newlines.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.