understand-anything-knowledge-graph
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUnderstand Anything — Codebase Knowledge Graph
Understand Anything — 代码库知识图谱
Skill by ara.so — Daily 2026 Skills collection.
Understand Anything is a Claude Code plugin that runs a multi-agent pipeline over your project, builds a knowledge graph of every file, function, class, and dependency, and opens an interactive React dashboard for visual exploration. It produces plain-English summaries of every node so anyone — developer, PM, or designer — can understand the codebase.
由ara.so开发的技能——属于Daily 2026技能合集。
Understand Anything是一款Claude Code插件,它会在你的项目上运行多Agent分析流程,构建包含所有文件、函数、类和依赖的知识图谱,并打开一个交互式React面板供你可视化探索。它会为每个节点生成通俗易懂的英文摘要,让开发者、产品经理或设计师都能轻松理解代码库。
Installation
安装
Via Claude Code plugin marketplace
通过Claude Code插件市场
bash
/plugin marketplace add Lum1104/Understand-Anything
/plugin install understand-anythingbash
/plugin marketplace add Lum1104/Understand-Anything
/plugin install understand-anythingFrom source (development)
从源码安装(开发环境)
bash
git clone https://github.com/Lum1104/Understand-Anything
cd Understand-Anything
pnpm install
pnpm --filter @understand-anything/core build
pnpm --filter @understand-anything/skill build
pnpm --filter @understand-anything/dashboard buildbash
git clone https://github.com/Lum1104/Understand-Anything
cd Understand-Anything
pnpm install
pnpm --filter @understand-anything/core build
pnpm --filter @understand-anything/skill build
pnpm --filter @understand-anything/dashboard buildCore Skills / Commands
核心技能/命令
| Command | What it does |
|---|---|
| Run the full multi-agent analysis pipeline on the current project |
| Open the interactive knowledge graph dashboard |
| Ask anything about the codebase in natural language |
| Analyze impact of current uncommitted changes |
| Deep-dive explanation of a specific file or function |
| Generate an onboarding guide for new team members |
| 命令 | 功能 |
|---|---|
| 在当前项目上运行完整的多Agent分析流程 |
| 打开交互式知识图谱面板 |
| 用自然语言查询代码库相关问题 |
| 分析当前未提交更改的影响范围 |
| 深度解析指定文件或函数 |
| 为新团队成员生成入职指南 |
Typical Workflow
典型工作流程
1. Analyze a project
1. 分析项目
bash
undefinedbash
undefinedInside any project directory, in Claude Code:
在任意项目目录的Claude Code中执行:
/understand
This orchestrates 5 agents in sequence (with file-analyzers running up to 3 concurrent):
1. **project-scanner** — discovers files, detects languages/frameworks
2. **file-analyzer** — extracts functions, classes, imports; builds graph nodes and edges
3. **architecture-analyzer** — groups nodes into architectural layers (API, Service, Data, UI, Utility)
4. **tour-builder** — generates ordered learning tours
5. **graph-reviewer** — validates referential integrity
Output is saved to `.understand-anything/knowledge-graph.json` in your project root./understand
该命令会依次调度5个Agent(文件分析器最多支持3个并发运行):
1. **project-scanner** — 发现文件,检测语言/框架
2. **file-analyzer** — 提取函数、类、导入关系;构建图谱节点和关联边
3. **architecture-analyzer** — 将节点按架构层分组(API、服务、数据、UI、工具)
4. **tour-builder** — 生成有序的学习引导路径
5. **graph-reviewer** — 验证引用完整性
输出结果会保存到项目根目录的`.understand-anything/knowledge-graph.json`文件中。2. Open the dashboard
2. 打开可视化面板
bash
/understand-dashboardThe React + Vite dashboard opens in your browser. Features:
- Graph view — React Flow canvas, color-coded by layer, zoom/pan
- Node inspector — click any node for code, relationships, LLM summary
- Search — fuzzy + semantic search across all nodes
- Tours — guided walkthroughs ordered by dependency
- Persona mode — toggle detail level (Junior Dev / PM / Power User)
bash
/understand-dashboardReact + Vite构建的面板会在浏览器中打开,包含以下功能:
- 图谱视图 — 基于React Flow的画布,按架构层颜色区分,支持缩放/平移
- 节点检查器 — 点击任意节点查看代码、关联关系和LLM生成的摘要
- 搜索 — 对所有节点进行模糊+语义搜索
- 引导路径 — 按依赖关系排序的分步学习指南
- 角色模式 — 切换细节展示级别(初级开发者/产品经理/高级用户)
3. Ask questions
3. 查询代码库
bash
/understand-chat How does authentication work in this project?
/understand-chat What calls the payment service?
/understand-chat Which files are most depended on?bash
/understand-chat 这个项目的认证机制是如何工作的?
/understand-chat 哪些模块调用了支付服务?
/understand-chat 哪些文件的依赖度最高?4. Review diff impact before committing
4. 提交前审查变更影响
bash
undefinedbash
undefinedAfter making changes:
完成代码修改后执行:
/understand-diff
Returns a list of affected nodes in the knowledge graph — shows ripple effects before you push./understand-diff
返回知识图谱中受影响的节点列表——在推送代码前展示变更的连锁反应。5. Explain a specific file
5. 解析指定文件
bash
/understand-explain src/auth/login.ts
/understand-explain src/services/PaymentService.tsbash
/understand-explain src/auth/login.ts
/understand-explain src/services/PaymentService.tsKnowledge Graph Schema
知识图谱 Schema
The graph is stored at . Key types (from ):
.understand-anything/knowledge-graph.jsonpackages/coretypescript
// packages/core/src/types.ts
interface GraphNode {
id: string; // unique: "file:src/auth/login.ts"
type: "file" | "function" | "class" | "module";
name: string;
filePath: string;
layer: ArchitectureLayer; // "api" | "service" | "data" | "ui" | "utility"
summary: string; // LLM-generated plain-English description
code?: string; // raw source snippet
language?: string;
concepts?: LanguageConcept[]; // e.g. "generics", "closures", "decorators"
metadata?: Record<string, unknown>;
}
interface GraphEdge {
id: string;
source: string; // node id
target: string; // node id
type: "imports" | "calls" | "extends" | "implements" | "uses";
label?: string;
}
interface KnowledgeGraph {
version: string;
generatedAt: string;
projectRoot: string;
nodes: GraphNode[];
edges: GraphEdge[];
tours: GuidedTour[];
}
type ArchitectureLayer = "api" | "service" | "data" | "ui" | "utility" | "unknown";
type LanguageConcept =
| "generics"
| "closures"
| "decorators"
| "async-await"
| "interfaces"
| "higher-order-functions"
| "dependency-injection"
| "observers"
| "iterators"
| "pattern-matching"
| "monads"
| "currying";图谱存储在文件中,核心类型定义来自:
.understand-anything/knowledge-graph.jsonpackages/coretypescript
// packages/core/src/types.ts
interface GraphNode {
id: string; // 唯一标识:"file:src/auth/login.ts"
type: "file" | "function" | "class" | "module";
name: string;
filePath: string;
layer: ArchitectureLayer; // "api" | "service" | "data" | "ui" | "utility"
summary: string; // LLM生成的通俗易懂的描述
code?: string; // 原始代码片段
language?: string;
concepts?: LanguageConcept[]; // 例如 "generics", "closures", "decorators"
metadata?: Record<string, unknown>;
}
interface GraphEdge {
id: string;
source: string; // 源节点ID
target: string; // 目标节点ID
type: "imports" | "calls" | "extends" | "implements" | "uses";
label?: string;
}
interface KnowledgeGraph {
version: string;
generatedAt: string;
projectRoot: string;
nodes: GraphNode[];
edges: GraphEdge[];
tours: GuidedTour[];
}
type ArchitectureLayer = "api" | "service" | "data" | "ui" | "utility" | "unknown";
type LanguageConcept =
| "generics"
| "closures"
| "decorators"
| "async-await"
| "interfaces"
| "higher-order-functions"
| "dependency-injection"
| "observers"
| "iterators"
| "pattern-matching"
| "monads"
| "currying";Working with the Core Package Programmatically
以编程方式使用核心包
typescript
import { loadKnowledgeGraph, searchGraph, buildTour } from "@understand-anything/core";
// Load the persisted graph
const graph = await loadKnowledgeGraph(".understand-anything/knowledge-graph.json");
// Fuzzy search across all nodes
const results = searchGraph(graph, "payment processing");
console.log(results.map(r => `${r.type}:${r.name} (${r.filePath})`));
// Find all callers of a function
const paymentNode = graph.nodes.find(n => n.name === "processPayment");
const callers = graph.edges
.filter(e => e.target === paymentNode?.id && e.type === "calls")
.map(e => graph.nodes.find(n => n.id === e.source));
// Get all nodes in the service layer
const serviceNodes = graph.nodes.filter(n => n.layer === "service");
// Build a guided tour starting from a specific node
const tour = buildTour(graph, { startNodeId: "file:src/index.ts" });
tour.steps.forEach((step, i) => {
console.log(`Step ${i + 1}: ${step.node.name} — ${step.node.summary}`);
});typescript
import { loadKnowledgeGraph, searchGraph, buildTour } from "@understand-anything/core";
// 加载已持久化的图谱
const graph = await loadKnowledgeGraph(".understand-anything/knowledge-graph.json");
// 对所有节点进行模糊搜索
const results = searchGraph(graph, "payment processing");
console.log(results.map(r => `${r.type}:${r.name} (${r.filePath})`));
// 查找调用某个函数的所有节点
const paymentNode = graph.nodes.find(n => n.name === "processPayment");
const callers = graph.edges
.filter(e => e.target === paymentNode?.id && e.type === "calls")
.map(e => graph.nodes.find(n => n.id === e.source));
// 获取服务层的所有节点
const serviceNodes = graph.nodes.filter(n => n.layer === "service");
// 从指定节点开始构建引导学习路径
const tour = buildTour(graph, { startNodeId: "file:src/index.ts" });
tour.steps.forEach((step, i) => {
console.log(`步骤 ${i + 1}: ${step.node.name} — ${step.node.summary}`);
});Dashboard Development
面板开发
bash
undefinedbash
undefinedStart the dashboard dev server (hot reload)
启动面板开发服务器(支持热重载)
pnpm dev:dashboard
pnpm dev:dashboard
Build for production
构建生产版本
pnpm --filter @understand-anything/dashboard build
The dashboard is a Vite + React 18 app using:
- **React Flow** — graph canvas rendering
- **Zustand** — graph state management
- **TailwindCSS v4** — styling
- **Fuse.js** — fuzzy search
- **web-tree-sitter** — in-browser AST parsing
- **Dagre** — automatic graph layout
---pnpm --filter @understand-anything/dashboard build
该面板是基于Vite + React 18的应用,使用了以下技术:
- **React Flow** — 图谱画布渲染
- **Zustand** — 图谱状态管理
- **TailwindCSS v4** — 样式框架
- **Fuse.js** — 模糊搜索
- **web-tree-sitter** — 浏览器端AST解析
- **Dagre** — 自动图谱布局
---Project Structure
项目结构
understand-anything-plugin/
├── .claude-plugin/ # Plugin manifest (read by Claude Code)
├── agents/ # Agent definitions (project-scanner, file-analyzer, etc.)
├── skills/ # Skill definitions (/understand, /understand-chat, etc.)
├── src/ # Plugin TypeScript source
│ ├── context-builder.ts # Builds LLM context from the graph
│ └── diff-analyzer.ts # Git diff → affected nodes
├── packages/
│ ├── core/ # Analysis engine
│ │ ├── src/
│ │ │ ├── types.ts # GraphNode, GraphEdge, KnowledgeGraph
│ │ │ ├── persistence.ts
│ │ │ ├── search.ts # Fuzzy + semantic search
│ │ │ ├── tours.ts # Tour generation
│ │ │ ├── schema.ts # Zod validation schemas
│ │ │ └── tree-sitter.ts
│ │ └── tests/
│ └── dashboard/ # React dashboard app
│ └── src/understand-anything-plugin/
├── .claude-plugin/ # 插件清单(供Claude Code读取)
├── agents/ # Agent定义(project-scanner、file-analyzer等)
├── skills/ # 技能定义(/understand、/understand-chat等)
├── src/ # 插件TypeScript源码
│ ├── context-builder.ts # 从图谱构建LLM上下文
│ └── diff-analyzer.ts # Git diff → 受影响节点分析
├── packages/
│ ├── core/ # 分析引擎
│ │ ├── src/
│ │ │ ├── types.ts # GraphNode、GraphEdge、KnowledgeGraph类型定义
│ │ │ ├── persistence.ts
│ │ │ ├── search.ts # 模糊+语义搜索
│ │ │ ├── tours.ts # 引导路径生成
│ │ │ ├── schema.ts # Zod验证规则
│ │ │ └── tree-sitter.ts
│ │ └── tests/
│ └── dashboard/ # React面板应用
│ └── src/Incremental Updates
增量更新
Re-running only re-analyzes files that changed since the last run (based on mtime and content hash stored in the graph metadata). For large monorepos this makes subsequent runs fast.
/understandTo force a full re-analysis:
bash
rm -rf .understand-anything/
/understand重新运行时,只会重新分析自上次运行以来修改过的文件(基于图谱元数据中存储的修改时间和内容哈希)。对于大型单体仓库,后续运行会非常快速。
/understand如需强制全量重新分析:
bash
rm -rf .understand-anything/
/understandDevelopment Commands
开发命令
bash
pnpm install # Install all dependencies
pnpm --filter @understand-anything/core build # Build core package
pnpm --filter @understand-anything/core test # Run core tests
pnpm --filter @understand-anything/skill build # Build plugin package
pnpm --filter @understand-anything/skill test # Run plugin tests
pnpm --filter @understand-anything/dashboard build # Build dashboard
pnpm dev:dashboard # Dashboard dev server with HMRbash
pnpm install # 安装所有依赖
pnpm --filter @understand-anything/core build # 构建核心包
pnpm --filter @understand-anything/core test # 运行核心包测试
pnpm --filter @understand-anything/skill build # 构建插件包
pnpm --filter @understand-anything/skill test # 运行插件包测试
pnpm --filter @understand-anything/dashboard build # 构建面板
pnpm dev:dashboard # 启动面板开发服务器(支持热重载)Common Patterns
常见使用场景
Before a code review
代码审查前
bash
undefinedbash
undefinedSee what your diff actually touches in the architecture
查看代码变更在架构层面的影响范围
/understand-diff
undefined/understand-diff
undefinedOnboarding a new engineer
新工程师入职
bash
undefinedbash
undefinedGenerate a structured onboarding doc grounded in the real code
基于真实代码生成结构化的入职指南
/understand-onboard
undefined/understand-onboard
undefinedResearching a feature area
研究特定功能模块
bash
/understand-chat What are all the entry points for the GraphQL API?
/understand-explain src/graphql/resolvers/bash
/understand-chat GraphQL API的所有入口点有哪些?
/understand-explain src/graphql/resolvers/Understanding an unfamiliar module
理解陌生模块
bash
/understand-explain src/workers/queue-processor.tsbash
/understand-explain src/workers/queue-processor.tsReturns: summary, key functions, what calls it, what it calls, concepts used
返回内容:摘要、核心函数、调用方、依赖项、用到的编程概念
---
---Troubleshooting
故障排除
/understand- The file-analyzer runs up to 3 workers concurrently. Very large repos (>50k files) may need patience. Delete and re-run if a previous run was interrupted.
.understand-anything/
Dashboard doesn't open
- Run first if working from source, then retry
pnpm --filter @understand-anything/dashboard build./understand-dashboard
Stale graph after major refactor
- Delete to force full re-analysis:
.understand-anything/knowledge-graph.jsonrm .understand-anything/knowledge-graph.json && /understand
pnpm install- Ensure you are using pnpm v8+: . The project uses pnpm workspaces defined in
pnpm --version.pnpm-workspace.yaml
Search returns no results
- Confirm the graph was generated: . If empty or missing, run
cat .understand-anything/knowledge-graph.json | head -5first./understand
/understand- 文件分析器最多支持3个并发Worker。超大型仓库(>50k文件)可能需要更多时间。如果之前的运行被中断,删除后重新运行。
.understand-anything/
面板无法打开
- 如果从源码安装,先执行,然后重试
pnpm --filter @understand-anything/dashboard build。/understand-dashboard
重大重构后图谱内容过时
- 删除强制全量重新分析:
.understand-anything/knowledge-graph.jsonrm .understand-anything/knowledge-graph.json && /understand
pnpm install- 确保使用pnpm v8+版本:。项目使用
pnpm --version定义的pnpm工作区。pnpm-workspace.yaml
搜索无结果
- 确认图谱已生成:。如果文件为空或不存在,先运行
cat .understand-anything/knowledge-graph.json | head -5。/understand
Contributing
贡献指南
bash
undefinedbash
undefinedFork, then:
Fork仓库后:
git checkout -b feature/my-feature
pnpm --filter @understand-anything/core test # must pass
git checkout -b feature/my-feature
pnpm --filter @understand-anything/core test # 测试必须通过
open a PR — file an issue first for major changes
提交PR——重大变更请先提交issue讨论
License: MIT © [Lum1104](https://github.com/Lum1104)
许可证:MIT © [Lum1104](https://github.com/Lum1104)