Back to Documentation & Writing

draw-io

draw.iodiagramsXML editingPNG conversiondocumentationAWS architecturevisualstechnical drawing
2.0k📄 MIT🕒 2026-03-05Source ↗

Install this skill

npx skills add softaworks/agent-toolkit

Works across Claude Code, Cursor, Codex, Copilot & Antigravity

The draw-io skill provides a structured framework for managing technical diagrams within the softaworks agent-toolkit. It emphasizes XML-based manipulation of .drawio source files to ensure consistent visual output for documentation and presentations. By enforcing strict formatting rules for font families, coordinate positioning, and layered element management, the skill ensures that visual assets remain readable and accessible. It integrates directly with project pre-commit hooks to automate the conversion of source XML into high-resolution, transparent PNGs, preventing the need for manual image editing. The workflow prioritizes clarity and design consistency across complex system diagrams, data flows, and sequence charts, making it essential for teams maintaining large-scale architectural documentation that requires frequent updates and high alignment accuracy.

When to Use This Skill

  • Maintaining consistent architectural diagrams across evolving documentation sets
  • Generating transparent, high-DPI visuals for Quarto-based slide decks
  • Managing complex data flow or sequence diagrams with precise alignment requirements
  • Standardizing service component representations in deployment configurations

How to Invoke This Skill

Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:

  • convert my drawio diagrams to png
  • update the diagram layout in the documentation
  • fix the font size and style in this drawio file
  • add a new system component to the architecture diagram
  • re-export all diagrams for the latest presentation

Pro Tips

  • 💡Always specify `defaultFontFamily` in the `mxGraphModel` tag for project-wide consistency and ensure individual text elements explicitly define `fontFamily` to prevent rendering issues.
  • 💡Utilize the `-s 2` option during PNG conversion to generate high-resolution images, perfect for retina displays or print, ensuring clarity without manual scaling.
  • 💡Integrate the conversion script into your pre-commit hooks to automatically update PNGs whenever `.drawio` files are modified, maintaining up-to-date visuals effortlessly.

What this skill does

  • Automated XML-to-PNG conversion pipeline via pre-commit hooks
  • Precise coordinate-based layout adjustment for internal elements
  • Standardized font handling and styling for Quarto presentation compatibility
  • Metadata injection for improved diagram discoverability and versioning
  • Advanced edge labeling and arrow routing with explicit coordinate placement

When not to use it

  • Interactive or high-fidelity UI/UX mockups where XML manipulation is inefficient
  • Projects lacking the required pre-commit automation infrastructure
  • Diagrams requiring frequent, ad-hoc drag-and-drop editing by non-technical stakeholders

Example workflow

  1. Update the target .drawio file using standard XML structure
  2. Adjust the mxGeometry tags for precise element positioning
  3. Apply specific font families and styles to text elements
  4. Commit changes to the repository to trigger the pre-commit hook
  5. Verify the auto-generated .drawio.png file for transparency and scale

Prerequisites

  • drawio command line tool installed
  • Project-level pre-commit hook configuration
  • Mise environment manager

Pitfalls & limitations

  • !Directly editing .drawio.png files instead of the XML source
  • !Miscalculating coordinate offsets leading to element overlaps
  • !Incorrect line breaks in Japanese text labels due to insufficient width definitions
  • !Failing to remove hardcoded background colors, causing visual mismatch on dark themes

FAQ

Why should I avoid editing .drawio.png files directly?
The .drawio.png files are auto-generated from the XML source. Manual edits are lost whenever the conversion script runs.
How do I ensure my labels have proper line breaks?
Use the <br> tag within the value attribute and ensure the width of the mxGeometry box is sufficient, typically allocating 30-40px per character.
How do I place arrows behind other elements?
Place arrow definitions in the XML file immediately after the title element but before other foreground components to ensure correct z-index layering.

How it compares

Unlike manual GUI-based editing, this skill uses a programmatic XML approach that guarantees reproducible layouts and seamless integration into automated CI/CD documentation pipelines.

Source & trust

2.0k stars📄 MIT🕒 Updated 2026-03-05
📄 Full skill instructions — original source: softaworks/agent-toolkit
# draw.io Diagram Skill

## 1. Basic Rules

- Edit only .drawio files
- Do not directly edit .drawio.png files
- Use auto-generated .drawio.png by pre-commit hook in slides

## 2. Font Settings

For diagrams used in Quarto slides,
specify defaultFontFamily in mxGraphModel tag:

<mxGraphModel defaultFontFamily="Noto Sans JP" ...>


Also explicitly specify fontFamily in each text element's style attribute:

style="text;html=1;fontSize=27;fontFamily=Noto Sans JP;"


## 3. Conversion Commands

See conversion script at [scripts/convert-drawio-to-png.sh](scripts/convert-drawio-to-png.sh).

# Convert all .drawio files
mise exec -- pre-commit run --all-files

# Convert specific .drawio file
mise exec -- pre-commit run convert-drawio-to-png --files assets/my-diagram.drawio

# Run script directly (using skill's script)
bash ~/.claude/skills/draw-io/scripts/convert-drawio-to-png.sh assets/diagram1.drawio


Internal command used:

drawio -x -f png -s 2 -t -o output.drawio.png input.drawio


| Option | Description |
|--------|-------------|
| -x | Export mode |
| -f png | PNG format output |
| -s 2 | 2x scale (high resolution) |
| -t | Transparent background |
| -o | Output file path |

## 4. Layout Adjustment

### 4.1. Coordinate Adjustment Steps

1. Open .drawio file in text editor (plain XML format)
2. Find mxCell for element to adjust (search by value attribute for text)
3. Adjust coordinates in mxGeometry tag
- x: Position from left
- y: Position from top
- width: Width
- height: Height
4. Run conversion and verify

### 4.2. Coordinate Calculation

- Element center coordinate = y + (height / 2)
- To align multiple elements, calculate and match center coordinates

## 5. Design Principles

### 5.1. Basic Principles

- Clarity: Create simple, visually clean diagrams
- Consistency: Unify colors, fonts, icon sizes, line thickness
- Accuracy: Do not sacrifice accuracy for simplification

### 5.2. Element Rules

- Label all elements
- Use arrows to indicate direction
(prefer 2 unidirectional arrows over bidirectional)
- Use latest official icons
- Add legend to explain custom symbols

### 5.3. Accessibility

- Ensure sufficient color contrast
- Use patterns in addition to colors

### 5.4. Progressive Disclosure

Separate complex systems into staged diagrams:

| Diagram Type | Purpose |
|--------------|---------|
| Context Diagram | System overview from external perspective |
| System Diagram | Main components and relationships |
| Component Diagram | Technical details and integration points |
| Deployment Diagram | Infrastructure configuration |
| Data Flow Diagram | Data flow and transformation |
| Sequence Diagram | Time-series interactions |

### 5.5. Metadata

Include title, description, last updated, author, and version in diagrams.

## 6. Best Practices

### 6.1. Background Color

- Remove background="#ffffff"
- Transparent background adapts to various themes

### 6.2. Font Size

- Use 1.5x standard font size (around 18px) for PDF readability

### 6.3. Japanese Text Width

- Allow 30-40px per character
- Insufficient width causes unintended line breaks

<!-- For 10-character text, allow 300-400px -->
<mxGeometry x="140" y="60" width="400" height="40" />


### 6.4. Arrow Placement

- Always place arrows at back (position in XML right after Title)
- Position arrows to avoid overlapping with labels
- Keep arrow start/end at least 20px from label bottom edge

<!-- Title -->
<mxCell id="title" value="..." .../>

<!-- Arrows (back layer) -->
<mxCell id="arrow1" style="edgeStyle=..." .../>

<!-- Other elements (front layer) -->
<mxCell id="box1" .../>


### 6.5. Arrow Connection to Text Labels

For text elements, exitX/exitY don't work, so use explicit coordinates:

<!-- Good: Explicit coordinates with sourcePoint/targetPoint -->
<mxCell id="arrow" style="..." edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="1279" y="500" as="sourcePoint"/>
<mxPoint x="119" y="500" as="targetPoint"/>
<Array as="points">
<mxPoint x="1279" y="560"/>
<mxPoint x="119" y="560"/>
</Array>
</mxGeometry>
</mxCell>


### 6.6. edgeLabel Offset Adjustment

Adjust offset attribute to distance arrow labels from arrows:

<!-- Place above arrow (negative value to distance) -->
<mxPoint x="0" y="-40" as="offset"/>

<!-- Place below arrow (positive value to distance) -->
<mxPoint x="0" y="40" as="offset"/>


### 6.7. Remove Unnecessary Elements

- Remove decorative icons irrelevant to context
- Example: If ECR exists, separate Docker icon is unnecessary

### 6.8. Labels and Headings

- Service name only: 1 line
- Service name + supplementary info: 2 lines with line break
- Redundant notation (e.g., ECR Container Registry): shorten to 1 line
- Use &lt;br&gt; tag for line breaks

### 6.9. Background Frame and Internal Element Placement

When placing elements inside background frames (grouping boxes),
ensure sufficient margin.

- YOU MUST: Internal elements must have at least 30px margin from frame boundary
- YOU MUST: Account for rounded corners (rounded=1) and stroke width
- YOU MUST: Always visually verify PNG output for overflow

Coordinate calculation verification:

Background frame: y=20, height=400 -> range is y=20-420
Internal element top: frame y + 30 or more (e.g., y=50)
Internal element bottom: frame y + height - 30 or less (e.g., up to y=390)


Bad example (may overflow):

<!-- Background frame -->
<mxCell id="bg" style="rounded=1;strokeWidth=3;...">
<mxGeometry x="500" y="20" width="560" height="400" />
</mxCell>
<!-- Text: y=30 is too close to frame top (y=20) -->
<mxCell id="label" value="Title" style="text;...">
<mxGeometry x="510" y="30" width="540" height="35" />
</mxCell>


Good example (sufficient margin):

<!-- Background frame -->
<mxCell id="bg" style="rounded=1;strokeWidth=3;...">
<mxGeometry x="500" y="20" width="560" height="430" />
</mxCell>
<!-- Text: y=50 is 30px from frame top (y=20) -->
<mxCell id="label" value="Title" style="text;...">
<mxGeometry x="510" y="50" width="540" height="35" />
</mxCell>


## 7. Reference

- [Layout Guidelines](references/layout-guidelines.md)
- [AWS Icons](references/aws-icons.md)
- [AWS Icon Search Script](scripts/find_aws_icon.py)

AWS icon search examples:

python ~/.claude/skills/draw-io/scripts/find_aws_icon.py ec2
python ~/.claude/skills/draw-io/scripts/find_aws_icon.py lambda


## 8. Checklist

- [ ] No background color set (page="0")
- [ ] Font size appropriate (larger recommended)
- [ ] Arrows placed at back layer
- [ ] Arrows not overlapping labels (verify in PNG)
- [ ] Arrow start/end sufficiently distant from labels (at least 20px)
- [ ] Arrows not penetrating boxes or icons (verify in PNG)
- [ ] Internal elements not overflowing background frame (verify in PNG)
- [ ] 30px+ margin between background frame and internal elements
- [ ] AWS service names are official names/correct abbreviations
- [ ] AWS icons are latest version (mxgraph.aws4.*)
- [ ] No unnecessary elements remaining
- [ ] Visually verified PNG conversion

## 9. Image Display in reveal.js Slides

Add auto-stretch: false to YAML header:

---
title: "Your Presentation"
format:
revealjs:
auto-stretch: false
---


This ensures correct image display on mobile devices.

How to Use This Skill Unit

Option A: Project-Specific (Recommended)

  1. Click "Download" above
  2. In your project, create the directory: .agent/skills/draw-io/
  3. Save the file as SKILL.md
  4. The agent will automatically discover the skill based on its description.

Option B: Global Installation (All Agents)

Save the file to these locations to make it available across all projects:

  • Claude Code: ~/.claude/skills/softaworks/agent-toolkit/draw-io/SKILL.md
  • Cursor: ~/.cursor/skills/softaworks/agent-toolkit/draw-io/SKILL.md
  • Antigravity: ~/.gemini/antigravity/skills/softaworks/agent-toolkit/draw-io/SKILL.md

🚀 Install with CLI:
npx skills add softaworks/agent-toolkit

Read the Master Guide: Mastering Agent Skills

Recommended Rules

View more rules

Recommended Workflows

View more workflows

Recommended MCP Servers

View more MCP servers

Take It Further

Maximize your productivity with these powerful resources

📋

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
📖

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide

How to use this Skill in Claude Code & Cursor

For Claude Code (CLI)

To use this skill in Claude Code, copy the rule content into your project's custom instructions or follow our Add-Skill CLI guide. This ensures Claude follows your standards during every code generation.

For Cursor & Windsurf

For Cursor or Windsurf, individual skills are best used in the "Rules for AI" section. This specific unit helps the agent avoid documentation & writing issues, leading to cleaner, more efficient code.

Why the skill format matters: the standardized Agent Skills format lets your AI agent load detailed instructions only when they are relevant, keeping your prompt clean while improving results.

Source & attribution

This skill is categorized under Documentation & Writing and is published by Softaworks, maintained in softaworks/agent-toolkit.

← Browse All Agent Skills
Sponsored AI assistant. Recommendations may be paid.