Search code with the code graph
Este conteúdo não está disponível em sua língua ainda.
This guide shows you how to get a repo into the code graph and then use it to answer the question you actually have before a refactor: what depends on this?
The code graph is a symbol-and-edge database built by parsing your registered checkouts with tree-sitter. Its tools are agent-facing — you reach them by asking an agent.
Before you start
Section titled “Before you start”The graph indexes Dart, JavaScript, TypeScript, TSX, PHP, Python, Rust, Zig, C, C++, Go, Java, Ruby, C#, Swift, Kotlin, R, Assembly, MATLAB and Ada. Files in any other language are not parsed, so they do not appear in search_code, code_symbol, code_callers, code_callees or code_impact.
Two more things shape what gets indexed:
- In a git work tree, enumeration defers to
git ls-files --cached --others --exclude-standard, so every.gitignore, nested ignore file,.git/info/excludeand the global excludes file is honoured. That is what keepsnode_modulesand build output out of the graph. - Generated Dart is dropped regardless. Generated files are usually committed, so git alone would not exclude them and they churn on every codegen run.
Get a repo indexed
Section titled “Get a repo indexed”Registering a checkout fires RepoAdded, which starts the index_code pipeline for it automatically. See Add repos to a workspace.
To re-index by hand:
- Open Settings → Workspace → Repositories.
- Click the Index code button on the repo’s row.
- While it runs the button shows files done over total, with a cancel control. When it finishes it settles into a check with the symbol count.
The graph is partitioned by workspace, repo and checkout: the linked checkout is one partition, and each space worktree gets its own (keyed by its isolated-repo id).
Two throttles are worth knowing about, because they explain a wait that looks like a hang:
- The file watcher admits only one index run at a time on the host — a second checkout waits. The
index_codepipeline is separately capped at one run per workspace, so two repos in the same workspace queue; different workspaces can index in parallel. The indexer itself serializes two runs of the same checkout so a pipeline start and a watcher sweep cannot double-parse it. - Worktrees belonging to dormant spaces (no message in the last week) are neither watched nor indexed. Linked checkouts stay watched. A skip decision is re-checked after five minutes, so a space that becomes active again gets picked up.
Find a symbol
Section titled “Find a symbol”Ask an agent to search. The tool is search_code and it needs both a workspace and a repo:
search_code(workspace_id: "...", repo_id: "...", query: "authentication middleware")Repo ids come from list_repos. The optional mode argument is keyword, semantic or hybrid and it defaults to hybrid — BM25 over names, signatures and doc comments, fused with vector similarity.
Each result carries the symbol’s id, name, qualified name, kind, file path, start and end line and its signature when it has one. The id is the handle you feed to every other tool on this page.
When you know the exact name, look it up directly instead:
code_symbol(workspace_id: "...", repo_id: "...", name: "MyClass")Trace calls
Section titled “Trace calls”Both take a symbol_id from a search result, plus an optional limit (default 50):
code_callers(workspace_id: "...", symbol_id: "...")code_callees(workspace_id: "...", symbol_id: "...")code_callers returns the symbols with an incoming edge to this one; code_callees returns the ones it depends on.
Check what a change would break
Section titled “Check what a change would break”This is the tool the whole page exists for:
code_impact(workspace_id: "...", symbol_id: "...", depth: 3)It computes the reverse-dependency radius: everything that directly or transitively depends on the symbol along calls, extends and implements edges (imports, mixes-in and generic references are stored in the graph but are not walked here). depth is the maximum number of hops, between 1 and 6, defaulting to 2.
The result is three fields:
root— the symbol you asked aboutimpacted— the reachable set, including the root at depth 0, each carrying itsdepthfrom the rootedgeCount— how many edges the traversal crossed, as a count rather than the edges themselves
Run it before you rename or change a signature and give the agent the impacted list as its scope.
Results are checked against the caller’s own working copy
Section titled “Results are checked against the caller’s own working copy”For an agent caller, the space id is injected automatically and results are verified against that space’s working copy. A symbol whose file no longer exists in the caller’s tree is omitted and the response carries a staleOmitted count plus a note saying the index is stale for those symbols.
This is why you and an agent can get different answers to the same query and why an agent in one space can get a different answer from an agent in another. Every conversation in a space shares that one worktree. Verification fails open: a stale answer is preferred to an empty one.
Ask an agent to run code_impact (or review_studio.blastRadius) when you want the blast radius of a change. See Review compute.
Semantic search needs the embedding model
Section titled “Semantic search needs the embedding model”Symbols and facts are embedded at write time and only when the on-device embedding model is installed. Until then, mode: "semantic" and the semantic half of hybrid have nothing to match against and search is effectively keyword-only.
Install the model at Settings → Server → Diagnostics & privacy → Semantic search before you index. Symbols pick up a vector when their file is ingested.
Note also that any rebuild of the server binary re-stages the grammar dylibs and changes their mtimes, which invalidates every index checkpoint and forces one full re-walk of every checkout on the next run. It re-hashes, but it does not re-extract unchanged files.
What is in the graph
Section titled “What is in the graph”Symbol kinds: function, method, class, field, enum, constructor, getter, setter, typedef, extension, mixin, variable.
Edge kinds: calls, imports, extends, implements, mixes in, references.
The canonical signatures for these tools live in MCP tools.