Génération de schémas draw.io

VérifiéSûr

Créez des diagrammes natives au format .drawio avec export possible en PNG, SVG ou PDF. Utilisez la CLI de draw.io pour l'exportation.

Spar Skills Guide Bot
DocumentationIntermédiaire
23/07/2026
Claude Code
#drawio#diagrams#flowcharts#export

Recommandé pour

Synthèse automatique

Génère des diagrammes natifs .drawio avec export possible en PNG, SVG ou PDF tout en conservant l'édition dans draw.io.

Points forts

  • Création rapide de diagrammes sans outil graphique
  • Export avec XML intégré pour réédition
  • Support de multiples formats (flowchart, ERD, architecture)

Limites

  • Nécessite draw.io CLI pour l'export
  • La génération XML peut être complexe pour des schémas très détaillés
  • Pas de rendu visuel direct dans le terminal
Quand l'utiliser

Lorsque vous devez produire un diagramme modifiable et exportable dans un format standard.

Quand l'éviter

Pour des diagrammes très simples qui pourraient être décrits en texte ou en markdown.

Analyse de sécurité

Sûr
Score qualité95/100

The skill generates draw.io XML files and optionally exports them using the local draw.io CLI. It does not involve network requests, sensitive data exfiltration, or arbitrary code execution. The CLI commands are constrained and use fixed arguments, presenting no meaningful risk.

Aucun point d'attention détecté

Comment cette analyse est faite

Exemples

Create a flowchart
drawio create a flowchart for user login
Export as PNG
drawio png flowchart for login
Export as SVG
drawio svg: ER diagram for a database schema

name: drawio description: Always use when user asks to create, generate, draw, or design a diagram, flowchart, architecture diagram, ER diagram, sequence diagram, class diagram, network diagram, mockup, wireframe, or UI sketch, or mentions draw.io, drawio, drawoi, .drawio files, or diagram export to PNG/SVG/PDF.

Draw.io Diagram Skill

Generate draw.io diagrams as native .drawio files. Optionally export to PNG, SVG, or PDF with the diagram XML embedded (so the exported file remains editable in draw.io).

How to create a diagram

  1. Generate draw.io XML in mxGraphModel format for the requested diagram
  2. Write the XML to a .drawio file in the current working directory using the Write tool
  3. If the user requested an export format (png, svg, pdf), locate the draw.io CLI (see below), export with --embed-diagram, then delete the source .drawio file. If the CLI is not found, keep the .drawio file and tell the user they can install the draw.io desktop app to enable export, or open the .drawio file directly
  4. Open the result — the exported file if exported, or the .drawio file otherwise. If the open command fails, print the file path so the user can open it manually

Choosing the output format

Check the user's request for a format preference. Examples:

  • /drawio create a flowchart → flowchart.drawio
  • /drawio png flowchart for login → login-flow.drawio.png
  • /drawio svg: ER diagram → er-diagram.drawio.svg
  • /drawio pdf architecture overview → architecture-overview.drawio.pdf

If no format is mentioned, just write the .drawio file and open it in draw.io. The user can always ask to export later.

Supported export formats

| Format | Embed XML | Notes | |--------|-----------|-------| | png | Yes (-e) | Viewable everywhere, editable in draw.io | | svg | Yes (-e) | Scalable, editable in draw.io | | pdf | Yes (-e) | Printable, editable in draw.io | | jpg | No | Lossy, no embedded XML support |

PNG, SVG, and PDF all support --embed-diagram — the exported file contains the full diagram XML, so opening it in draw.io recovers the editable diagram.

draw.io CLI

The draw.io desktop app includes a command-line interface for exporting.

Locating the CLI

First, detect the environment, then locate the CLI accordingly:

WSL2 (Windows Subsystem for Linux)

WSL2 is detected when /proc/version contains microsoft or WSL:

grep -qi microsoft /proc/version 2>/dev/null && echo "WSL2"

On WSL2, use the Windows draw.io Desktop executable via /mnt/c/...:

DRAWIO_CMD=`/mnt/c/Program Files/draw.io/draw.io.exe`

The backtick quoting is required to handle the space in Program Files in bash.

If draw.io is installed in a non-default location, check common alternatives:

# Default install path
`/mnt/c/Program Files/draw.io/draw.io.exe`

# Per-user install (if the above does not exist)
`/mnt/c/Users/$WIN_USER/AppData/Local/Programs/draw.io/draw.io.exe`

macOS

/Applications/draw.io.app/Contents/MacOS/draw.io

Linux (native)

drawio   # typically on PATH via snap/apt/flatpak

Windows (native, non-WSL2)

"C:\Program Files\draw.io\draw.io.exe"

Use which drawio (or where drawio on Windows) to check if it's on PATH before falling back to the platform-specific path.

Export command

drawio -x -f <format> -e -b 10 -o <output> <input.drawio>

WSL2 example:

`/mnt/c/Program Files/draw.io/draw.io.exe` -x -f png -e -b 10 -o diagram.drawio.png diagram.drawio

Key flags:

  • -x / --export: export mode
  • -f / --format: output format (png, svg, pdf, jpg)
  • -e / --embed-diagram: embed diagram XML in the output (PNG, SVG, PDF only)
  • -o / --output: output file path
  • -b / --border: border width around diagram (default: 0)
  • -t / --transparent: transparent background (PNG only)
  • -s / --scale: scale the diagram size
  • --width / --height: fit into specified dimensions (preserves aspect ratio)
  • -a / --all-pages: export all pages (PDF only)
  • -p / --page-index: select a specific page (1-based)

Opening the result

| Environment | Command | |-------------|---------| | macOS | open <file> | | Linux (native) | xdg-open <file> | | WSL2 | cmd.exe /c start "" "$(wslpath -w <file>)" | | Windows | start <file> |

WSL2 notes:

  • wslpath -w <file> converts a WSL2 path (e.g. /home/user/diagram.drawio) to a Windows path (e.g. C:\Users\...). This is required because cmd.exe cannot resolve /mnt/c/... style paths.
  • The empty string "" after start is required to prevent start from interpreting the filename as a window title.

WSL2 example:

cmd.exe /c start "" "$(wslpath -w diagram.drawio)"

File naming

  • Use a descriptive filename based on the diagram content (e.g., login-flow, database-schema)
  • Use lowercase with hyphens for multi-word names
  • For export, use double extensions: name.drawio.png, name.drawio.svg, name.drawio.pdf — this signals the file contains embedded diagram XML
  • After a successful export, delete the intermediate .drawio file — the exported file contains the full diagram

XML format

A .drawio file is native mxGraphModel XML. Always generate XML directly — Mermaid and CSV formats require server-side conversion and cannot be saved as native files.

Basic structure

Every diagram must have this structure:

<mxGraphModel adaptiveColors="auto">
  <root>
    <mxCell id="0"/>
    <mxCell id="1" parent="0"/>
    <!-- Diagram cells go here with parent="1" -->
  </root>
</mxGraphModel>
  • Cell id="0" is the root layer
  • Cell id="1" is the default parent layer
  • All diagram elements use parent="1" unless using multiple layers

Consult references/xml-reference.md for common styles, style properties, edge routing details (including waypoints), and container/group examples.

Edge routing

CRITICAL: Every edge mxCell must contain a <mxGeometry relative="1" as="geometry" /> child element, even when there are no waypoints. Self-closing edge cells (e.g. <mxCell ... edge="1" ... />) are invalid and will not render correctly. Always use the expanded form:

<mxCell id="e1" edge="1" parent="1" source="a" target="b" style="...">
  <mxGeometry relative="1" as="geometry" />
</mxCell>
  • Use edgeStyle=orthogonalEdgeStyle for right-angle connectors (most common)
  • Space nodes generously — prefer 200px horizontal / 120px vertical gaps
  • Leave room for arrowheads — at least 20px of straight segment before the target
  • Add explicit waypoints when edges would overlap
  • Align all nodes to a grid (multiples of 10)
  • Edge labels: Do NOT wrap edge labels in HTML markup to reduce font size. The default font size for edge labels is already 11px (vs 12px for vertices), so they are already smaller. Just set the value attribute directly.

See references/xml-reference.md for full edge routing and container guidance.

Containers and groups

Use parent-child containment (parent="containerId") for nested elements — do not just stack shapes. Children use relative coordinates within the container. See references/xml-reference.md for container types, rules, and examples.

Dark mode colors

draw.io supports automatic dark mode rendering. How colors behave depends on the property:

  • strokeColor, fillColor, fontColor default to "default", which renders as black in light theme and white in dark theme. When no explicit color is set, colors adapt automatically.
  • Explicit colors (e.g. fillColor=#DAE8FC) specify the light-mode color. The dark-mode color is computed automatically by inverting the RGB values (blending toward the inverse at 93%) and rotating the hue by 180° (via mxUtils.getInverseColor).
  • light-dark() function — To specify both colors explicitly, use light-dark(lightColor,darkColor) in the style string, e.g. fontColor=light-dark(#7EA6E0,#FF0000). The first argument is used in light mode, the second in dark mode.

To enable dark mode color adaptation, the mxGraphModel element must include adaptiveColors="auto".

When generating diagrams, you generally do not need to specify dark-mode colors — the automatic inversion handles most cases. Use light-dark() only when the automatic inverse color is unsatisfactory.

Style reference

For the complete draw.io style reference: https://www.drawio.com/doc/faq/drawio-style-reference.html

For the XML Schema Definition (XSD): https://www.drawio.com/assets/mxfile.xsd

Troubleshooting

| Problem | Cause | Solution | |---------|-------|----------| | draw.io CLI not found | Desktop app not installed or not on PATH | Keep the .drawio file and tell the user to install the draw.io desktop app, or open the file manually | | Export produces empty/corrupt file | Invalid XML (e.g. double hyphens in comments, unescaped special characters) | Validate XML well-formedness before writing; see the XML well-formedness section below | | Diagram opens but looks blank | Missing root cells id="0" and id="1" | Ensure the basic mxGraphModel structure is complete | | Edges not rendering | Edge mxCell is self-closing (no child mxGeometry element) | Every edge must have <mxGeometry relative="1" as="geometry" /> as a child element | | File won't open after export | Incorrect file path or missing file association | Print the absolute file path so the user can open it manually |

CRITICAL: XML well-formedness

  • NEVER use double hyphens (--) inside XML comments. -- is illegal inside <!-- --> per the XML spec and causes parse errors. Use single hyphens or rephrase.
  • Escape special characters in attribute values: &amp;, &lt;, &gt;, &quot;
  • Always use unique id values for each mxCell

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/draw-io-diagram-generation-mrwak9yd/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/draw-io-diagram-generation-mrwak9yd' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/draw-io-diagram-generation-mrwak9yd/download' --output '.skill-downloads/draw-io-diagram-generation-mrwak9yd/SKILL.md.part' && mv '.skill-downloads/draw-io-diagram-generation-mrwak9yd/SKILL.md.part' '.skill-downloads/draw-io-diagram-generation-mrwak9yd/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/draw-io-diagram-generation-mrwak9yd/SKILL.md' && test -s '.skill-downloads/draw-io-diagram-generation-mrwak9yd/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/drawio' && cp -R '.skill-downloads/draw-io-diagram-generation-mrwak9yd' '.claude/skills/drawio'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/draw-io-diagram-generation-mrwak9yd'

openskills read 'draw-io-diagram-generation-mrwak9yd'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/draw-io-diagram-generation-mrwak9yd/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires