insight-diagram
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInsight Diagram — 项目图表生成技能
Insight Diagram - Project Diagram Generation Skill
分析任意代码库,自动生成 UML 14种图 + 架构图 + 流程图,使用 渲染为 HTML+SVG。
/architecture-diagramAnalyze 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 Type | English Identifier | Focus |
|---|---|---|---|
| 1 | System Architecture Diagram | architecture | Component relationships, global perspective (non-UML, most commonly used) |
| 2 | Class Diagram | class | Define classes, attributes, operations and relationships |
| 3 | Object Diagram | object | Object instances and their relationships at a specific moment |
| 4 | Component Diagram | component | System components and their dependency relationships |
| 5 | Deployment Diagram | deployment | Physical hardware, nodes and software deployment |
| 6 | Package Diagram | package | Group and organize model elements |
| 7 | Composite Structure Diagram | composite-structure | Internal structure of classes |
| 8 | Profile Diagram | profile | Extend 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 Type | English Identifier | Focus |
|---|---|---|---|
| 9 | Flowchart | flowchart | Main process and branches (non-UML, most commonly used) |
| 10 | Use Case Diagram | usecase | Display system functions from the user's perspective |
| 11 | Activity Diagram | activity | Process flow or steps |
| 12 | State Machine Diagram | state-machine | State transitions in the object lifecycle |
| 13 | Sequence Diagram | sequence | Display interactions between objects in chronological order |
| 14 | Communication Diagram | communication | Focus on organizational relationships between objects |
| 15 | Timing Diagram | timing | Focus on time constraints for state changes |
| 16 | Interaction Overview Diagram | interaction-overview | Combine activity diagrams and sequence diagrams |
| 17 | Swimlane Diagram | swimlane | Cross-component/role responsibility process (variant of activity diagram) |
示例参考
Example References
本技能的 目录包含 13 个已完成的图表 HTML 文件,作为视觉样式和内容结构的参考模板。生成任何图表前,必须先阅读对应的示例文件,以确保风格一致、结构规范。
examples/The 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.
examples/示例文件清单
Example File List
| 文件 | 图表类型 | 英文标识 |
|---|---|---|
| 系统架构图 | architecture |
| 类图 | class |
| 对象图 | object |
| 组件图 | component |
| 部署图 | deployment |
| 流程图 | flowchart |
| 用例图 | usecase |
| 活动图 | activity |
| 序列图 | sequence |
| 通信图 | communication |
| 数据流图 | dfd |
| 交互概览图 | interaction-overview |
| 泳道图 | swimlane |
| File | Diagram Type | English Identifier |
|---|---|---|
| System Architecture Diagram | architecture |
| Class Diagram | class |
| Object Diagram | object |
| Component Diagram | component |
| Deployment Diagram | deployment |
| Flowchart | flowchart |
| Use Case Diagram | usecase |
| Activity Diagram | activity |
| Sequence Diagram | sequence |
| Communication Diagram | communication |
| Data Flow Diagram | dfd |
| Interaction Overview Diagram | interaction-overview |
| Swimlane Diagram | swimlane |
参考规则
Reference Rules
-
生成前必读: 调用前,先用 Read 工具阅读对应类型的示例文件,从中提取:
/architecture-diagram- SVG 布局策略(节点间距、分组方式、箭头走向)
- 节点样式层级(核心节点 accent 高亮、普通节点实线边框、可选节点虚线边框)
- 标注风格(阶段标签、Legend 图例、卡片摘要)
- 信息密度(每个节点显示多少字段/属性)
-
结构对齐: 生成的图表应与示例保持相同的结构层次:
- 页面顶部:标题 + 副标题 + 图表类型说明
- 中间主体:SVG 图表区域(带浅色边框容器)
- 底部:信息摘要卡片 + 页脚
-
内容替换而非照搬: 示例中的业务数据(NovaShield 风控系统)是虚构的参考案例,生成时需替换为目标项目的真实架构信息。只参考布局和样式,不复制业务内容。
-
无对应示例的类型: 对于包图 (package)、复合结构图 (composite-structure)、剖面图 (profile)、状态机图 (state-machine)、定时图 (timing) 这 5 种没有示例文件的图表类型,参考最相近的已有示例(如包图参考组件图,状态机图参考活动图),并沿用相同的视觉语言。
-
Read Before Generation: Before calling, use the Read tool to read the example file of the corresponding type, and extract:
/architecture-diagram- 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)
-
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
-
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.
-
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
读取项目关键文件,提取架构信息:
- 读取项目根目录的 (如存在)获取项目概览
CLAUDE.md - 读取各子目录的 (如存在)获取模块细节
CLAUDE.md - 用 Glob 扫描源码文件结构(,
**/*.go,**/*.py等)**/*.ts - 读取入口文件(,
main.go,app.py等)识别顶层组件index.ts - 用 Grep 搜索关键模式:接口定义、函数签名、依赖注入、配置项
从以上信息中提炼出:
- 组件清单: 服务、模块、外部依赖
- 关系图: 谁调用谁、谁依赖谁、数据流向
- 核心类型: 结构体/类、接口、枚举
- 流程: 主业务流程、异常处理流程
- 部署: 进程、中间件、外部服务
Read key project files to extract architecture information:
- Read the file in the project root directory (if exists) to get an overview of the project
CLAUDE.md - Read files in each subdirectory (if exists) to get module details
CLAUDE.md - Use Glob to scan the source code file structure (,
**/*.go,**/*.py, etc.)**/*.ts - Read entry files (,
main.go,app.py, etc.) to identify top-level componentsindex.ts - 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
对每个选中的图表类型:
- 先读示例: 用 Read 工具阅读 (如
examples/<标识>.html),提取布局模式、节点样式、标注方式examples/architecture.html - 根据步骤 1 提取的架构信息,整理出该图表应展示的元素和关系
- 调用 skill,传入图表类型、标题、内容描述、输出路径,必须指定 light 风格
/architecture-diagram - 输出文件保存到 (如
docs/<标识>.html)docs/architecture.html - 简要报告完成状态
生成规则:
- 风格: 必须使用 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:
- Read Example First: Use the Read tool to read (e.g.,
examples/<identifier>.html) to extract layout patterns, node styles, and annotation methodsexamples/architecture.html - Based on the architecture information extracted in Step 1, organize the elements and relationships that should be displayed in the diagram
- Call the skill, passing in the diagram type, title, content description, output path, must specify the light style
/architecture-diagram - Save the output file to (e.g.,
docs/<identifier>.html)docs/architecture.html - 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