/drawio:drawiofrom drawio
建立和編輯 draw.io 圖表的 XML 格式。當使用者想要建立流程圖、架構圖、序列圖或任何視覺化圖表時使用。處理 XML 結構、樣式、字型、箭頭、連接線和 PNG 匯出。
Ships in drawio. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
直接以 XML 格式建立和編輯 draw.io 檔案(.drawio)的技能。
重要:只生成 mxCell 元素,wrapper 結構由系統自動添加。
這種設計大幅降低 AI 出錯機率:
<mxfile>, <diagram>, <mxGraphModel>, <root> 等 wrapper 標籤id="0" 或 id="1" 的 mxCell(系統自動添加)parent="1",群組內元素用 parent="<container-id>"< 用 <,> 用 >,& 用 &," 用 "AI 只需生成這樣的內容:
<mxCell id="2" value="開始" style="rounded=1;whiteSpace=wrap;html=1;fontFamily=Helvetica;fontSize=18;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="3" value="處理" style="rounded=1;whiteSpace=wrap;html=1;fontFamily=Helvetica;fontSize=18;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="100" y="200" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=classic;" edge="1" parent="1" source="2" target="3">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
系統會自動包裝成完整的 .drawio 檔案。
<!-- 錯誤:包含了 wrapper 標籤 -->
<mxfile>
<diagram>
<mxGraphModel>
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
...
</root>
</mxGraphModel>
</diagram>
</mxfile>
<mxCell id="2" value="標籤" style="rounded=0;whiteSpace=wrap;html=1;fontFamily=Helvetica;fontSize=18;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="2" value="標籤" style="rounded=1;whiteSpace=wrap;html=1;fontFamily=Helvetica;fontSize=18;arcSize=20;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="2" value="標籤" style="ellipse;whiteSpace=wrap;html=1;fontFamily=Helvetica;fontSize=18;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="80" as="geometry"/>
</mxCell>
<mxCell id="2" value="條件?" style="rhombus;whiteSpace=wrap;html=1;fontFamily=Helvetica;fontSize=18;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="100" height="100" as="geometry"/>
</mxCell>
<mxCell id="2" value="文字" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontFamily=Helvetica;fontSize=18;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="30" as="geometry"/>
</mxCell>
<mxCell id="lane1" value="前端" style="swimlane;fontFamily=Helvetica;fontSize=16;" vertex="1" parent="1">
<mxGeometry x="40" y="40" width="200" height="200" as="geometry"/>
</mxCell>
<mxCell id="step1" value="步驟 1" style="rounded=1;fontFamily=Helvetica;" vertex="1" parent="lane1">
<mxGeometry x="20" y="60" width="160" height="40" as="geometry"/>
</mxCell>
<mxCell id="e1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=classic;" edge="1" parent="1" source="2" target="3">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="e1" value="標籤" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=classic;fontFamily=Helvetica;fontSize=14;" edge="1" parent="1" source="2" target="3">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="e1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;endArrow=classic;" edge="1" parent="1" source="2" target="3">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="e1" style="edgeStyle=orthogonalEdgeStyle;exitX=0.5;exitY=1;entryX=0.5;entryY=0;endArrow=classic;" edge="1" parent="1" source="2" target="5">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="160" y="350"/>
<mxPoint x="400" y="350"/>
</Array>
</mxGeometry>
</mxCell>
exitY=0.3 和 exitY=0.7 區分(不要都用 0.5)<!-- A→B: 從 A 的右側出發,進入 B 的左側 -->
<mxCell id="e1" style="exitX=1;exitY=0.5;entryX=0;entryY=0.5;endArrow=classic;" edge="1" source="a" target="b">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<!-- B→A: 從 B 的左側出發,進入 A 的右側 -->
<mxCell id="e2" style="exitX=0;exitY=0.5;entryX=1;entryY=0.5;endArrow=classic;" edge="1" source="b" target="a">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
每條邊都應該設定這 4 個屬性以獲得精確控制。
| 用途 | 填充色 | 邊框色 |
|---|---|---|
| 淺藍色 | #dae8fc | #6c8ebf |
| 淺綠色 | #d5e8d4 | #82b366 |
| 淺黃色 | #fff2cc | #d6b656 |
| 淺紅色 | #f8cecc | #b85450 |
| 淺紫色 | #e1d5e7 | #9673a6 |
| 淺灰色 | #f5f5f5 | #666666 |
fontSize=18 提升可讀性雖然核心原則是「只生成 mxCell」,但寫入 .drawio 檔案時需要完整結構。
工作流程:
<mxfile host="app.diagrams.net" agent="Agent" version="21.0.0">
<diagram name="Page-1" id="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="827" pageHeight="1169" math="0" shadow="0" defaultFontFamily="Helvetica">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<!-- 在此放入你生成的 mxCell 元素 -->
</root>
</mxGraphModel>
</diagram>
</mxfile>
helpers/ 目錄包含 TypeScript 工具,可用於驗證和除錯:
# 驗證 .drawio 檔案(需要 Bun)
bun helpers/validate-xml.ts diagram.drawio
# 將純 mxCell XML 包裝成 .drawio(需要 Bun)
bun helpers/wrap-mxfile.ts cells.xml output.drawio
這些工具是可選的參考實作,Agent 不需要呼叫它們,只需遵循上述規則即可
.drawio.png 是一種特殊格式:既是 PNG 圖片,又嵌入了 draw.io XML 資料,可以在 draw.io 中重新編輯。
需求: Docker + rlespinasse/drawio-export 映像
工作流程:
1. Agent 寫入 .drawio 檔案
↓
2. 執行 Docker 匯出(使用 -e 嵌入選項)
↓
3. 產生 .drawio.png(可編輯的 PNG)
匯出指令:
# 使用 helper 腳本
./helpers/export-drawio-png.sh diagram.drawio output.drawio.png
# 或直接使用 Docker
docker run --rm -v $(pwd):/data rlespinasse/drawio-export \
-f png -e --remove-page-suffix -o /data /data/diagram.drawio
重要選項:
-f png: 輸出 PNG 格式-e, --embed-diagram: 嵌入 diagram XML(關鍵!)-t, --transparent: 透明背景-s, --scale <n>: 縮放比例--remove-page-suffix: 移除頁面後綴產生的檔案特性:
如果使用者安裝了 Draw.io Integration 擴充套件:
支援的檔案格式:
| 格式 | Agent 可產生 | VS Code 可編輯 | 說明 |
|---|---|---|---|
.drawio | ✅ 直接 | ✅ | 純 XML |
.dio | ✅ 直接 | ✅ | 同 .drawio |
.drawio.png | ✅ via Docker | ✅ | PNG + 嵌入 XML |
.drawio.svg | ❌ | ✅ | 需要 SVG 渲染 |
建議做法:
.drawio 檔案.drawio.png,使用 Docker 匯出如果環境有 draw.io CLI:
# 使用 drawio-export(Docker 環境)
drawio-export -x -f png -s 2 -t -o output.png input.drawio
# 使用 drawio CLI(有顯示環境)
drawio -x -f png -s 2 -t -o output.png input.drawio
選項說明:
-x: 匯出模式-f png: 輸出格式(也可用 svg、pdf)-s 2: 2 倍縮放(高解析度)-t: 透明背景生成後確認:
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub rdcrystallab/agentic-plugins --plugin drawioOther plugins' skills for the same job