understand-explain
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/understand-explain
/understand-explain
Provide a thorough, in-depth explanation of a specific code component.
提供对特定代码组件的全面、深度解析。
Graph Structure Reference
知识图谱结构参考
The knowledge graph JSON has this structure:
- — {name, description, languages, frameworks, analyzedAt, gitCommitHash}
project - — each has {id, type, name, filePath, summary, tags[], complexity, languageNotes?}
nodes[]- Node types: file, function, class, module, concept
- IDs: ,
file:path,func:path:nameclass:path:name
- — each has {source, target, type, direction, weight}
edges[]- Key types: imports, contains, calls, depends_on
- — each has {id, name, description, nodeIds[]}
layers[] - — each has {order, title, description, nodeIds[]}
tour[]
知识图谱JSON的结构如下:
- — {name, description, languages, frameworks, analyzedAt, gitCommitHash}
project - — 每个节点包含{id, type, name, filePath, summary, tags[], complexity, languageNotes?}
nodes[]- 节点类型:file(文件)、function(函数)、class(类)、module(模块)、concept(概念)
- ID格式:、
file:path、func:path:nameclass:path:name
- — 每条边包含{source, target, type, direction, weight}
edges[]- 主要边类型:imports(导入)、contains(包含)、calls(调用)、depends_on(依赖)
- — 每个层级包含{id, name, description, nodeIds[]}
layers[] - — 每个导览项包含{order, title, description, nodeIds[]}
tour[]
How to Read Efficiently
高效阅读指南
- Use Grep to search within the JSON for relevant entries BEFORE reading the full file
- Only read sections you need — don't dump the entire graph into context
- Node names and summaries are the most useful fields for understanding
- Edges tell you how components connect — follow imports and calls for dependency chains
- 在阅读完整文件之前,先用Grep在JSON中搜索相关条目
- 只阅读你需要的部分——不要把整个图谱都加载到上下文里
- 节点名称和摘要部分是理解内容最有用的字段
- 边信息告诉你组件之间的关联——通过导入和调用关系追踪依赖链
Instructions
操作步骤
-
Check thatexists. If not, tell the user to run
.understand-anything/knowledge-graph.jsonfirst./understand -
Find the target node — use Grep to search the knowledge graph for the component: "$ARGUMENTS"
- For file paths (e.g., ): search for
src/auth/login.tsmatches"filePath" - For function notation (e.g., ): search for the function name in
src/auth/login.ts:verifyTokenfields filtered by the file path"name" - Note the exact node ,
id,type,summary, andtagscomplexity
- For file paths (e.g.,
-
Find all connected edges — Grep for the target node's ID in the edges section:
- matches → things this node calls/imports/depends on (outgoing)
"source" - matches → things that call/import/depend on this node (incoming)
"target" - Note the connected node IDs and edge types
-
Read connected nodes — for each connected node ID from step 3, Grep for those IDs in the nodes section to get their,
name, andsummary. This builds the component's neighborhood.type -
Identify the layer — Grep for the target node's ID in thesection to find which architectural layer it belongs to and that layer's description.
"layers" -
Read the actual source file — Read the source file at the node'sfor the deep-dive analysis.
filePath -
Explain the component in context:
- Its role in the architecture (which layer, why it exists)
- Internal structure (functions, classes it contains — from edges)
contains - External connections (what it imports, what calls it, what it depends on — from edges)
- Data flow (inputs → processing → outputs — from source code)
- Explain clearly, assuming the reader may not know the programming language
- Highlight any patterns, idioms, or complexity worth understanding
-
检查是否存在。如果不存在,告知用户先运行
.understand-anything/knowledge-graph.json命令。/understand -
定位目标节点——使用Grep在知识图谱中搜索目标组件:"$ARGUMENTS"
- 对于文件路径(例如):搜索匹配
src/auth/login.ts的条目"filePath" - 对于函数标识(例如):在指定文件路径过滤后的
src/auth/login.ts:verifyToken字段中搜索函数名称"name" - 记录目标节点的准确、
id、type、summary和tagscomplexity
- 对于文件路径(例如
-
查找所有关联边——在边信息部分搜索目标节点的ID:
- 匹配的条目 → 该节点调用/导入/依赖的对象(向外关联)
"source" - 匹配的条目 → 调用/导入/依赖该节点的对象(向内关联)
"target" - 记录关联节点的ID和边类型
- 匹配
-
查看关联节点——针对步骤3中找到的每个关联节点ID,在节点部分搜索这些ID,获取它们的、
name和summary。以此构建目标组件的关联网络。type -
确定所属层级——在部分搜索目标节点的ID,找到它所属的架构层级以及该层级的描述。
"layers" -
查看实际源代码文件——打开节点对应的源代码文件,进行深度分析。
filePath -
结合上下文解析组件:
- 它在架构中的角色(所属层级,存在的意义)
- 内部结构(包含的函数、类——来自边信息)
contains - 外部关联(它导入的内容、调用它的对象、它依赖的对象——来自边信息)
- 数据流(输入→处理→输出——来自源代码)
- 解释要清晰,假设读者可能不熟悉该编程语言
- 突出任何值得关注的模式、惯用写法或复杂度要点