code-understanding-diagrams

Codebase visualization and understanding report: used when a user wants a fresh, diagram-heavy HTML report to quickly understand a new codebase or system. Covers ten dimensions: architecture, call chains, configuration notes, feature descriptions, library descriptions, data models/ER, error handling, security & auth, CI/CD, and usage instructions. Every diagram node and edge must cite real source file paths and line numbers and must not be fabricated. Trigger phrases include requests to quickly get familiar with a system, draw architecture/call-chain diagrams, map the project with diagrams, or generate a system understanding report.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "code-understanding-diagrams" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-6d64a40a7863fa3e3843612a0d422cd01ce7fc962d0030256a7fb1d112c18a73. Verify the upstream source and version against https://skillhub.cn/skills/user_0e3266b7/code-understanding-diagrams before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Codebase visualization and understanding report: used when a user wants a fresh, diagram-heavy HTML report to quickly understand a new codebase or system. Covers ten dimensions: architecture, call chains, configuration notes, feature descriptions, library descriptions, data models/ER, error handling, security & auth, CI/CD, and usage instructions. Every diagram node and edge must cite real source file paths and line numbers and must not be fabricated. Trigger phrases include requests to quickly get familiar with a system, draw architecture/call-chain diagrams, map the project with diagrams, or generate a system understanding report.

0 Downloads

Introduction source: third_party · user_0e3266b7 · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: code-understanding-diagrams
description: "当用户希望通过生成清新、图表密集的 HTML 报告来快速理解一个新代码库或系统时,应使用此技能。它覆盖十个维度(架构、调用链路、配置说明、功能说明、库的说明、数据模型/ER、错误处理、安全与鉴权、CI/CD、使用说明),且每个图节点与连线都必须引用真实的源码文件路径与行号,不得编造。触发语包括:快速熟悉这个系统、帮我画架构图/调用链路图、用图梳理这个项目、deepwiki 风格报告、生成系统理解报告,或任何需要上手陌生仓库的请求。"
agent_created: true

Code Understanding Diagrams(清新 · 代码有据 · 图表化系统理解)

目的

把一个不熟悉的代码库转化为一份可导航的 HTML 报告,其中关于系统的每一条结论都带有可点击的 file:line 引用。报告以图为主、文字为辅(架构图、调用链时间线、ER 图、安全链路、部署流水线、依赖地图),采用清新多色相配色,并遵循「宏观 → 核心链路 → 微观」(图先行 / 线贯穿 / 点突破)的上手路径。

何时使用

  • 用户要求理解、梳理或上手某个仓库或子系统。
  • 用户要求为项目画架构图 / 调用链路图 / ER 图 / 配置图。
  • 用户提到 DeepWiki 风格总结,但要求清新配色与代码行号引用。
  • 用户希望得到一份可分享的「系统理解」HTML 文档。

各维度说明

报告覆盖以下十个维度,每个维度都有明确的取证来源、图表形式与对应 JSON 键:

维度 一句话说明 主要取证来源 图表形式 JSON 键
架构 Architecture 系统模块分层与依赖关系,建立宏观地图 README、目录结构、依赖文件 分层 SVG 架构图 architecture
调用链路 Call Chains 核心业务请求从入口到响应的完整路径 入口点 + 逐步读代码追踪 时间线(有序步骤 + 连线) call_chains
配置说明 Configuration 所有可变参数及作用,改之即变行为 配置文件 + 配置文档 + 代码引用 带行号表格 config
功能说明 Features 对用户可见的功能模块及其入口 代码 + 接口文档 卡片表格 features
库的说明 Libraries 第三方依赖、版本、实际被使用处 依赖清单(requirements/package.json 等) 依赖地图/表格(扫描器自动预填) libraries
数据模型/ER Data Model 核心表结构、字段、外键关系 SQL 迁移脚本 / ORM 模型 ER 图(表卡片 + 外键连线) data_model
错误处理 Errors 全局异常捕获、错误码、重试/降级 搜索异常处理代码 时间线 errors
安全与鉴权 Security 登录、token 校验、权限拦截点 拦截器/中间件 时间线 security
部署与CI/CD Deploy 构建、测试、打包、部署流水线 CI 配置 / Dockerfile 时间线/流程图 deploy
用户使用说明 Usage 本地搭建与运行步骤 README / Quick Start 步骤列表 usage

schema 是开放的:如需更多维度(消息队列 / 状态机 / 测试覆盖等),在 report_input.json 追加新键,并在 build_report.py 增加对应渲染分支即可(见步骤 5)。

黄金法则:每个图元素都必须引用真实代码

任何节点、连线、表或箭头,若没有 agent 实际读过的 file:line(最好附一小段引用代码),都不得出现。若某事实无法用读代码证实,应标注为「推测(待验证)」,而非断言。这是不可妥协的底线——报告的价值就在于可核实。

工作流程

步骤 0 — 初始化工作区

先运行扫描器,预填可核实的事实(依赖、带行号的配置键、入口点候选、路由/端点候选、SQL/ORM 数据模型候选)。全部为 stdlib-only、离线运行。

python3 SKILL_DIR/scripts/scan_project.py REPO_ROOT --out REPO_ROOT/report_input.json

SKILL_DIR 为本技能目录的绝对路径(WORKSPACE/.workbuddy/skills/code-understanding-diagrams)。扫描器会写出结构化的 report_input.json,能自动填好的部分预填,其余空数组/对象留给 agent 补全。

步骤 1 — 宏观概览:图先行

读取 report_input.json(扫描器预填)与仓库顶层文档(README、docs/、wiki)。然后借助 Read/Grep/Agent 探索,补全 architecture 段落:

  • 将每个组件归入一个 layer(如 接入层 / 业务层 / 数据层 / 基础设施层)。
  • 每个节点给出其定义的 file + line。
  • 用 edges 连接各层,每条边引用调用点的 file:line。

详见 references/methodology.md §架构,了解应收集哪些证据。

步骤 2 — 核心链路:线贯穿

挑选 1–3 条核心业务流(如「用户下单」「登录鉴权」)。对每条,从入口点到响应完整追踪,记录有序的 call_chains[].steps 列表。每一步引用定义的 file:line,并附关键代码片段(code 字段)。这是报告的核心——务必逐步实际读取下一个文件来核实每一跳。

步骤 3 — 微观维度:点突破

补全其余段落,均以 file:line 为依据:

  • config — 配置键、值、默认值,以及每个键在代码中被读取的位置。
  • data_model — 表/字段(来自迁移脚本或 ORM 模型)及关系。
  • security — 鉴权/登录/权限链路,含拦截器 file:line。
  • errors — 全局异常处理、错误码、重试/降级路径。
  • deploy — 构建/测试/部署各阶段及流水线文件 file:line。
  • libraries — 依赖、版本,以及每处实际被使用的地方。
  • features — 对用户可见的功能,映射到其入口 file:line。
  • usage — 本地搭建/运行命令及文档 file:line。

如需新增项目特定维度,在 JSON 中追加新键,并在 build_report.py 增加对应渲染分支(见步骤 5)。schema 是开放的。

步骤 4 — 生成 HTML 报告

python3 SKILL_DIR/scripts/build_report.py REPO_ROOT/report_input.json \
        --out REPO_ROOT/code-understanding-report.html

生成器渲染清新图表(架构/ER/依赖图用 SVG,调用链/安全/错误/部署用 HTML 时间线,配置/功能用表格),并内嵌 file:line 引用与代码片段。打开 HTML 核对配色、布局,以及每个元素是否都链向真实代码。

步骤 5 — 迭代与扩展

若用户想要更多维度(如 消息队列 / 状态机 / 测试覆盖),在 report_input.json 追加段落;若需新图类型,在 build_report.py 中按现有渲染器模式扩展(每个渲染器接收一个段落 dict 与 PALETTE 清新色板,返回 HTML 片段;每个节点携带 file/line)。

数据契约(report_input.json)

扫描器创建该文件,agent 编辑它。最简结构:

{
  "meta": {"project_name": "", "repo_path": "", "tech_stack": [], "summary": ""},
  "architecture": {"layers": [{"name": "", "nodes": [{"id":"", "label":"", "file":"", "line":0, "note":""}]}], "edges": [{"from":"", "to":"", "label":"", "file":"", "line":0}]},
  "call_chains": [{"name":"", "steps":[{"order":0,"component":"","action":"","file":"","line":0,"code":""}], "edges":[{"from":0,"to":0,"label":""}]}],
  "config": [{"file":"","line":0,"key":"","value":"","desc":"","used_in":""}],
  "data_model": {"tables":[{"name":"","file":"","line":0,"fields":[{"name":"","type":"","pk":false}],"note":""}], "relations":[{"from":"","to":"","type":"","on":"","file":"","line":0}]},
  "security": {"chains":[{"name":"","steps":[{"order":0,"component":"","action":"","file":"","line":0,"code":""}]}]},
  "errors": {"chains":[{"name":"","steps":[{"order":0,"component":"","action":"","file":"","line":0,"code":""}]}]},
  "deploy": {"stages":[{"name":"","file":"","line":0,"note":""}]},
  "libraries": [{"name":"","version":"","file":"","line":0,"used_for":"","used_in":""}],
  "features": [{"name":"","file":"","line":0,"desc":"","related":""}],
  "usage": [{"title":"","steps":[{"cmd":"","file":"","line":0}]}]
}

所有 file 字段均相对于 repo_path。line 从 1 开始计数。空段落会优雅渲染为「未提供 / 待补充」占位,因此部分报告也有效。

输出设计规范

  • 清新色系(薄荷/青绿/天蓝/叶绿): 浅底(#F1FAF7)、薄荷/青绿/天蓝/叶绿节点填充、深青文字(#2C4A45)。保持通透、低饱和、多色相,避免厚重暖橙。
  • 色相多样: 循环使用清新色列表,使相邻节点明显区分。
  • 引用可见: 每个节点/边/行都显示 file:line 徽标;点击展开引用片段。
  • 单一自包含 HTML: 内联 CSS + SVG,不发起任何外部网络请求。

错误处理与排障

技能执行分两步(扫描、生成)。任一步报错都有明确提示与恢复路径,不要直接放弃——按以下清单排查:

扫描阶段 scan_project.py 报错

  • repo not found: <path>:路径不存在。确认 REPO_ROOT 正确且存在,优先用绝对路径(如 /abs/path/to/repo)而非相对路径。
  • 超大仓库扫描过慢/内存偏高:默认扫描上限为 --max-files 8000。可追加 --max-files 0 取消限制,或 --max-files 20000 调大(0 表示不限制)。达上限会打印 [warn] 并停止,结果以已提取事实为准。
  • 个别文件编码/权限异常:扫描器对单文件读取已做 try/except 跳过,并在 stderr 打印 [warn],不影响整体;最终报告以已提取事实为准。
  • 无法写入输出文件 <out>: ...:输出目录不可写。改用可写路径(如 --out /tmp/report_input.json)。

生成阶段 build_report.py 报错

  • 无法读取输入 <in>: ...:输入不是合法 JSON。用 python3 -m json.tool <in> 校验;确认文件由扫描器生成或被 agent 正确手填。
  • 单个段落渲染失败:生成器对每段独立 try/except,出错时该段渲染为「⚠ 该段落渲染出错(已跳过)」占位,并在 stderr 告警 [warn] 段落「X」渲染失败已跳过,其余段落正常输出。检查该段 JSON 字段类型(如 edges/steps 应为数组、architecture 应为对象)。
  • 顶层不是 JSON 对象:自动退化为空结构并告警,仍可生成基础报告。
  • 无法写入输出 <out>: ...:输出目录不可写,换可写路径。

通用原则

  • 扫描与生成均为 stdlib-only、离线运行,无需联网,也不依赖第三方包;使用 python3(建议 3.8+)。
  • 路径一律用绝对路径,避免 cwd 错位导致找不到仓库或写错位置。
  • 报告渲染失败或某段缺失时,会优雅降级为「未提供 / 待补充」占位,仍是一份可用文档;先交付再补强。

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value95/100

Highlights

  • 解决开发者快速理解陌生代码库的核心痛点,覆盖架构、调用链路、配置、安全等十大维度
  • 强调每个图表元素必须引用真实源码 file:line,确保报告可核实、高可信
  • 生成清新配色的自包含 HTML 报告,支持可导航、可分享的系统理解文档
Trigger Precision92/100

Highlights

  • 触发语覆盖全面且边界清晰,包括“快速熟悉系统”、“画架构图”、“deepwiki 风格报告”等典型场景
  • 能有效区分于通用代码分析工具,聚焦于图表化、可引用的系统理解报告
Structure and Standards85/100

Areas to improve

  • Document is too long Reported severity: Minor

    SKILL.md 内容约 600 行,超出建议的 500 行上限

    Recommendation: 可考虑将部分详细说明(如错误处理清单、数据契约示例)移至 references/ 子文档,主文件保留核心流程

  • 缺少显式 When to Use 章节 Reported severity: Minor

    虽有「何时使用」段落,但未以标准 frontmatter 形式呈现

    Recommendation: 在 frontmatter 后增加显式 ## When to Use 章节,提升可读性

Highlights

  • 工作流程分步骤清晰(步骤 0-5),每步有明确目标与输出
  • 提供完整的数据契约示例与脚本调用命令,便于直接执行
  • 开放 schema 设计支持扩展新维度,具备良好的可演进性
Execution Reliability88/100

Highlights

  • 扫描与生成脚本均为 stdlib-only、离线运行,不依赖第三方包,环境兼容性强
  • 两阶段均有完善的错误处理与优雅降级机制(如段落渲染失败仍输出其余内容)
  • 路径处理建议明确(优先绝对路径),减少执行环境错位风险
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.