跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
文档处理

bruce-drawio

**Use this skill** when the user wants to create any diagram: flowchart, architecture, UML (sequence/class), ER, mindmap, network topology, or any visual diagram. Trigger words: "draw", "diagram", "flowchart", "architecture", "UML", "sequence diagram", "mindmap", "ER diagram", "network topology", "visualize", "draw.io", "drawio". Workflow: understand requirements -> generate drawio XML directly -> validate -> CLI export PNG/SVG/PDF, falling back to an app.diagrams.net browser link when draw.io desktop is unavailable.

bruc3van · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add bruc3van/bruce-drawio --skill bruce-drawio

技能说明


name: bruce-drawio description: | Use this skill when the user wants to create any diagram: flowchart, architecture, UML (sequence/class), ER, mindmap, network topology, or any visual diagram.

Trigger words: "draw", "diagram", "flowchart", "architecture", "UML", "sequence diagram", "mindmap", "ER diagram", "network topology", "visualize", "draw.io", "drawio".

Workflow: understand requirements -> generate drawio XML directly -> validate -> CLI export PNG/SVG/PDF, falling back to an app.diagrams.net browser link when draw.io desktop is unavailable.

Draw.io Diagram Generator

Workflow

Each numbered step below has a matching ## Step N section. Follow them in order.

1. Understand requirements   -> determine diagram type, elements, relationships
2. Generate XML directly     -> write drawio XML; read the matching reference section first
3. Apply layout rules        -> coordinates, spacing, sizes, cell order
4. Save + validate (DO NOT SKIP) -> write the .drawio file, run the validator, fix every error
5. CLI export (optional)     -> call draw.io desktop CLI to export an image (skip if not installed)
6. Browser link (conditional) -> only when the export failed, or the user asks for it
7. Deliver to user           -> image + .drawio file path, kept short

Steps 5 and 6 are two routes to the same goal, not two deliverables to stack up. Export is the default. The browser link is the fallback that needs nothing installed — it guarantees the user can always see the diagram, so it is never a dead end, but it is also a detached copy of the file (Step 6d) and should not be pushed on a user who already has an image.

Step 1: Understand Requirements

Determine:

  • Diagram type: flowchart / architecture / uml-sequence / uml-class / er / mindmap / network
  • Key elements: nodes, components, participants, entities
  • Relationships: connections, dependencies, flow direction
  • Output format: PNG (default) / SVG / PDF
  • Language: match the user's language for labels

Step 2: Generate XML

You MUST write the XML directly. Do not call any script to generate it.

Read the matching reference first

Diagram typeRead before writing
Architecturereferences/best-practices.md → Architecture Diagram Templates, then references/examples.md → Example 2
Flowchartreferences/examples.md → Example 1
Mindmapreferences/examples.md → Example 3
ERreferences/examples.md → Example 4
UML sequence/class, network, anything elsereferences/best-practices.md → General Rules, then write from your own knowledge

references/examples.md holds complete, validated diagrams — copying the structure of the closest example is faster and more reliable than composing one from scratch. Read only the sections you need, not the whole file.

Base XML Structure

<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="app.diagrams.net" agent="drawio-skill" version="21.0.0" type="device">
  <diagram name="DiagramName" id="diagram-1">
    <mxGraphModel dx="1422" dy="762"
                   grid="1" gridSize="10"
                   guides="1" tooltips="1" connect="1"
                   arrows="1" fold="1"
                   page="1" pageScale="1"
                   pageWidth="1600" pageHeight="1200"
                   math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />

        <!-- nodes and edges here -->

      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

Node Template

<mxCell id="node-1" value="Label"
        style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=14;"
        vertex="1" parent="1">
  <mxGeometry x="100" y="100" width="160" height="60" as="geometry" />
</mxCell>

Text Content Rules

  • For multi-line labels, encode line breaks as &#xa; inside value, for example value="API&#xa;Gateway"
  • Do not write literal \n inside value; draw.io will render it as backslash + n text
  • Keep html=1 on nodes, but still use &#xa; as the default line-break form for predictable output

Edge Template

<mxCell id="edge-1" value=""
        style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;"
        edge="1" parent="1" source="node-1" target="node-2">
  <mxGeometry relative="1" as="geometry" />
</mxCell>

Cell Order Is Z-Order (CRITICAL)

draw.io paints cells in document order: whatever comes later in <root> is drawn on top. Emit cells back-to-front:

1. Background plate      (the big gray rectangle, if any)
2. Layer containers      (semi-transparent blocks)
3. Sub-group containers
4. Leaf nodes / labels
5. Edges

Writing the background rectangle after the nodes hides the entire diagram behind a gray block — this is the single most destructive ordering mistake, and it renders as a blank image with no error anywhere.

Parent and Coordinate System

A cell's x/y are relative to its parent. That gives you two valid approaches, and mixing them is what produces diagrams where everything is shifted off-screen:

ApproachWhenparentCoordinates
Flat + absolute (default)Everything except ER/UML tables, including the Layered Block Style — visual nesting comes from the numbers, not the treealways "1"absolute canvas coordinates
True nestingOnly when the shape genuinely owns its children: swimlane tables (ER, UML class), childLayout=stackLayout rowsthe container's IDrelative to the container's top-left, so a child at y="30" sits 30px below the container's top

Default to flat + absolute. The Layered Block Style puts every leaf node at parent="1" with absolute coordinates even though it looks nested — see `references/examples

阅读完整来源 ↗