diagram-generator

软件研发 安全与合规 6 文件 EN 原文 2 脚本

把分析结果画成结构图 / 攻击图

generate, refine, validate, and render diagrams from natural language, notes, code snippets, schemas, tables, or existing diagram source. use for flowcharts, swimlanes, sequence diagrams, state diagrams, er diagrams, class diagrams, architecture/c4-style diagrams, dependency graphs, gantt charts, mind maps, user journeys, sankey-style flows, org charts, network graphs, and other visual models. supports mermaid by default, graphviz dot for complex graph layout, plantuml for uml-heavy engineering diagrams, and svg output when direct markup is more reliable.

说明语言:英文

来源zhaoxuya520reverse-skill ↗ 查看原文件 ↗版权归原作者,请遵循原仓库许可
安装
npx skills add https://github.com/zhaoxuya520/reverse-skill --skill diagram-generator

需要已安装 skills CLI。也可以直接从源仓库 clone。

在星云中查看 ↗
SKILL.md 原文

name: diagram-generator description: generate, refine, validate, and render diagrams from natural language, notes, code snippets, schemas, tables, or existing diagram source. use for flowcharts, swimlanes, sequence diagrams, state diagrams, er diagrams, class diagrams, architecture/c4-style diagrams, dependency graphs, gantt charts, mind maps, user journeys, sankey-style flows, org charts, network graphs, and other visual models. supports mermaid by default, graphviz dot for complex graph layout, plantuml for uml-heavy engineering diagrams, and svg output when direct markup is more reliable. ---

Diagram Generator

ACTION REQUIRED(读完后立刻执行)

  1. NOW:确认当前任务是否命中本 skill 的适用范围
  2. NOW:读取 ../tool-index.md,校验工具可用性和实际路径
  3. NEXT:缺工具时调用 bootstrap,不要猜路径
  4. ACT:进入"工作流"第一步并执行,不要停在确认状态

Purpose

Create clear, editable diagrams from messy or structured inputs. Prefer text-based diagram source first so the result can be reviewed, versioned, and refined. Render to files only when the user asks for an image/PDF or when a downloadable artifact would materially help.

Default workflow

  1. Identify the user's intent, audience, and source material.
  2. Choose the diagram family and language using the decision table below.
  3. Normalize entities, relationships, labels, states, branches, and time/order information before writing diagram code.
  4. Generate concise, readable diagram source.
  5. Validate the syntax mentally and, when creating files, run scripts/render_diagram.py.
  6. Return the diagram source plus a short note about assumptions. When files are generated, include links to the output files.

Do not over-ask for clarification. If the request is underspecified, make reasonable assumptions and label them briefly.

Diagram language decision table

Use Mermaid unless another language is clearly better.

User wantsPreferWhy
process flow, decision tree, simple swimlaneMermaid flowchartreadable and easy to paste into Markdown
sequence of system/user interactionsMermaid sequenceDiagram or PlantUML sequenceMermaid for docs; PlantUML for UML formality
lifecycle, state machine, transitionsMermaid stateDiagram-v2 or PlantUML statecompact transition syntax
database schema, entities, relationshipsMermaid erDiagramportable ER notation
class/interface/object modelMermaid classDiagram or PlantUML classMermaid for docs; PlantUML for detailed UML
project scheduleMermaid ganttconcise timeline syntax
hierarchy, ideas, notesMermaid mindmapgood default for idea maps
customer/product journeyMermaid journeybuilt-in journey notation
git historyMermaid gitGraphbuilt-in git notation
dependency graph, package graph, large networkGraphviz DOTbetter layout engines for dense graphs
architecture with layers, clusters, boundariesMermaid flowchart with subgraphs, Graphviz clusters, or PlantUML C4-stylechoose based on requested fidelity
weighted flow/sankey-like relationshipMermaid sankey-beta when supported, otherwise SVG or GraphvizMermaid support may vary by renderer
custom visual where source languages fit poorlySVGprecise control over layout and styling

Output policy

Mermaid generation rules

Consult references/diagram-patterns.md for compact templates.

General Mermaid rules:

Graphviz DOT generation rules

Use Graphviz for large, dense, or layout-sensitive relationship diagrams.

PlantUML generation rules

Use PlantUML when the user asks for UML or needs formal UML notation.

SVG generation rules

Use SVG only when text diagram languages cannot express the requested visual reliably.

Rendering files

When the user asks for PNG/SVG/PDF, create a source file and run:

python "<SKILL_ROOT>/diagram-generator/scripts/render_diagram.py" input.mmd --format svg --out output.svg
python "<SKILL_ROOT>/diagram-generator/scripts/render_diagram.py" input.dot --format png --out output.png
python "<SKILL_ROOT>/diagram-generator/scripts/render_diagram.py" input.puml --format svg --out output.svg
<SKILL_ROOT> 是本包 skills/ 目录的实际路径,AI 应自动检测。

The renderer is intentionally dependency-tolerant. It tries common local tools and reports actionable installation hints if a renderer is unavailable. Do not claim an image was rendered unless the script completed successfully and the output file exists.

Validation checklist

Before finalizing:

Common response template

Use this structure for most diagram answers:

下面是可编辑的 [language] 版本:

[source]


Assumptions:
- [only if needed]

Rendered file: [link] [only if generated]

For English user requests, respond in English. For Chinese user requests, respond in Chinese unless they ask otherwise.


按需自举(On-Demand Bootstrap)

自动化能力边界

工具可自动安装安装方式说明
Mermaid CLI (mmdc)✓npm install -g @mermaid-js/mermaid-cli渲染 Mermaid 为 PNG/SVG
Graphviz (dot)✗手动安装https://graphviz.org/download/
PlantUML✗需要 Java + plantuml.jarhttps://plantuml.com/download
Python (render script)✓已在 bootstrap 中scripts/render_diagram.py 依赖

说明

本 skill 主要输出文本格式的图表源码(Mermaid/DOT/PlantUML),不一定需要本地渲染工具。只有当用户明确要求生成 PNG/SVG/PDF 文件时才需要对应的渲染器。

如果渲染器不可用,scripts/render_diagram.py 会输出安装提示而不是报错。


路由上下文

上游入口: skills/SKILL.md(总控)、routing.md 触发条件: 用户说"画图"、"流程图"、"架构图"、"攻击路径图"、"时序图"、"Mermaid"、"Graphviz"、"PlantUML" 下游出口:

同级关联模块: docs-generator/(报告中嵌入图表)

任务完成自检(声称完成前 MUST 通过)

同类技能
api-securityapk-reverseattack-chainattack-tree-constructionaudit-integrityauth-implementation-patternsbinary-diffbinary-ninja-reverse
本页内容来自开源项目 zhaoxuya520, 版权归原作者所有。
本站仅作技能索引与分享,所有 Skill 版权归其原作者所有。