understand-anything-knowledge-graph

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Understand 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-anything
bash
/plugin marketplace add Lum1104/Understand-Anything
/plugin install understand-anything

From 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 build

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 build

Core Skills / Commands

核心技能/命令

CommandWhat it does
/understand
Run the full multi-agent analysis pipeline on the current project
/understand-dashboard
Open the interactive knowledge graph dashboard
/understand-chat <question>
Ask anything about the codebase in natural language
/understand-diff
Analyze impact of current uncommitted changes
/understand-explain <path>
Deep-dive explanation of a specific file or function
/understand-onboard
Generate an onboarding guide for new team members

命令功能
/understand
在当前项目上运行完整的多Agent分析流程
/understand-dashboard
打开交互式知识图谱面板
/understand-chat <question>
用自然语言查询代码库相关问题
/understand-diff
分析当前未提交更改的影响范围
/understand-explain <path>
深度解析指定文件或函数
/understand-onboard
为新团队成员生成入职指南

Typical Workflow

典型工作流程

1. Analyze a project

1. 分析项目

bash
undefined
bash
undefined

Inside 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-dashboard
The 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-dashboard
React + 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
undefined
bash
undefined

After 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.ts

bash
/understand-explain src/auth/login.ts
/understand-explain src/services/PaymentService.ts

Knowledge Graph Schema

知识图谱 Schema

The graph is stored at
.understand-anything/knowledge-graph.json
. Key types (from
packages/core
):
typescript
// 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.json
文件中,核心类型定义来自
packages/core
typescript
// 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
undefined
bash
undefined

Start 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
/understand
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.
To force a full re-analysis:
bash
rm -rf .understand-anything/
/understand

重新运行
/understand
时,只会重新分析自上次运行以来修改过的文件(基于图谱元数据中存储的修改时间和内容哈希)。对于大型单体仓库,后续运行会非常快速。
如需强制全量重新分析:
bash
rm -rf .understand-anything/
/understand

Development 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 HMR

bash
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
undefined
bash
undefined

See what your diff actually touches in the architecture

查看代码变更在架构层面的影响范围

/understand-diff
undefined
/understand-diff
undefined

Onboarding a new engineer

新工程师入职

bash
undefined
bash
undefined

Generate a structured onboarding doc grounded in the real code

基于真实代码生成结构化的入职指南

/understand-onboard
undefined
/understand-onboard
undefined

Researching 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.ts
bash
/understand-explain src/workers/queue-processor.ts

Returns: summary, key functions, what calls it, what it calls, concepts used

返回内容:摘要、核心函数、调用方、依赖项、用到的编程概念


---

---

Troubleshooting

故障排除

/understand
times out on large repos
  • The file-analyzer runs up to 3 workers concurrently. Very large repos (>50k files) may need patience. Delete
    .understand-anything/
    and re-run if a previous run was interrupted.
Dashboard doesn't open
  • Run
    pnpm --filter @understand-anything/dashboard build
    first if working from source, then retry
    /understand-dashboard
    .
Stale graph after major refactor
  • Delete
    .understand-anything/knowledge-graph.json
    to force full re-analysis:
    rm .understand-anything/knowledge-graph.json && /understand
pnpm install
fails with workspace errors
  • Ensure you are using pnpm v8+:
    pnpm --version
    . The project uses pnpm workspaces defined in
    pnpm-workspace.yaml
    .
Search returns no results
  • Confirm the graph was generated:
    cat .understand-anything/knowledge-graph.json | head -5
    . If empty or missing, run
    /understand
    first.

/understand
在大型仓库中超时
  • 文件分析器最多支持3个并发Worker。超大型仓库(>50k文件)可能需要更多时间。如果之前的运行被中断,删除
    .understand-anything/
    后重新运行。
面板无法打开
  • 如果从源码安装,先执行
    pnpm --filter @understand-anything/dashboard build
    ,然后重试
    /understand-dashboard
重大重构后图谱内容过时
  • 删除
    .understand-anything/knowledge-graph.json
    强制全量重新分析:
    rm .understand-anything/knowledge-graph.json && /understand
pnpm install
因工作区配置失败
  • 确保使用pnpm v8+版本:
    pnpm --version
    。项目使用
    pnpm-workspace.yaml
    定义的pnpm工作区。
搜索无结果
  • 确认图谱已生成:
    cat .understand-anything/knowledge-graph.json | head -5
    。如果文件为空或不存在,先运行
    /understand

Contributing

贡献指南

bash
undefined
bash
undefined

Fork, 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)