Draw.io Diagram Expert
This skill is responsible for converting users' diagram requirements into
files, and exporting them as PNG, SVG, or PDF when needed.
The main file only retains task routing, workflows, and acceptance rules. Detailed styles, XML templates, export commands, and examples are read from
as needed.
When to Use
Prioritize using this skill in the following scenarios:
- Users explicitly request , , or files
- Users request to generate flowcharts, architecture diagrams, sequence diagrams, ER diagrams, state machine diagrams, or mind maps
- Users want to export diagrams as PNG/SVG/PDF
- Users need illustrations for technical articles, tutorials, or system design documents
- Users provide an article and hope to extract multiple technical diagrams into a single draw.io file
Scenarios not suitable for this skill:
- Users only want Mermaid code and don't need files
- Users require bitmap illustrations, posters, or whiteboard-style body illustrations instead of structured diagrams
- Users are only discussing diagram ideas and don't want to actually generate files yet
Reference Routing
Read corresponding reference files according to task needs; do not load all reference content into the context by default:
| Requirement | File to Read |
|---|
| Colors, fonts, node semantics, connection styles, visual consistency specifications | |
| XML structure rules, text label rules, node/connection templates, structure suggestions for different diagram types | references/xml-and-layout.md
|
| Export commands, file naming, opening methods, delivery rules | references/export-and-files.md
|
| Common prompts, single/multi-diagram article illustration examples, batch page generation methods | |
Core Rules
- By default, first generate the native file, then decide whether to export based on user requirements.
- If users explicitly request export to PNG/SVG/PDF, still keep the file as the source file unless users explicitly request deletion.
- When outputting diagrams, prioritize clear information structure first, then visual consistency; do not sacrifice readability for "good looks".
- Use plain text for in diagrams by default, avoid embedding HTML tags.
- Keep connection labels short; prioritize placing long descriptions inside nodes or in side note nodes.
- Avoid explaining basic concepts if possible; reserve context for constraints that truly affect drawing results.
Diagram Type Selection
Choose diagrams based on content structure, do not mechanically apply templates:
- Process steps, decision branches, algorithm logic: Flowchart
- Module relationships, service dependencies, deployment layers: Architecture diagram
- Service calls, message interactions, sequential processes: Sequence diagram
- Entities, fields, primary/foreign key relationships: ER diagram
- Lifecycle, state transitions, event-driven processes: State machine diagram
- Concept sorting, knowledge organization, hierarchical expansion: Mind map
If users specify a diagram type, follow their request first; only briefly remind and suggest alternatives if users clearly choose the wrong diagram type.
Workflow
1. Identify Task Mode
First determine which type the current task belongs to:
- Single diagram generation
- Single diagram generation and export
- Multiple diagrams generation from one article
- Modify existing file
2. Collect Minimum Necessary Input
At least clarify the following information:
- Diagram topic
- Target diagram type
- Key nodes / modules / entities / steps
- Relationships between nodes
- Whether export is needed, and the export format
If user information is incomplete but can be reasonably inferred, directly infer and explain in the result; only follow up when key structural information is missing.
3. Read Corresponding Reference Materials
- Read when unified visual style is required
- Read
references/xml-and-layout.md
when generating XML or judging layout
- Read
references/export-and-files.md
when exporting or naming files
- Read when showing users common prompts or article illustration modes
4. Plan First, Then Generate
Before generation, clarify internally:
- Which diagram type to adopt
- Whether the page is a single diagram or multiple
- How to layout node groups
- Which connections need labels and which don't
Do not临时 decide structure while writing XML.
5. Generate File
Follow this order when generating:
- Title
- Containers / Groups
- Core nodes
- Connections
- Labels and side notes
6. Export or Open
- Execute export only when users request it
- By default, deliver file when users only request generation
- If CLI is not available locally, clearly inform users that automatic export is not possible, but the file has been generated
Multi-Diagram Article Mode
When users provide an article and request "generate multiple technical illustrations", follow these rules:
- First extract 2-6 structures from the article that are most worth diagramming
- Each structure corresponds to an independent
- The main file name defaults to match the article file name
- Page names use lowercase English with hyphens
- Avoid squeezing all knowledge points of the entire article into one large diagram
For more detailed examples and prompt writing, read
.
Verification Checklist
Check at least the following before delivery:
- Whether the diagram type matches the task
- Whether main nodes are complete and relationships are drawn correctly
- Whether connection directions and semantics are clearly stated
- Whether text is concise and not overcrowded
- Whether HTML tags are mixed into
- Whether export file names comply with naming specifications
- If it's a multi-page file, whether page names are clear and consistent
Failure Handling
- If user requirements are too vague, first present the inferred diagram structure, then explain your assumptions
- If export fails, retain the file, report the failure reason and manually executable export commands
- If the content requested by users is more suitable for Mermaid or image illustrations, clearly explain and suggest using a more appropriate method
Output Requirements
- Default to return the generated file path
- If export is executed, return both the generated and exported file paths
- If there are assumptions, deletions, or structural adjustments, explain in one sentence