/understand-explain command focuses the knowledge graph on a single file or function and produces a detailed explanation: what it does, why it exists, how data flows through it, which other components it interacts with, and any language patterns or design decisions worth noting.
Use it when you need to truly understand a specific module before modifying it, during code review, or when onboarding to an unfamiliar part of the system.
Usage
Arguments
| Argument | Description |
|---|---|
<path> | Relative path to a source file (e.g. src/auth/login.ts) |
<path>:<function-name> | Path combined with a function or class name to target a specific node (e.g. src/auth/login.ts:validateToken) |
How it works
Locate the target node
The path is matched against the knowledge graph. If a
path:name format is provided, it first looks for a node with that exact file path and name. If not found, it falls back to matching by file path alone.Collect child nodes
All nodes contained inside the target (via
contains edges) are gathered — for a file node this includes all its functions and classes; for a class node this includes its methods.Find connected components
All 1-hop neighbors of the target and its children are collected: importers, callees, dependencies, and related nodes. The full set of relevant edges is recorded.
Resolve architectural layer
The layer that contains the target node is identified and included in the explanation.
Output
A structured explanation that covers:- Type and complexity — node type (file, function, class) and complexity rating
- Location — file path and line range
- Plain-English summary — what the component does and why it exists
- Architectural layer — where it sits in the system
- Internal components — child functions, methods, or classes
- Connected components — callers, imports, dependencies with relationship types
- Relationships — edge-level view of all connections (
calls,imports,depends_on, etc.) - Language notes — programming patterns, idioms, or concepts present in the component
If the path is not found in the knowledge graph, the command will say so and suggest running
/understand first or checking the exact file path.Examples
Related commands
/understand-chat
Ask free-form questions about how components relate to each other.
/understand-diff
See the blast radius when you modify this component.
/understand-dashboard
Visualize the component and its connections in the interactive graph.
/understand
Build or update the graph so new files are available for explanation.