- AI Engineering
- Posts
- Turn Your Codebase Into a Queryable Knowledge Graph
Turn Your Codebase Into a Queryable Knowledge Graph
... PLUS: Give AI Agents Clean Context From Any Document
In today’s newsletter:
Give AI Agents Clean Context From Any Document
Turn Your Codebase Into a Queryable Knowledge Graph
Reading time: 5 minutes.
Your document agent does not see the PDF you upload. It sees the parser’s version of that PDF.
On a page with columns, charts, or tables, position carries meaning. A text extractor can return the words and numbers while losing the reading order or the labels attached to each value.
LlamaParse uses layout-aware parsing to carry reading order and table structure into the output your agent receives. That gives the agent a better chance of finding the right evidence when it answers a question.
What the Agent Actually Receives
LlamaParse converts the uploaded document into Markdown, text, or JSON. In Markdown output, headings mark sections, tables keep their rows and columns, and text follows the page’s reading order.
For an AI agent, that output becomes searchable content. Retrieval returns relevant passages, and the model reads them when it answers.
The Error Travels Through the Pipeline
The parsed output becomes the input to chunking, embedding, and retrieval. If a year label has been separated from its figures, the index stores that separation too. Retrieval may find the right page, but the agent still lacks enough context to choose the right number.
For document-heavy agents, parsing quality is part of answer quality. It is worth checking before spending time tuning retrieval or changing models.
Test LlamaParse on Your Documents
Before wiring a new parser into your agent, you need to see what it returns for the documents your agent will process. In LlamaParse’s Parse playground, you can upload a document and inspect the result without changing your existing pipeline.
LlamaIndex is offering new accounts $250 in LlamaParse credits if they sign up by September 30. No purchase is required.
Pro remains a paid plan. If you upgrade within 30 days of sign-up, or sooner if your credits run out, use code SUMMERGIFT26 to get 50% off for the first three months.
Turn Your Codebase Into a Queryable Knowledge Graph
A coding agent starts every unfamiliar repository with the same problem. It has files but no map of how those files work together.
The agent searches for names, opens likely matches, follows imports, and repeats the process until it understands enough of the codebase to begin working. On a large repository, that investigation can consume more context than the change itself.
Graphify gives the agent a different starting point. It converts the codebase and its supporting documents into a local knowledge graph that both developers and coding agents can query.
Text Search Finds Names
Suppose you ask an agent to change how authentication errors reach the API response.
A text search can find files containing AuthenticationError. The search cannot directly explain which handler catches the exception, which route calls that handler, or which tests depend on the response.
The agent has to reconstruct those relationships by opening files one at a time.
A knowledge graph stores the relationships directly. Functions, classes, methods, files, and documentation become nodes. Imports, calls, inheritance, and references become edges connecting those nodes.
That lets an agent ask structural questions instead of guessing which search result matters.
Graphify Maps the Repository
Graphify parses code locally with tree-sitter. The parser reads the abstract syntax tree and resolves relationships across roughly 40 programming languages without sending the source code to an LLM.
The resulting graph can connect:
Code to code: functions, classes, calls, imports, and inheritance.
Code to documentation: comments, docstrings, ADRs, and RFCs.
Code to data: SQL schemas and configuration files.
Project concepts: related nodes grouped into architectural communities.
Graphify can also process PDFs and other media through a configured model. That semantic step is separate from the deterministic code parser, so teams can decide whether non-code files should be processed locally or through an external provider.
Every Connection Shows Its Origin
Generated knowledge graphs become difficult to trust when you cannot tell why two nodes were connected.
Graphify labels graph edges according to how each relationship was created:
EXTRACTEDmeans the relationship appears directly in the source.INFERREDmeans Graphify resolved the relationship from available evidence.AMBIGUOUSmeans the relationship could not be determined confidently.
Each node also points back to the relevant file and source location.
An agent can therefore use the graph to narrow its search and return to the source code when a relationship needs verification. The graph guides repository exploration without replacing the code as the final authority.
Build the Graph
Install Graphify and register its skill with your coding assistant:
uv tool install graphifyy
graphify installThen run Graphify from the root of the project:
/graphify . PowerShell users should run graphify . without the leading slash.
Graphify creates three outputs:
graphify-out/
├── graph.html
├── GRAPH_REPORT.md
└── graph.jsongraph.html provides an interactive view of the repository. GRAPH_REPORT.md summarizes the main concepts and connections. graph.json contains the complete graph for future queries.
The graph is built once and can be queried without asking the agent to reread the entire repository.
Ask Structural Questions
You can inspect one concept and its connections:
graphify explain "APIRouter"You can trace how two parts of the system connect:
graphify path "FastAPI" "ModelField"Or ask a broader question:
graphify query "How does request validation reach the API response?"Graphify returns a focused subgraph instead of a long list of matching lines. The agent sees the relevant nodes, relationships, and source locations before opening individual files.
That changes repository exploration from repeated search into targeted verification.
The Graph Becomes Part of the Agent Harness
Building the graph is only useful if the coding agent remembers to consult it.
Graphify can add persistent instructions to Claude Code, Codex, Cursor, Gemini CLI, and other coding assistants. Those instructions tell the agent to query the graph before searching through source files manually.
The agent can then use the graph during familiar development tasks:
Find every implementation of an interface before changing its contract.
Trace a database field from its schema to the API response.
Identify modules connected to a shared dependency.
Locate the code and documentation behind an architectural decision.
Estimate which parts of the system a proposed change may affect.
The graph reduces exploration work, but it does not prove that a code change is safe. Tests, type checks, and human review still determine whether the implementation behaves correctly.
A repository graph also becomes stale when the code changes. Teams should rebuild it after meaningful changes or install the supplied Git hooks to keep the map current.
Text search remains useful when you already know the exact symbol or string. Graph queries become more valuable when the question is about relationships across files.
That is the real advantage of giving a coding agent a repository map. The agent spends less time discovering where the work belongs and more time verifying the change in the source code.
That’s all for today. Thank you for reading today’s edition. See you in the next issue with more AI Engineering insights.
PS: We curate this AI Engineering content for free, and your support means everything. If you find value in what you read, consider sharing it with a friend or two.
Your feedback is valuable: If there’s a topic you’re stuck on or curious about, reply to this email. We’re building this for you, and your feedback helps shape what we send.
WORK WITH US
Looking to promote your company, product, or service to 200K+ AI developers? Get in touch today by replying to this email.

