You've built a graph. Now learn to ask it the right questions — both from the CLI and from inside an AI session.
After this lesson, you'll know how to use graphify path and graphify explain to answer structural questions without reading source files, and how to phrase prompts that leverage graph context.
Graphify gives you two ways to query:
| Mode | When to use | Command |
|---|---|---|
| CLI queries | Quick lookup outside an AI session | graphify path, graphify explain |
| AI-assisted | Complex questions during development | Prompt the agent with graph loaded |
The path command finds the shortest connection between two nodes in your graph:
graphify path "BaseTestCase" "execute_command"
This returns a chain of nodes and edges showing how those two entities connect — through imports, inheritance, or calls. Use it when you want to understand coupling between modules without reading intermediate files.
# Output example:
# BaseTestCase → (inherits) → UpdateTestCase → (calls) → execute_command
Node names must match what tree-sitter extracted. Use the graph visualization (graph.html) or GRAPH_REPORT.md to find exact names if you're unsure.
The explain command gives a plain-language description of a node and its immediate neighbors:
graphify explain "assertResult"
This shows what calls the node, what it calls, what it imports, and what community it belongs to. Think of it as a focused "tell me about this thing" without opening the source file.
When the graph is loaded in a Kiro CLI or Claude Code session, you can ask structural questions that the agent answers from the graph rather than grepping files:
framework.assertions?"test_min_comparisons.py?"The graph answers structural questions well. It cannot answer behavioral questions (what does this code actually do at runtime).
| Good (structural) | Bad (behavioral) |
|---|---|
"What calls execute_command?" | "What does execute_command return when the query fails?" |
"Show all test files using assertResult" | "Which assertions pass on DocumentDB but fail on MongoDB?" |
"What's the inheritance chain for UpdateTestCase?" | "How long does the test suite take to run?" |
The graph replaces discovery, not understanding. Once the agent knows which files matter (from the graph), it still reads those files to understand behavior. The savings come from not reading the other 400 files.
These prompt shapes get the most out of graph context:
# "Show me the shape" — asks for structure, not implementation
"What's the dependency graph around the test runner?"
# "Find similar" — leverages community clustering
"What other files are in the same community as test_min_comparisons.py?"
# "Trace the path" — follows edges
"How does a test case get from BaseTestCase to an actual MongoDB command?"
# "What's connected" — neighborhood exploration
"What are the 5 most-connected nodes in the graph?"
When should you use graphify path instead of asking the AI agent?
Which question type is the graph not good at answering?
graphify explain on the most important class in your projectgraphify path between two entities you know are related