Drawio Diagrams
ASecurityBuild editable .drawio architecture, DFD, UML sequence, workflow, and presentation diagrams with manual flow-based layout, non-crossing orthogonal routing, TTF font-metric sizing, and native draw.io CLI export with a built-in macOS Launch Services crash fix. Writes native uncompressed Electron XML with random 20-character cell and diagram IDs by default so files open in Draw.io Desktop and Confluence macros, with --export-only support to preserve manual edits. Use when creating or updating dr...
- 4 stars
- 0 votes
- 0 copies
- 0 views
- Added December 4, 2026
Works with
Security analysis
100/100Pro scans all 9 files and shows the line behind each finding
npx -y skills add websanya/drawio-diagrams --skill drawio-diagrams --agent claude-codeAre you the author of Drawio Diagrams?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/websanya-drawio-diagrams)---
name: drawio-diagrams
description: >-
Build editable .drawio architecture, DFD, UML sequence, workflow, and
presentation diagrams with manual flow-based layout, non-crossing
orthogonal routing, TTF font-metric sizing, and native draw.io CLI export
with a built-in macOS Launch Services crash fix. Writes native uncompressed
Electron XML with random 20-character cell and diagram IDs by default so
files open in Draw.io Desktop and Confluence macros, with --export-only
support to preserve manual edits. Use when creating or updating draw.io or
diagrams.net technical diagrams, system architectures, data flows, or slide
visuals, including Russian requests: диаграмма, схема архитектуры, схема
потоков в draw.io. Do not use for physical L1 or L2 site network port maps,
rack or RJ45 panels, or Wi-Fi site plans, or when the user asks only for
inline Mermaid or PlantUML.
license: MIT
compatibility: >-
Python 3.10 or newer using the standard library, with optional Pillow for
exact TTF font metrics. Draw.io Desktop is required only for rendering PNG,
SVG, or PDF files or for re-saving XML.
metadata:
author: websanya
version: "1.0.1"
repository: https://github.com/websanya/drawio-diagrams
---
# Draw.io diagrams
Create editable draw.io diagrams with manual layout, orthogonal routing,
font-metric text sizing, native XML export, and visual review.
Throughout this guide, `<SKILL_DIR>` refers to the directory containing this
`SKILL.md` file, such as `~/.agents/skills/drawio-diagrams`,
`~/.claude/skills/drawio-diagrams`, or `~/.codex/skills/drawio-diagrams`.
Resolve `scripts/` relative to `<SKILL_DIR>`, not the project working directory.
## Use this skill when
- Creating or updating `.drawio` architecture diagrams, data flow diagrams, UML
sequence diagrams, workflow charts, or presentation slide diagrams.
- Generating draw.io XML that must open in Draw.io Desktop or Confluence macros
for manual editing without synthetic sequential IDs.
- Re-exporting manually edited `.drawio` files to PNG, SVG, PDF, or uncompressed
XML without overwriting XML changes.
Do not use this skill for physical L1 or L2 site network port maps, rack or RJ45
panels, or Wi-Fi site plans, or when the user wants inline Mermaid or PlantUML
only.
## Core invariants
1. **Native editable XML by default.** Emit uncompressed UTF-8 XML with
`compressed="false"`, `host="Electron"`, a random 20-character diagram ID, and
random 20-character cell prefixes (`<rand20>-<n>`) instead of sequential
`node1` or `e1` IDs. Files open in Draw.io Desktop and Confluence macros
without conversion errors. Keep the `.drawio` source next to every export.
2. **Manual layout over auto-layout.** Position nodes along the natural flow of
signal, data, or process with explicit routing corridors. Never rely on
automatic graph layout for final diagrams.
3. **Orthogonal routing without crossings.** Use
`edgeStyle=orthogonalEdgeStyle;rounded=1`, pinned port anchors via `exitX`,
`exitY`, `entryX`, `entryY`, `exitPerimeter=0`, and `entryPerimeter=0`, and
explicit `<Array as="points">` waypoints. Order parallel turns so edges never
cross. Read [references/xml-and-routing.md](references/xml-and-routing.md) for
turn ordering, bus bars, and direction rules.
4. **Four-layer z-order.** Emit cells in exact order: background and zones, then
edges, then nodes, then labels and zone titles. Place edge labels near
straight segments with `labelBackgroundColor=#FFFFFF`. Render zone titles last
on zone-colored fill above all edges.
5. **Preserve manual edits with `--export-only`.** Every generator script must
support `--build-only` and `--export-only`. After a human edits the `.drawio`
file in Draw.io Desktop, run `--export-only` to render PNG, SVG, or PDF
without overwriting XML.
6. **Native draw.io export only.** Render through
`<SKILL_DIR>/scripts/drawio_export.py`. It launches macOS `draw.io.app` via
Launch Services with `kqueue` exit-status tracking to avoid
`electron/electron#52815`, wraps headless Linux in `xvfb-run`, and locates
Windows `draw.io.exe`. Never use `rsvg-convert` or third-party SVG rasterizers.
7. **No secrets in shared diagrams.** Never place passwords, API tokens, or
private keys in `.drawio` files or rendered images.
## Workflow
### Step 1. Select a preset and canvas
Use `pastel-technical` when the user specifies no preset. It sets Arial, five
pastel roles, an 800 px vertical page or a 1320 px wide map, and `shadow=0`.
Read [references/presets.md](references/presets.md) for `architecture-classic`,
`slide-clean`, and local overrides via `~/.config/drawio-diagrams/presets.json`
or `--presets-file`.
### Step 2. Design flow, corridors, and split strategy
- Lay out nodes left to right or top to bottom along the primary flow.
- Keep 4 px or 10 px grid increments, equal padding inside sibling cards, and
aligned baselines across columns and rows.
- Split tall UML sequence diagrams by scenario or event into separate pages or
files instead of one giant sheet with empty lifelines. Widen actor gaps to fit
the widest message label, and build actors, lifelines, `alt` and `else` frames,
and notes from `box()`, `edge()`, `zone()`, and `text()`.
- Keep one color for one meaning across every page in a set, distinguish link
types with text or dash patterns for grayscale readability, and include a
legend when multiple line or node categories appear.
### Step 3. Build with `<SKILL_DIR>/scripts/drawio_kit.py`
Write a project build script that locates `<SKILL_DIR>/scripts` and calls
`run_build_cli(...)`. It uses only the Python standard library, reads Pillow TTF
metrics when Pillow is installed, and falls back to built-in glyph widths
otherwise.
`run_build_cli` invokes `build_fn(presets_file: Path | None) -> DiagramBook` with
a single `Path | None` argument from `--presets-file`:
```python
import os
import sys
from pathlib import Path
for candidate in (
os.environ.get("DRAWIO_SKILL_SCRIPTS"),
Path.home() / ".agents/skills/drawio-diagrams/scripts",
Path.home() / ".claude/skills/drawio-diagrams/scripts",
Path.home() / ".codex/skills/drawio-diagrams/scripts",
Path.home() / ".cursor/skills/drawio-diagrams/scripts",
Path.home() / ".gemini/config/skills/drawio-diagrams/scripts",
Path.home() / ".gemini/antigravity/skills/drawio-diagrams/scripts",
):
if candidate and (Path(candidate) / "drawio_kit.py").is_file():
sys.path.insert(0, str(candidate))
break
from drawio_kit import DiagramBook, DiagramPage, run_build_cli
def build(presets_file: Path | None) -> DiagramBook:
book = DiagramBook()
p = DiagramPage("Overview", preset="pastel-technical", width=800, height=640, presets_override=presets_file)
# Use p.header(), p.card(), p.box(), p.bus(), p.zone(), p.edge(), p.text(), p.edge_label(), p.legend()
book.add_page(p)
return book
if __name__ == "__main__":
raise SystemExit(run_build_cli(Path(__file__).with_suffix(".drawio"), build))
```
- `run_build_cli(...)` provides `--build-only`, `--export-only`, `--pages`,
`--formats`, `--scale`, `--border`, `--theme`, `--embed-diagram`,
`--no-embed-diagram`, `--check-no-yo`, `--strict-warnings`, and
`--presets-file`.
- To embed an icon or image in a node, pass a draw.io data URI via
`extra="shape=image;image=data:image/png,<base64_payload>;"`. Omit `;base64`
because semicolons separate draw.io style pairs.
### Step 4. Validate before export
Run the static XML, geometry, overlap, text-fit, and secret linter on every
`.drawio` file:
```bash
python3 "<SKILL_DIR>/scripts/validate_drawio.py" --strict-warnings path/to/diagram.drawio
# Add --check-no-yo for Russian and Cyrillic diagrams
```
Fix every reported error until the exit code is `0`.
### Step 5. Export with `<SKILL_DIR>/scripts/drawio_export.py`
Export through the native draw.io CLI wrapper, or through your project script's
`run_build_cli` and `--export-only`:
```bash
# Documentation: 2x PNG and embedded-diagram SVG for every page
python3 "<SKILL_DIR>/scripts/drawio_export.py" path/to/diagram.drawio \
--out-dir path/to/diagrams --all-pages --formats png,svg --scale 2 --border 15 --embed-diagram
# Presentation slides: 3x PNG with embedded draw.io data and zero border
python3 "<SKILL_DIR>/scripts/drawio_export.py" path/to/slides.drawio \
--out-dir path/to/slides-png --all-pages --formats png --scale 3 --border 0 --embed-diagram
# Confluence upload: re-save uncompressed XML through Draw.io Desktop
python3 "<SKILL_DIR>/scripts/drawio_export.py" path/to/diagram.drawio \
--output path/to/published.drawio --formats xml --uncompressed
```
To open a diagram in Draw.io Desktop on macOS, run `open -a draw.io <file>`.
### Step 6. Inspect visually and sync
1. **Inspect every exported PNG and PDF visually before finishing.** Passing XML
validation does not guarantee readable line wraps or even whitespace. Follow
[references/checklist.md](references/checklist.md).
2. **Independent design review.** For client architecture documents, conference
decks, or printouts, run an independent visual review on the rendered PNGs.
3. **Keep artifacts in sync.** When facts, topology, or copy change in
documentation or code, update `.drawio`, re-export PNG and SVG, and rebuild
any parent PDF or PowerPoint file in the same task.
## Limitations
- Rendering PNG, SVG, or PDF files and re-saving XML require a local Draw.io
Desktop installation. Headless Linux environments also need `xvfb-run`.
- Without Pillow and local TTF files installed, text width checks use built-in
character heuristics, so visual inspection of rendered images remains mandatory.
- Static validation inspects XML geometry and syntax; it does not evaluate visual
balance, unintended line wraps, or semantic accuracy.
- Physical L1 or L2 site network port maps, rack diagrams, and Wi-Fi floor plans
are outside the scope of this skill.
## Copy, anti-slop, and Russian rules
- Write short, factual labels without filler, decorative badges, emojis,
gradients, or drop shadows (`shadow=0`). Never add captions that repeat what
the diagram already shows, and never put changelog banners on diagrams.
- Use plain terms instead of raw internal identifiers when non-authors will read
the diagram.
- **Russian and Cyrillic diagrams.**
- Use `е` and `Е` instead of `ё` and `Ё` across titles, nodes, edge labels, and
legends, unless the user requests that spelling.
- Avoid em dashes; use short noun phrases or a colon.
- Reserve 15 to 20 percent extra horizontal margin for wide Cyrillic glyphs
such as `Ш`, `Щ`, `Ж`, `Ю`, and `М` when estimating box widths.
Files in this skill
- LICENSE
- SKILL.md
- agents/openai.yaml
- references/checklist.md
- references/presets.md
- references/xml-and-routing.md
- scripts/drawio_export.py
- scripts/drawio_kit.py
- scripts/validate_drawio.py
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.