insight-diagram

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Insight Diagram — 项目图表生成技能

Insight Diagram - Project Diagram Generation Skill

分析任意代码库,自动生成 UML 14种图 + 架构图 + 流程图,使用
/architecture-diagram
渲染为 HTML+SVG。
Analyze any codebase to automatically generate 14 types of UML diagrams + architecture diagrams + flowcharts, rendered as HTML+SVG using
/architecture-diagram
.

图表分类与清单

Diagram Categories and List

结构性图形 (Structural Diagrams — 静态)

Structural Diagrams — Static

描述系统的物理组成和静态结构。
编号图表类型英文标识关注点
1系统架构图architecture组件关系、全局视角(非UML,最常用)
2类图class定义类、属性、操作及关系
3对象图object特定时刻的对象实例及其关系
4组件图component系统组件及其依赖关系
5部署图deployment物理硬件、节点及软件部署
6包图package将模型元素分组组织
7复合结构图composite-structure类的内部结构
8剖面图profile扩展UML元模型、自定义构造型
Describe the physical composition and static structure of the system.
No.Diagram TypeEnglish IdentifierFocus
1System Architecture DiagramarchitectureComponent relationships, global perspective (non-UML, most commonly used)
2Class DiagramclassDefine classes, attributes, operations and relationships
3Object DiagramobjectObject instances and their relationships at a specific moment
4Component DiagramcomponentSystem components and their dependency relationships
5Deployment DiagramdeploymentPhysical hardware, nodes and software deployment
6Package DiagrampackageGroup and organize model elements
7Composite Structure Diagramcomposite-structureInternal structure of classes
8Profile DiagramprofileExtend UML metamodel, define custom stereotypes

行为性图形 (Behavioral Diagrams — 动态)

Behavioral Diagrams — Dynamic

描述系统与外部参与者或系统内部的交互过程。
编号图表类型英文标识关注点
9流程图flowchart主流程与分支(非UML,最常用)
10用例图usecase从用户角度展示系统功能
11活动图activity过程的流程或步骤
12状态机图state-machine对象生命周期的状态变迁
13序列图sequence按时间顺序展示对象间交互
14通信图communication侧重于对象间的组织关系
15定时图timing侧重于状态变化的时间约束
16交互概览图interaction-overview结合活动图和时序图
17泳道图swimlane跨组件/角色职责流程(活动图变体)
Describe the interaction process between the system and external participants or within the system.
No.Diagram TypeEnglish IdentifierFocus
9FlowchartflowchartMain process and branches (non-UML, most commonly used)
10Use Case DiagramusecaseDisplay system functions from the user's perspective
11Activity DiagramactivityProcess flow or steps
12State Machine Diagramstate-machineState transitions in the object lifecycle
13Sequence DiagramsequenceDisplay interactions between objects in chronological order
14Communication DiagramcommunicationFocus on organizational relationships between objects
15Timing DiagramtimingFocus on time constraints for state changes
16Interaction Overview Diagraminteraction-overviewCombine activity diagrams and sequence diagrams
17Swimlane DiagramswimlaneCross-component/role responsibility process (variant of activity diagram)

示例参考

Example References

本技能的
examples/
目录包含 13 个已完成的图表 HTML 文件,作为视觉样式和内容结构的参考模板。生成任何图表前,必须先阅读对应的示例文件,以确保风格一致、结构规范。
The
examples/
directory of this skill contains 13 completed diagram HTML files, serving as reference templates for visual styles and content structure. You must read the corresponding example file before generating any diagram to ensure consistent style and standardized structure.

示例文件清单

Example File List

文件图表类型英文标识
examples/architecture.html
系统架构图architecture
examples/class.html
类图class
examples/object.html
对象图object
examples/component.html
组件图component
examples/deployment.html
部署图deployment
examples/flowchart.html
流程图flowchart
examples/usecase.html
用例图usecase
examples/activity.html
活动图activity
examples/sequence.html
序列图sequence
examples/communication.html
通信图communication
examples/dfd.html
数据流图dfd
examples/interaction-overview.html
交互概览图interaction-overview
examples/swimlane.html
泳道图swimlane
FileDiagram TypeEnglish Identifier
examples/architecture.html
System Architecture Diagramarchitecture
examples/class.html
Class Diagramclass
examples/object.html
Object Diagramobject
examples/component.html
Component Diagramcomponent
examples/deployment.html
Deployment Diagramdeployment
examples/flowchart.html
Flowchartflowchart
examples/usecase.html
Use Case Diagramusecase
examples/activity.html
Activity Diagramactivity
examples/sequence.html
Sequence Diagramsequence
examples/communication.html
Communication Diagramcommunication
examples/dfd.html
Data Flow Diagramdfd
examples/interaction-overview.html
Interaction Overview Diagraminteraction-overview
examples/swimlane.html
Swimlane Diagramswimlane

参考规则

Reference Rules

  1. 生成前必读: 调用
    /architecture-diagram
    前,先用 Read 工具阅读对应类型的示例文件,从中提取:
    • SVG 布局策略(节点间距、分组方式、箭头走向)
    • 节点样式层级(核心节点 accent 高亮、普通节点实线边框、可选节点虚线边框)
    • 标注风格(阶段标签、Legend 图例、卡片摘要)
    • 信息密度(每个节点显示多少字段/属性)
  2. 结构对齐: 生成的图表应与示例保持相同的结构层次:
    • 页面顶部:标题 + 副标题 + 图表类型说明
    • 中间主体:SVG 图表区域(带浅色边框容器)
    • 底部:信息摘要卡片 + 页脚
  3. 内容替换而非照搬: 示例中的业务数据(NovaShield 风控系统)是虚构的参考案例,生成时需替换为目标项目的真实架构信息。只参考布局和样式,不复制业务内容。
  4. 无对应示例的类型: 对于包图 (package)、复合结构图 (composite-structure)、剖面图 (profile)、状态机图 (state-machine)、定时图 (timing) 这 5 种没有示例文件的图表类型,参考最相近的已有示例(如包图参考组件图,状态机图参考活动图),并沿用相同的视觉语言。
  1. Read Before Generation: Before calling
    /architecture-diagram
    , use the Read tool to read the example file of the corresponding type, and extract:
    • SVG layout strategy (node spacing, grouping method, arrow direction)
    • Node style hierarchy (core node accent highlight, normal node solid border, optional node dashed border)
    • Annotation style (phase labels, Legend, card summary)
    • Information density (number of fields/properties displayed per node)
  2. Structure Alignment: The generated diagram should maintain the same structural hierarchy as the example:
    • Top of page: Title + Subtitle + Diagram type description
    • Middle body: SVG diagram area (with light border container)
    • Bottom: Information summary card + Footer
  3. Replace Content Instead of Copying: The business data (NovaShield risk control system) in the examples is a fictional reference case. When generating, replace it with the actual architecture information of the target project. Only reference the layout and style, do not copy business content.
  4. Types Without Corresponding Examples: For the 5 diagram types without example files (package, composite-structure, profile, state-machine, timing), refer to the closest existing examples (e.g., package diagram refers to component diagram, state machine diagram refers to activity diagram) and follow the same visual language.

执行流程

Execution Process

步骤 1:分析代码库

Step 1: Analyze the Codebase

读取项目关键文件,提取架构信息:
  1. 读取项目根目录的
    CLAUDE.md
    (如存在)获取项目概览
  2. 读取各子目录的
    CLAUDE.md
    (如存在)获取模块细节
  3. 用 Glob 扫描源码文件结构(
    **/*.go
    ,
    **/*.py
    ,
    **/*.ts
    等)
  4. 读取入口文件(
    main.go
    ,
    app.py
    ,
    index.ts
    等)识别顶层组件
  5. 用 Grep 搜索关键模式:接口定义、函数签名、依赖注入、配置项
从以上信息中提炼出:
  • 组件清单: 服务、模块、外部依赖
  • 关系图: 谁调用谁、谁依赖谁、数据流向
  • 核心类型: 结构体/类、接口、枚举
  • 流程: 主业务流程、异常处理流程
  • 部署: 进程、中间件、外部服务
Read key project files to extract architecture information:
  1. Read the
    CLAUDE.md
    file in the project root directory (if exists) to get an overview of the project
  2. Read
    CLAUDE.md
    files in each subdirectory (if exists) to get module details
  3. Use Glob to scan the source code file structure (
    **/*.go
    ,
    **/*.py
    ,
    **/*.ts
    , etc.)
  4. Read entry files (
    main.go
    ,
    app.py
    ,
    index.ts
    , etc.) to identify top-level components
  5. Use Grep to search for key patterns: interface definitions, function signatures, dependency injection, configuration items
Extract the following information from the above:
  • Component List: Services, modules, external dependencies
  • Relationship Diagram: Who calls whom, who depends on whom, data flow direction
  • Core Types: Structs/classes, interfaces, enums
  • Processes: Main business processes, exception handling processes
  • Deployment: Processes, middleware, external services

步骤 2:选择图表

Step 2: Select Diagrams

使用 AskUserQuestion 让用户选择要生成的图表(multiSelect: true),分4组展示:
第1组 — 结构性图形(静态):
  • 系统架构图 (architecture)
  • 类图 (class)
  • 对象图 (object)
  • 组件图 (component)
第2组 — 结构性图形续 + 部署:
  • 部署图 (deployment)
  • 包图 (package)
  • 复合结构图 (composite-structure)
  • 剖面图 (profile)
第3组 — 行为性图形(动态):
  • 流程图 (flowchart)
  • 用例图 (usecase)
  • 活动图 (activity)
  • 状态机图 (state-machine)
第4组 — 交互图 + 常用非UML:
  • 序列图 (sequence)
  • 通信图 (communication)
  • 交互概览图 (interaction-overview)
  • 泳道图 (swimlane)
  • 全部生成 (all)
默认推荐:architecture + sequence + flowchart
Use AskUserQuestion to let users select the diagrams to generate (multiSelect: true), displayed in 4 groups:
Group 1 — Structural Diagrams (Static):
  • System Architecture Diagram (architecture)
  • Class Diagram (class)
  • Object Diagram (object)
  • Component Diagram (component)
Group 2 — Continued Structural Diagrams + Deployment:
  • Deployment Diagram (deployment)
  • Package Diagram (package)
  • Composite Structure Diagram (composite-structure)
  • Profile Diagram (profile)
Group 3 — Behavioral Diagrams (Dynamic):
  • Flowchart (flowchart)
  • Use Case Diagram (usecase)
  • Activity Diagram (activity)
  • State Machine Diagram (state-machine)
Group 4 — Interaction Diagrams + Common Non-UML:
  • Sequence Diagram (sequence)
  • Communication Diagram (communication)
  • Interaction Overview Diagram (interaction-overview)
  • Swimlane Diagram (swimlane)
  • Generate All (all)
Default recommendation: architecture + sequence + flowchart

步骤 3:逐个生成

Step 3: Generate One by One

对每个选中的图表类型:
  1. 先读示例: 用 Read 工具阅读
    examples/<标识>.html
    (如
    examples/architecture.html
    ),提取布局模式、节点样式、标注方式
  2. 根据步骤 1 提取的架构信息,整理出该图表应展示的元素和关系
  3. 调用
    /architecture-diagram
    skill,传入图表类型、标题、内容描述、输出路径,必须指定 light 风格
  4. 输出文件保存到
    docs/<标识>.html
    (如
    docs/architecture.html
  5. 简要报告完成状态
生成规则:
  • 风格: 必须使用 light Claude 风格(暖白背景 #FAF9F6、terracotta/sage/plum/rose 配色、Inter 字体、白色卡片容器),与 Anthropic Claude 品牌视觉一致
  • 防遮盖: 所有 SVG 元素(节点、箭头、标签)不得互相遮盖。具体做法:
    • 计算每个元素的边界框,确保无重叠
    • 箭头绘制在节点下方(SVG 中先画箭头再画节点)
    • 节点间留足间距(垂直最少 40px,水平最少 30px)
    • 文字不超出所在节点边界,超长文字截断或换行
    • 连接线的标签放置在线段中点偏移处,避免覆盖线段或节点
    • 如果元素过多导致图表拥挤,拆分为多个子图或缩小元素尺寸
批量生成顺序(宏观→微观): architecture → component → deployment → package → composite-structure → profile → class → object → usecase → flowchart → activity → state-machine → swimlane → sequence → communication → timing → interaction-overview
For each selected diagram type:
  1. Read Example First: Use the Read tool to read
    examples/<identifier>.html
    (e.g.,
    examples/architecture.html
    ) to extract layout patterns, node styles, and annotation methods
  2. Based on the architecture information extracted in Step 1, organize the elements and relationships that should be displayed in the diagram
  3. Call the
    /architecture-diagram
    skill, passing in the diagram type, title, content description, output path, must specify the light style
  4. Save the output file to
    docs/<identifier>.html
    (e.g.,
    docs/architecture.html
    )
  5. Briefly report the completion status
Generation Rules:
  • Style: Must use the light Claude style (warm white background #FAF9F6, terracotta/sage/plum/rose color scheme, Inter font, white card container), consistent with the Anthropic Claude brand visual
  • Anti-Overlap: All SVG elements (nodes, arrows, labels) must not overlap with each other. Specific practices:
    • Calculate the bounding box of each element to ensure no overlap
    • Draw arrows below nodes (draw arrows first then nodes in SVG)
    • Leave sufficient spacing between nodes (minimum 40px vertically, minimum 30px horizontally)
    • Text does not exceed the boundary of the node it belongs to; truncate or wrap long text
    • Place connection line labels at the offset of the line midpoint to avoid covering lines or nodes
    • If there are too many elements causing crowding, split into multiple sub-diagrams or reduce element size
Batch generation order (macro to micro): architecture → component → deployment → package → composite-structure → profile → class → object → usecase → flowchart → activity → state-machine → swimlane → sequence → communication → timing → interaction-overview

步骤 4:报告

Step 4: Report

全部完成后输出:
  • 生成的文件列表
  • 每个图表的简要描述
After all are completed, output:
  • List of generated files
  • Brief description of each diagram

各图表的内容指南

Content Guidelines for Each Diagram

系统架构图 (architecture) — 非UML,最常用

System Architecture Diagram (architecture) — Non-UML, Most Commonly Used

  • 展示系统顶层组件及其连接关系
  • 区分内部模块与外部依赖
  • 标注核心数据流方向
  • Display top-level system components and their connection relationships
  • Distinguish internal modules from external dependencies
  • Mark core data flow directions

类图 (class)

Class Diagram (class)

  • 核心类型为类节点(名称+字段+方法)
  • 继承、组合、依赖关系
  • 接口与实现分离
  • 限制在 10-15 个核心类型
  • Core types are class nodes (name + fields + methods)
  • Inheritance, composition, dependency relationships
  • Separation of interfaces and implementations
  • Limit to 10-15 core types

对象图 (object)

Object Diagram (object)

  • 选取一个典型运行时场景
  • 展示对象实例及其属性值
  • 对象间的链接关系
  • Select a typical runtime scenario
  • Display object instances and their attribute values
  • Link relationships between objects

组件图 (component)

Component Diagram (component)

  • 每个组件为一个节点
  • 箭头表示依赖/调用方向
  • 标注接口名称
  • Each component is a node
  • Arrows indicate dependency/call direction
  • Mark interface names

部署图 (deployment)

Deployment Diagram (deployment)

  • 物理节点(服务器、容器、Serverless)
  • 中间件(消息队列、缓存、数据库)
  • 外部服务(第三方 API)
  • 标注通信协议
  • Physical nodes (servers, containers, Serverless)
  • Middleware (message queues, caches, databases)
  • External services (third-party APIs)
  • Mark communication protocols

包图 (package)

Package Diagram (package)

  • 按模块/命名空间分组
  • 包间依赖关系
  • 体现分层架构
  • Group by module/namespace
  • Dependency relationships between packages
  • Reflect layered architecture

复合结构图 (composite-structure)

Composite Structure Diagram (composite-structure)

  • 类/组件的内部结构
  • 部件(Part)与连接器(Connector)
  • 端口(Port)与接口
  • Internal structure of classes/components
  • Parts and Connectors
  • Ports and interfaces

剖面图 (profile)

Profile Diagram (profile)

  • 自定义构造型(Stereotype)
  • 扩展元模型的标签定义(Tagged Values)
  • 领域特定建模约束
  • Custom Stereotypes
  • Tagged Values extending metamodel definitions
  • Domain-specific modeling constraints

流程图 (flowchart) — 非UML,最常用

Flowchart (flowchart) — Non-UML, Most Commonly Used

  • 主流程 + 关键分支
  • 失败/异常路径
  • 起止节点清晰
  • Main process + key branches
  • Failure/exception paths
  • Clear start and end nodes

用例图 (usecase)

Use Case Diagram (usecase)

  • 参与者(人/外部系统)
  • 用例椭圆
  • include/extend 关系
  • Actors (people/external systems)
  • Use case ellipses
  • include/extend relationships

活动图 (activity)

Activity Diagram (activity)

  • 阶段/步骤为活动节点
  • 并行分支用 fork/join
  • 决策点用菱形
  • Phases/steps are activity nodes
  • Parallel branches use fork/join
  • Decision points use diamonds

状态机图 (state-machine)

State Machine Diagram (state-machine)

  • 对象的关键状态
  • 触发状态变迁的事件
  • 动作/守卫条件
  • 初始态和终态
  • Key states of objects
  • Events triggering state transitions
  • Actions/guard conditions
  • Initial and final states

序列图 (sequence)

Sequence Diagram (sequence)

  • 参与者为纵向生命线
  • 水平箭头为消息调用
  • 标注关键返回值
  • 关注 2-5 个核心交互场景
  • Actors are vertical lifelines
  • Horizontal arrows are message calls
  • Mark key return values
  • Focus on 2-5 core interaction scenarios

通信图 (communication)

Communication Diagram (communication)

  • 组件为节点,消息为连线
  • 标注消息序号
  • 强调协作关系而非时序
  • Components are nodes, messages are connections
  • Mark message serial numbers
  • Emphasize collaboration relationships rather than timing

定时图 (timing)

Timing Diagram (timing)

  • 时间轴横向展开
  • 状态变化的时间约束
  • 持续时间标注
  • Time axis expands horizontally
  • Time constraints for state changes
  • Duration annotations

交互概览图 (interaction-overview)

Interaction Overview Diagram (interaction-overview)

  • 控制流节点内嵌交互片段
  • 展示条件分支和循环
  • 宏观概览各交互场景
  • Control flow nodes embed interaction fragments
  • Display conditional branches and loops
  • Macro overview of each interaction scenario

泳道图 (swimlane) — 活动图变体

Swimlane Diagram (swimlane) — Variant of Activity Diagram

  • 按组件/角色分泳道
  • 流程步骤在对应泳道内
  • 跨泳道箭头表示交互
  • Divide swimlanes by component/role
  • Process steps are within corresponding swimlanes
  • Cross-swimlane arrows indicate interactions