Agent Skills › CodingFeng101/CanvasAnvil › diagram-skill

diagram-skill

GitHub

用于生成、编辑和验证 draw.io/diagrams.net 图表 XML,支持新建、局部修改及截断续传,并自动构建在线编辑器链接以便用户继续编辑。

skill/diagram-skill/SKILL.md CodingFeng101/CanvasAnvil

触发场景

请求生成或编辑流程图、架构图、网络图、ER图等 提及 draw.io、diagrams.net、drawio 或 .drawio 文件

安装

npx skills add CodingFeng101/CanvasAnvil --skill diagram-skill -g -y
更多选项

非标准路径

npx skills add https://github.com/CodingFeng101/CanvasAnvil/tree/main/skill/diagram-skill -g -y

不安装直接使用

npx skills use CodingFeng101/CanvasAnvil@diagram-skill

指定 Agent (Claude Code)

npx skills add CodingFeng101/CanvasAnvil --skill diagram-skill -a claude-code -g -y

安装 repo 全部 skill

npx skills add CodingFeng101/CanvasAnvil --all -g -y

预览 repo 内 skill

npx skills add CodingFeng101/CanvasAnvil --list

SKILL.md

Frontmatter
{
    "name": "diagram-skill",
    "description": "Generate, edit, and validate draw.io or diagrams.net diagrams as XML, then open them directly in the draw.io online editor so the user can keep editing there. Use for new diagrams, local XML edits, shape-library diagrams, and truncated XML continuation."
}

Diagram Skill

Trigger

Use when the user asks for a diagram, flowchart, architecture diagram, network diagram, ER diagram, BPMN diagram, or a cloud/infrastructure diagram, or mentions draw.io, diagrams.net, drawio, or a .drawio file.

Order

  1. Classify the request.
  2. Read the required references.
  3. Produce or modify draw.io XML.
  4. Validate the XML.
  5. Write the XML to a .drawio file when file writes are available.
  6. Build an online editor URL and open it in the agent's built-in browser.
  7. Return the XML code, the .drawio path, and the online editor link.

Classification

  • prompts/display.md
    • new diagram
    • major rewrite
    • major relayout
    • any case where local editing is fragile
  • prompts/edit.md
    • current XML exists
    • change is small and precise
    • ids can remain stable
  • prompts/append.md
    • earlier XML output was truncated
  • prompts/router.md
    • routing decision needed before generation

Required References

  • references/xml-rules.md
  • references/edit-rules.md
  • references/shape-library-index.md
  • references/shape-libraries/<library>.md

Read the library file before generating any library-backed diagram.

Do not guess undocumented shape-library prefixes or shape names.

XML Contract

  • New diagrams should normally produce a full <mxGraphModel> with <root>.
  • All mxCell elements must be direct children of <root>.
  • Root cells must exist:
    • <mxCell id="0"/>
    • <mxCell id="1" parent="0"/>
  • Every id must be unique.
  • Every edge source and target must reference existing ids.
  • Preserve existing ids during local edits unless renaming is explicitly required.
  • Escape XML attribute values correctly.
  • Do not emit XML comments.

Output Contract

  • Prefer complete XML for new diagrams.
  • Prefer the smallest safe edit set for local changes, then return the full updated XML.
  • Stop at a clean boundary when output length is at risk.
  • Continue from the exact next character when appending.
  • Return the XML as a code block in chat.
  • Write the same XML to <name>.drawio when file writes are available.
  • Do not produce PNG, SVG, PDF, xmlpng, or metadata artifacts.
  • Do not run Playwright and do not install browser dependencies.

Online Editor Handoff

  1. Save the XML to a .drawio file.

  2. Build the editor URL:

    node skill/diagram-skill/scripts/build-drawio-url.mjs --input path\to\diagram.drawio
    

    The script prints a self-contained https://app.diagrams.net/?offline=1#R... URL with the diagram compressed inside it.

  3. Open that URL with the agent's built-in browser tool in a new tab and leave the tab open.

  4. Tell the user the diagram is loaded and can be edited directly in the online editor. Do not automate edits.

  5. If no browser tool is available, or the page fails to load, give the user the URL and the .drawio path instead.

  6. If the script reports tooLong, or the browser rejects the URL, fall back to the .drawio file: open https://app.diagrams.net and use File > Open From > Device.

  7. Re-running the handoff opens a fresh editor tab with the current XML. It does not update a tab the user has already edited; ask before replacing manual changes.

  8. Do not ask the user to log in. app.diagrams.net works without an account.

Scripts

  • scripts/validate-drawio-xml.mjs
  • scripts/build-drawio-url.mjs
  • vendor/pako_deflate.min.cjs (compression only, no install step)

If the user specifies an output directory or file path, write the .drawio file there.

If the user does not specify an output location, create a new output folder automatically and write the .drawio file there.

Do not write generated artifacts into the skill folder.

Deliverables

Preferred:

  • draw.io XML code in chat
  • <name>.drawio
  • online editor link (https://app.diagrams.net/?offline=1#R...)

版本历史

  • 27f1aea 当前 2026-11-03 09:19

同 Skill 集合

skill/cad-skill/SKILL.md
skill/flow-skill/SKILL.md
skill/infographic-skill/SKILL.md
skill/poster-skill/SKILL.md
skill/ppt-skill/SKILL.md
skill/product-skill/SKILL.md

元信息

文件数
0
版本
27f1aea
Hash
2e91f28d
收录时间
2026-11-03 09:19

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-11-05 16:42
浙ICP备14020137号-1