Tell Claude to Draw: Diagrams with /drawio in Claude Code

Tell Claude to Draw: Diagrams with /drawio in Claude Code

You’re describing an architecture to Claude Code. The response includes detailed ASCII art that almost works, but not quite. You think: “I wish I could just tell it to draw this.”

Turns out, you can.

The draw.io skill for Claude Code adds a /drawio slash command that turns natural language into native .drawio diagram files. Describe what you want, and Claude generates the XML, writes the file, and optionally exports to PNG, SVG, or PDF. No MCP server, no API key, no running a separate service.

What the Skill Does Differently

The skill is a single SKILL.md file you drop into your Claude Code skills directory. When you type /drawio, Claude reads the skill instructions, generates mxGraphModel XML for your requested diagram, and writes it to a .drawio file in your project. If you ask for PNG/SVG/PDF, it also runs the draw.io desktop CLI with —embed-diagram to produce a shareable file that stays editable.

It sits alongside three other approaches in the drawio-mcp project — MCP App Server (inline diagrams in chat), MCP Tool Server (open in browser), and Project Instructions (no install needed):

  • MCP App Server renders interactive diagrams inline for Claude.ai and VS Code via a hosted endpoint at mcp.draw.io
  • MCP Tool Server opens diagrams in your browser via an npm package, supports XML, CSV, and Mermaid
  • Skill + CLI generates local .drawio files, ideal for Claude Code development workflows
  • Project Instructions teach Claude to generate draw.io URLs via Python, zero install

The skill route is the simplest for local development. No server process, no port management, no MCP configuration. Just a file and a slash command.

When to Use It

Architecture documentation — Ask Claude to diagram your service architecture mid-conversation. It generates the .drawio file from the same context it’s been building.

Database schema visualization — After Claude helps you design a schema, ask it to generate the ER diagram. The diagram is based on the actual schema it just helped you write.

API flow diagrams — Map out endpoint interactions during design review. Claude already knows the code, so the diagram reflects reality.

PR documentation — Generate a before/after architecture diagram for your pull request. Drop the exported PNG directly into the PR description.

The Sharp Edges

Export requires draw.io Desktop. The skill can always write .drawio files, but PNG/SVG/PDF export depends on the draw.io desktop CLI being installed. Without it, you get a .drawio file you can open in the app — fine for editing, less convenient for sharing.

XML quality depends on the reference. Claude follows the shared XML reference from the drawio-mcp repo. Complex layouts with many overlapping edges may need manual cleanup. The npx @drawio/postprocess tool helps with edge routing but is optional.

Not all diagrams need this. A quick flowchart for a brainstorming session is faster with pen and paper. The skill shines when the diagram needs to be accurate, version-controlled, and derived from code.

Installation

Copy the skill file to your Claude Code skills directory. That’s it.

Global install (all projects):

mkdir -p ~/.claude/skills/drawio
cp drawio/SKILL.md ~/.claude/skills/drawio/SKILL.md

Per-project install:

mkdir -p .claude/skills/drawio
cp drawio/SKILL.md .claude/skills/drawio/SKILL.md

For PNG/SVG/PDF export, also install draw.io Desktop from https://www.drawio.com.

That’s the entire setup. No npm install, no MCP config, no running a server.

Usage

In Claude Code, use the /drawio slash command:

/drawio create a flowchart for user login

To export to an image format, mention it in the request:

/drawio png flowchart for user login
/drawio svg: ER diagram for e-commerce
/drawio pdf architecture overview

Claude generates the XML, writes the file, and opens it. The file naming follows a convention:

  • /drawio create a flowchart for user login -> login-flow.drawio
  • /drawio png flowchart for user login -> login-flow.drawio.png
  • /drawio svg: ER diagram for e-commerce -> er-diagram.drawio.svg

For export formats, the intermediate .drawio file is deleted after export since the PNG/SVG/PDF already contains the embedded diagram XML.

The skill also supports more complex requests:

/drawio sequence diagram for API auth
/drawio png class diagram for the models in src/

How It Works Under the Hood

When you type /drawio, Claude does three things:

First, it reads the skill instructions which include the shared XML reference from the drawio-mcp repo — covering cell types, style properties, edge routing, containers, layers, and dark mode.

Second, it generates the mxGraphModel XML in the standard .drawio format:

<mxGraphModel adaptiveColors="auto">
  <root>
    <mxCell id="0"/>
    <mxCell id="1" parent="0"/>
    ...
  </root>
</mxGraphModel>

Third, it writes the file. If you requested an export, it calls the draw.io desktop CLI:

drawio -x -f png -e -b 10 -o diagram.drawio.png diagram.drawio

The whole pipeline — from natural language to diagram file — happens in a single Claude Code interaction.

End-to-End Example: Architecture Diagram Mid-Session

You’re building a microservices app and discussing the architecture with Claude Code:

You: /drawio png architecture for my microservices app with
     api-gateway, user-service, payment-service, and a shared database

Claude generates a .drawio file with all services as boxes, labeled and arranged on a grid. It draws edges from api-gateway to each service, then from each service to the database. After generation, it runs the export CLI and produces architecture.drawio.png — ready to drop into your docs.

The whole thing takes seconds. You didn’t open draw.io once.


The draw.io skill turns Claude Code into a diagramming tool that speaks your architecture. Describe the system, get the file.

If you’re already using Claude Code for development, adding /drawio is copying one file. The question is why you haven’t done it yet.

GitHub: https://github.com/jgraph/drawio-mcp Skill docs: https://github.com/jgraph/drawio-mcp/blob/main/skill-cli/README.md draw.io Desktop: https://www.drawio.com

Related Posts

22 Claude Code Skills for End-to-End Content Creation: From Generation to Publish in One Workflow

22 Claude Code Skills for End-to-End Content Creation: From Generation to Publish in One Workflow

You finish a technical blog post. Now comes the headache: generate a cover image, create illustratio ...

Why Claude's Team Is Ditching Markdown as AI Output Explodes from 10 to 1,000 Lines

Why Claude's Team Is Ditching Markdown as AI Output Explodes from 10 to 1,000 Lines

Your AI can now generate 1,000-line plans, complex flowcharts, and full code reviews in one shot. An ...

How to Turn Real-World Capabilities Into an Agent Skill

General-purpose AI agents are powerful, but they lack the one thing every team has: **procedural kno ...

AI Agent Skill: Caveman Mode Cuts 75% Output Tokens Without Losing Accuracy

AI Agent Skill: Caveman Mode Cuts 75% Output Tokens Without Losing Accuracy

Your AI agent talks too much. Every "Sure! I'd be happy to help you with that" is a wasted token tha ...

Karpathy's Fix for Claude Code: Four Principles That Kill Bloated AI Code

Andrej Karpathy put his finger on it: LLMs make wrong assumptions and run with them. They overcompli ...

Style × Layout: How baoyu-skills' Visual Design System Makes AI Draw Better Than You Can Design

You ask AI to draw a picture. It gives you oversaturated, plastic-looking junk. You ask AI to make a ...

Book2Skills: turn books into agent skills that actually work

Book2Skills: turn books into agent skills that actually work

Book2Skills is an open-source project that distills classic book methodologies into structured AI ag ...