What is a code knowledge graph? (And why it beats grep for AI agents)
A code knowledge graph is a knowledge graph built from a codebase. Functions, classes, config, and docs are nodes. Calls, imports, and references are typed edges between them. An assistant follows those edges to see how the pieces connect, instead of searching the repo as flat text.
What is a code graph?
A code graph is a map of a codebase built by parsing the source. Functions, classes, files and modules become nodes. Calls, imports and references become typed edges between them. An AI coding agent follows those edges to answer structural questions, such as what calls a function or what a change reaches, and each hop points to a file and line. It is also called a code knowledge graph.
For how a code graph is built, how it compares with grep and with embeddings, and how agents use one over MCP, read What is a code graph?.
Most code graphs come from a parser, not a model. Graphify reads each file's syntax tree with tree-sitter, so a call or import edge exists because the parser found it, and every edge carries a tag saying how it was found. The Code graph glossary entry has the longer definition.
How do AI coding agents use a code graph over MCP?
An agent reaches a code graph through an MCP server, which exposes the graph as tools the agent can call in the middle of a task. It asks for the callers of a function, the path between two symbols or the code a change touches, and gets back nodes and edges with a file and line instead of a page of search results.
On hosted Graphify those tools include graphify_callers, graphify_trace and graphify_impact. The Graphify MCP server page lists the rest and the setup for each agent.
Where does Graphify fit?
Graphify builds the code graph from your repository and puts shared codebase context on top of it: a Wiki generated from the graph, Memory that ties what your agents learn to the code it is about, and PR reviews that show what a change affects. Agents connect to the hosted MCP server at https://api.graphify.com/mcp, and a push to the default branch starts an incremental rebuild.
Start free at app.graphify.com. To build the graph on your own machine instead, install open-source Graphify with uv tool install --python 3.12 graphifyy, as shown below.
Where does a code knowledge graph beat grep?
A call can exist when the names do not match. A file can import charge as take_payment and then call take_payment(). Grep for charge finds the import. It does not find the call, because the call is named take_payment. The import edge still connects that call to charge. Tree-sitter read the alias in the syntax tree.
Grep returns the lines that contain a string. A Code graph stores the relationship itself, a call or an import with a direction and a type. Knowledge graph is the name for entities and the typed relationships between them.
What calls this handler is a walk backward along call edges. A string search returns every line that mentions the handler, comments included. The call edges are the callers. A structural question, such as "what breaks if this changes," traces to a path through files. You can open those files and check the answer.
When is grep still the right tool?
Grep is the right tool when the question is really "find this string." A misspelled word in a comment, or a URL in a config file, is a string to find. The graph holds nodes and edges. A string that never became a node or an edge is still a search, and grep is how you run it.
How does an agent follow a path across files?
graphify path "webhook" "database" walks the edges between those two nodes. A path from the webhook to the database takes more than one hop. It can run from the handler, through the function that handler calls, to the table that function writes. Each hop is one typed edge. The agent starts at one node, follows the edges, and answers from the chain. Each node on the chain names a file.
You can check an edge before you trust the hop. Every edge is tagged. EXTRACTED means the syntax tree produced it. INFERRED means the model proposed it. AMBIGUOUS means the evidence did not resolve, as with dynamic dispatch or an import built from a string. An AMBIGUOUS edge stays in the graph and keeps the tag. How Graphify works explains the tags.
The comparison with retrieval over similar passages is Code knowledge graph vs RAG.
How do you build one?
Code is parsed locally across about 40 languages, mostly with tree-sitter. Call and import edges come from the syntax tree. That pass does not call a model. Docs and other non-code files can be folded in by the model you already use. Those connections are tagged INFERRED.
In the project, /graphify . writes three files under graphify-out/:
graph.html: a map you can open in a browserGRAPH_REPORT.md: a written briefgraph.json: the raw structure
You can run the queries from the shell.
graphify query "what calls this handler"
graphify path "webhook" "database"
graphify explain "APIRouter"graphify query answers over the structure. graphify path traces how two nodes connect. graphify explain walks why a node matters.
When the code changes, graphify update . re-extracts the changed files. Inside the assistant, /graphify . --update re-scans what changed. You run the refresh. Until then, the files in graphify-out/ stay as they were written.
There is no telemetry.
Graphify is open source, Apache 2.0. Graphify Cloud is the hosted map, and it is a different product from this on-device setup.
Install
The package on PyPI is graphifyy (two y's).
uv tool install --python 3.12 graphifyypipx install graphifyy also works. If the graphify command is missing after uv, run uv tool update-shell and open a new terminal.
Then, in the project:
/graphify .First graph: docs.graphify.com/guides/first-graph.
Sign in at Graphify Cloud and connect a repository to open the hosted map. The install steps above are the on-device path.
FAQ
What is a code knowledge graph?
A code knowledge graph is a knowledge graph built from a codebase. Functions, classes, config, and docs are nodes. Calls, imports, and references are typed edges between them. An assistant follows those edges to see how the pieces connect, instead of searching the repo as flat text.
What is a code graph?
A code graph is a map of a codebase built by parsing the source. Functions, classes, files and modules become nodes. Calls, imports and references become typed edges between them. An AI coding agent follows those edges to answer structural questions, such as what calls a function or what a change reaches, and each hop points to a file and line. It is also called a code knowledge graph.
How is a code knowledge graph different from grep?
Grep returns the lines that contain a string. A code graph stores the relationship itself, a call or an import with a direction and a type. A call can exist when the names do not match. Grep for the original name finds the import and misses the call. The import edge still connects them.
When should an agent still use grep?
Grep is the right tool when the question is really a search for a string. A misspelled word in a comment, or a URL in a config file, is a string to find. A string that never became a node or an edge is still a search, and grep is how you run it.
How do you build one with Graphify?
In the project, /graphify . writes three files under graphify-out/: graph.html, GRAPH_REPORT.md, and graph.json. The package on PyPI is graphifyy. Sign in at Graphify Cloud and connect a repository to open the hosted map. The install steps above are the on-device path.
Use Graphify in your agent
Add Graphify to ChatGPT, Claude, Cursor and more in one click.