# 代码库知识图谱 (understand)

> 分析代码库，在 .ua/ 目录生成 knowledge-graph.json，包含文件、符号、关系、架构分层和导览，供交互式仪表盘浏览。

- 分类: [架构调优](https://www.myskills.tools/zh/categories/architecture-tuning/)
- 来源: 社区 · Egonex-AI
- 代码仓库: https://github.com/Egonex-AI/Understand-Anything/tree/main/understand-anything-plugin/skills/understand (commit 08d16bd)
- SKILL.md: https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/skills/understand/SKILL.md
- 安装命令: `npx skills add Egonex-AI/Understand-Anything --skill understand`
- 许可证: MIT
- 兼容工具: Claude Code, Codex, Cursor, Copilot, Gemini CLI
- 权限: read-repo ✓, write-files ✓, shell ✓, network ✓
- 状态: 扫描通过
- 规则扫描无法覆盖所有风险，安装前请阅读此技能的 SKILL.md，确认权限后再使用。
- ⚠ 首次运行会在插件目录执行 pnpm install 并构建；大型代码库的分析会派出大量子代理，耗时较长。

## 核心规则

绝不静默吞掉错误，每一次失败都必须出现在最终报告中。

## 执行阶段

1. **预检与配置** — 确定项目根目录和 .ua/ 数据目录，必要时构建插件，读取已有图谱并判断全量还是增量分析。
2. **扫描与分批** — 按 .understandignore 和 --exclude 规则扫描文件、识别语言与框架，再计算语义批次。
3. **并行分析文件** — 最多 5 个子代理并发分析各批文件，合并为节点和边，并审查组装后的图谱。
4. **分层与导览** — 识别架构分层并生成引导式导览，随后校验整个图谱。
5. **保存与汇报** — 写入图谱、指纹基线和 meta.json，清理中间文件，汇报统计；校验通过时自动打开仪表盘。

## 权限说明（据 SKILL.md 整理）

| 能力 | 是否需要 | 说明 |
|---|---|---|
| 文件写入 | 部分需要 | 只在项目的 .ua/（或旧版 .understand-anything/）数据目录内写入图谱、配置和中间文件，不修改源码。 |
| 命令执行 | 需要 | 运行 git、自带的 Node 和 Python 脚本，并在首次使用时执行 pnpm install 和构建。 |
| 网络外发 | 部分需要 | 仅在插件尚未构建时通过 pnpm install 下载依赖；分析过程本身不访问网络。 |

## SKILL.md 头部信息（YAML）

```yaml
---
name: understand
description: Analyze a codebase to produce an interactive knowledge graph for understanding architecture, components, and relationships
argument-hint: ["[path] [--full|--auto-update|--no-auto-update|--review|--language <lang>|--exclude <patterns>]"]
---
```

首页: https://www.myskills.tools/zh/ · URL: https://www.myskills.tools/zh/skills/understand/
