npx skills add https://github.com/thomasrohde/marketplace --skill 'DrawIO Diagram Creation'创建具备规范 XML 结构、样式和布局的生产就绪 .drawio 文件。DrawIO (diagrams.net) 使用基于 mxGraph 库构建的 XML 格式。
DrawIO 文件是扩展名为 .drawio 的 XML 文档(也可以是 .drawio.xml 或 .drawio.svg)。该格式使用 mxGraph 的 XML 序列化,内容可以是压缩或未压缩的。
每个 DrawIO 文件都遵循以下结构:
<mxfile host="app.diagrams.net" modified="2024-01-01T00:00:00.000Z" agent="Claude" version="21.0.0" type="device">
<diagram id="diagram-id" name="Page-1">
<mxGraphModel dx="1000" dy="600" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- 形状和连接线放在这里 -->
</root>
</mxGraphModel>
</diagram>
</mxfile>
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
关键元素:
mxfile - 根容器,可以包含多个图表(页面)diagram - 单个页面,具有唯一 id 和名称mxGraphModel - 画布设置(大小、网格、参考线)root - 包含所有单元格(形状和边)mxCell id="0" - 必需的根单元格mxCell id="1" - 所有形状必需的默认父级顶点(形状):
<mxCell id="2" value="Label" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="60" as="geometry" />
</mxCell>
边(连接线):
<mxCell id="3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;" edge="1" parent="1" source="2" target="4">
<mxGeometry relative="1" as="geometry" />
</mxCell>
为每个单元格分配唯一的 ID。使用从 "2" 开始的简单递增模式(0 和 1 是保留的):
<mxCell id="2" ... /> <!-- 第一个形状 -->
<mxCell id="3" ... /> <!-- 第一条边 -->
<mxCell id="4" ... /> <!-- 第二个形状 -->
使用相对于画布原点(左上角)的 x/y 坐标。典型间距:
矩形(默认):
rounded=0;whiteSpace=wrap;html=1;
圆角矩形:
rounded=1;whiteSpace=wrap;html=1;
椭圆/圆形:
ellipse;whiteSpace=wrap;html=1;
菱形(决策):
rhombus;whiteSpace=wrap;html=1;
圆柱体(数据库):
shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;
文档:
shape=document;whiteSpace=wrap;html=1;boundedLbl=1;
流程(带侧线的矩形):
shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;
正交(直角):
edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;
曲线:
edgeStyle=orthogonalEdgeStyle;curved=1;orthogonalLoop=1;jettySize=auto;html=1;
直线:
edgeStyle=none;orthogonalLoop=1;jettySize=auto;html=1;
带箭头:
endArrow=classic;html=1;
虚线:
dashed=1;
添加到样式字符串中:
fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333;fontSize=12;fontStyle=1;strokeWidth=2;常见配色方案:
fillColor=#dae8fc;strokeColor=#6c8ebf;fillColor=#d5e8d4;strokeColor=#82b366;fillColor=#ffe6cc;strokeColor=#d79b00;fillColor=#f8cecc;strokeColor=#b85450;fillColor=#e1d5e7;strokeColor=#9673a6;fillColor=#f5f5f5;strokeColor=#666666;使用矩形表示流程,菱形表示决策,椭圆表示开始/结束:
<!-- 开始 -->
<mxCell id="2" value="Start" style="ellipse;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="200" y="40" width="80" height="40" as="geometry" />
</mxCell>
<!-- 流程 -->
<mxCell id="3" value="Process Step" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="170" y="120" width="140" height="60" as="geometry" />
</mxCell>
<!-- 决策 -->
<mxCell id="4" value="Condition?" style="rhombus;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
<mxGeometry x="180" y="220" width="120" height="80" as="geometry" />
</mxCell>
使用分组容器、服务形状和带标签的连接线:
<!-- 容器/组 -->
<mxCell id="2" value="Backend Services" style="swimlane;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
<mxGeometry x="40" y="40" width="300" height="200" as="geometry" />
</mxCell>
<!-- 容器内的服务 -->
<mxCell id="3" value="API Gateway" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="2">
<mxGeometry x="20" y="40" width="120" height="60" as="geometry" />
</mxCell>
使用垂直的生命线和水平的消息箭头:
<!-- 参与者/生命线头部 -->
<mxCell id="2" value="Client" style="shape=umlLifeline;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=1;collapsible=0;recursiveResize=0;outlineConnect=0;portConstraint=eastwest;newEdgeStyle={"edgeStyle":"elbowEdgeStyle","elbow":"vertical","curved":0,"rounded":0};" vertex="1" parent="1">
<mxGeometry x="100" y="40" width="100" height="300" as="geometry" />
</mxCell>
<!-- 消息 -->
<mxCell id="4" value="request()" style="html=1;verticalAlign=bottom;endArrow=block;edgeStyle=elbowEdgeStyle;elbow=vertical;curved=0;rounded=0;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="150" y="100" as="sourcePoint" />
<mxPoint x="350" y="100" as="targetPoint" />
</mxGeometry>
</mxCell>
使用带列的表形状:
<mxCell id="2" value="users" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="160" height="130" as="geometry" />
</mxCell>
<mxCell id="3" value="id: INT (PK)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;fontStyle=1;" vertex="1" parent="2">
<mxGeometry y="26" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="4" value="email: VARCHAR(255)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="2">
<mxGeometry y="52" width="160" height="26" as="geometry" />
</mxCell>
使用 UML 类形状:
<mxCell id="2" value="<b>ClassName</b>" style="swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="160" height="130" as="geometry" />
</mxCell>
<mxCell id="3" value="- privateField: Type" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="2">
<mxGeometry y="26" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="4" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=inherit;" vertex="1" parent="2">
<mxGeometry y="52" width="160" height="8" as="geometry" />
</mxCell>
<mxCell id="5" value="+ publicMethod(): void" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="2">
<mxGeometry y="60" width="160" height="26" as="geometry" />
</mxCell>
有关详细信息,请查阅:
references/xml-structure.md - 完整的 XML 结构和属性references/shape-library.md - 全面的形状样式和图标references/styling-guide.md - 高级样式、主题和格式examples/ 目录中的工作示例:
flowchart.drawio - 带决策逻辑的基本流程图architecture.drawio - 微服务架构图sequence-diagram.drawio - UML 序列图er-diagram.drawio - 实体关系数据库图class-diagram.drawio - UML 类图network-diagram.drawio - 网络拓扑图org-chart.drawio - 组织结构图archimate.drawio - ArchiMate 企业架构(业务/应用/技术层)c4-diagram.drawio - 包含上下文图和容器图的 C4 模型最小可工作的 .drawio 文件:
<mxfile host="app.diagrams.net" modified="2024-01-01T00:00:00.000Z" agent="Claude" version="21.0.0" type="device">
<diagram id="main" name="Diagram">
<mxGraphModel dx="1000" dy="600" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- 在此处添加形状 -->
</root>
</mxGraphModel>
</diagram>
</mxfile>
每周安装次数
–
代码仓库
GitHub 星标数
1
首次出现时间
–
安全审计
Create production-ready .drawio files with proper XML structure, styling, and layout. DrawIO (diagrams.net) uses an XML-based format built on mxGraph library.
DrawIO files are XML documents with .drawio extension (also .drawio.xml or .drawio.svg). The format uses mxGraph's XML serialization with compressed or uncompressed content.
Every DrawIO file follows this structure:
<mxfile host="app.diagrams.net" modified="2024-01-01T00:00:00.000Z" agent="Claude" version="21.0.0" type="device">
<diagram id="diagram-id" name="Page-1">
<mxGraphModel dx="1000" dy="600" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- Shapes and connectors go here -->
</root>
</mxGraphModel>
</diagram>
</mxfile>
Key elements:
mxfile - Root container, can hold multiple diagrams (pages)diagram - Single page with unique id and namemxGraphModel - Canvas settings (size, grid, guides)root - Contains all cells (shapes and edges)mxCell id="0" - Required root cellmxCell id="1" - Required default parent for all shapesVertex (Shape):
<mxCell id="2" value="Label" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="60" as="geometry" />
</mxCell>
Edge (Connector):
<mxCell id="3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;" edge="1" parent="1" source="2" target="4">
<mxGeometry relative="1" as="geometry" />
</mxCell>
Assign unique IDs to every cell. Use a simple incrementing pattern starting from "2" (0 and 1 are reserved):
<mxCell id="2" ... /> <!-- First shape -->
<mxCell id="3" ... /> <!-- First edge -->
<mxCell id="4" ... /> <!-- Second shape -->
Use x/y coordinates relative to the canvas origin (top-left). Typical spacing:
Rectangle (default):
rounded=0;whiteSpace=wrap;html=1;
Rounded rectangle:
rounded=1;whiteSpace=wrap;html=1;
Ellipse/Circle:
ellipse;whiteSpace=wrap;html=1;
Diamond (decision):
rhombus;whiteSpace=wrap;html=1;
Cylinder (database):
shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;
Document:
shape=document;whiteSpace=wrap;html=1;boundedLbl=1;
Process (rectangle with side lines):
shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;
Orthogonal (right angles):
edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;
Curved:
edgeStyle=orthogonalEdgeStyle;curved=1;orthogonalLoop=1;jettySize=auto;html=1;
Straight:
edgeStyle=none;orthogonalLoop=1;jettySize=auto;html=1;
With arrow:
endArrow=classic;html=1;
Dashed:
dashed=1;
Add to style string:
fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333;fontSize=12;fontStyle=1;strokeWidth=2;Common color schemes:
fillColor=#dae8fc;strokeColor=#6c8ebf;fillColor=#d5e8d4;strokeColor=#82b366;fillColor=#ffe6cc;strokeColor=#d79b00;fillColor=#f8cecc;strokeColor=#b85450;fillColor=#e1d5e7;strokeColor=#9673a6;fillColor=#f5f5f5;strokeColor=#666666;Use rectangles for processes, diamonds for decisions, ellipses for start/end:
<!-- Start -->
<mxCell id="2" value="Start" style="ellipse;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="200" y="40" width="80" height="40" as="geometry" />
</mxCell>
<!-- Process -->
<mxCell id="3" value="Process Step" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="170" y="120" width="140" height="60" as="geometry" />
</mxCell>
<!-- Decision -->
<mxCell id="4" value="Condition?" style="rhombus;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
<mxGeometry x="180" y="220" width="120" height="80" as="geometry" />
</mxCell>
Use grouped containers, service shapes, and labeled connectors:
<!-- Container/Group -->
<mxCell id="2" value="Backend Services" style="swimlane;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
<mxGeometry x="40" y="40" width="300" height="200" as="geometry" />
</mxCell>
<!-- Service inside container -->
<mxCell id="3" value="API Gateway" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="2">
<mxGeometry x="20" y="40" width="120" height="60" as="geometry" />
</mxCell>
Use vertical lifelines with horizontal message arrows:
<!-- Actor/Lifeline header -->
<mxCell id="2" value="Client" style="shape=umlLifeline;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=1;collapsible=0;recursiveResize=0;outlineConnect=0;portConstraint=eastwest;newEdgeStyle={"edgeStyle":"elbowEdgeStyle","elbow":"vertical","curved":0,"rounded":0};" vertex="1" parent="1">
<mxGeometry x="100" y="40" width="100" height="300" as="geometry" />
</mxCell>
<!-- Message -->
<mxCell id="4" value="request()" style="html=1;verticalAlign=bottom;endArrow=block;edgeStyle=elbowEdgeStyle;elbow=vertical;curved=0;rounded=0;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="150" y="100" as="sourcePoint" />
<mxPoint x="350" y="100" as="targetPoint" />
</mxGeometry>
</mxCell>
Use table shapes with columns:
<mxCell id="2" value="users" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="160" height="130" as="geometry" />
</mxCell>
<mxCell id="3" value="id: INT (PK)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;fontStyle=1;" vertex="1" parent="2">
<mxGeometry y="26" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="4" value="email: VARCHAR(255)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="2">
<mxGeometry y="52" width="160" height="26" as="geometry" />
</mxCell>
Use UML class shapes:
<mxCell id="2" value="<b>ClassName</b>" style="swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="160" height="130" as="geometry" />
</mxCell>
<mxCell id="3" value="- privateField: Type" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="2">
<mxGeometry y="26" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="4" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=inherit;" vertex="1" parent="2">
<mxGeometry y="52" width="160" height="8" as="geometry" />
</mxCell>
<mxCell id="5" value="+ publicMethod(): void" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="2">
<mxGeometry y="60" width="160" height="26" as="geometry" />
</mxCell>
For detailed information, consult:
references/xml-structure.md - Complete XML structure and attributesreferences/shape-library.md - Comprehensive shape styles and iconsreferences/styling-guide.md - Advanced styling, themes, and formattingWorking examples in examples/:
flowchart.drawio - Basic flowchart with decision logicarchitecture.drawio - Microservices architecture diagramsequence-diagram.drawio - UML sequence diagramer-diagram.drawio - Entity-relationship database diagramclass-diagram.drawio - UML class diagramnetwork-diagram.drawio - Network topology diagramorg-chart.drawio - Organizational hierarchy chartarchimate.drawio - ArchiMate enterprise architecture (Business/Application/Technology layers)Minimal working .drawio file:
<mxfile host="app.diagrams.net" modified="2024-01-01T00:00:00.000Z" agent="Claude" version="21.0.0" type="device">
<diagram id="main" name="Diagram">
<mxGraphModel dx="1000" dy="600" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- Add shapes here -->
</root>
</mxGraphModel>
</diagram>
</mxfile>
Weekly Installs
–
Repository
GitHub Stars
1
First Seen
–
Security Audits
新闻稿撰写工具:使用 inference.sh CLI 进行事实核查与专业新闻稿创作
7,400 周安装
c4-diagram.drawio - C4 model with Context and Container diagrams