CodeGraph: The Local Memory Layer That Lets AI Agents Stop Re-reading Your Codebase

A deep look at the SQLite graph, detached daemon, and blast-radius engine that turn code exploration into a reusable system instead of a token leak.

8 min read • View on GitHub • More from colbymchenry

A wide black-ink editorial scene shows an AI agent walking the same maze of file corridors with a flashlight and a stack of tokens, while a compact local graph hub routes direct paths into a terminal beside it. The image explains how CodeGraph replaces repeated repo scavenging with persistent structural memory.
CodeGraph turns repeated discovery into a local lookup problem instead of a fresh search problem every session.

CodeGraph gives Claude Code a pre-built understanding of your code instead of making it explore from scratch every session

Key Takeaways

AI coding agents have a predictable failure mode. They rediscover the same repo every time, burn tokens on the same file reads, and act like they have no memory. CodeGraph is interesting because it does not try to fix that with better phrasing. It changes the substrate.

CodeGraph is a local-first MCP server that pre-indexes a codebase into a SQLite-backed knowledge graph. The point is simple: let an agent ask for structure, not re-learn it from scratch.

The agent problem CodeGraph is actually solving

The cost of naive exploration is not only latency. It is repetition. A coding agent starts with almost nothing, then reconstructs the same understanding by grepping, reading, and cross-checking file after file. That is a discovery tax, and it hits twice: once in token spend, once in attention.

CodeGraph treats that tax as a systems problem. If the codebase can be parsed once into symbols, references, and dependencies, then future sessions can query the result instead of replaying the search.

A WSJ hedcut-style portrait of Colby McHenry based on his verified GitHub avatar. The portrait identifies the creator behind CodeGraph and anchors the project’s origin story in a real maintainer.

Why persistence beats prompting

The conceptual leap is not subtle. CodeGraph does not try to make the model smarter in the moment. It makes the codebase legible ahead of time, so the next session starts with durable context instead of amnesia.

Blast radius is the useful mental model here. The graph is not only telling you where something lives. It is telling you what else you should inspect before you touch it.

That matters because agents are not just search tools. They are decision systems. When the environment tells them what is connected to what, they can spend fewer tokens rediscovering the shape of the code and more tokens changing it.

How CodeGraph builds a local code graph

Under the hood, the pipeline is straightforward in the best way. Tree-sitter parses source into syntax trees. Symbol extraction turns those trees into definitions and references. Resolution links those references across files. SQLite stores the result locally, where it can be queried fast and reused often.

// Conceptual flow
const graph = await CodeGraph.open({ root: repoPath });
await graph.index();

const context = await graph.contextBuilder
  .forSymbol('UserService.createUser')
  .includeBlastRadius()
  .build();

console.log(context.definitions);
console.log(context.callers);
console.log(context.affectedFiles);

The interesting part is not the parsing itself. It is what the parsing enables. Once the repository is represented as a graph, the system can answer questions like: where is this symbol defined, who calls it, and what else should be checked if it changes?

A close-up precision diagram shows a Tree-sitter parser feeding symbols into a SQLite vault, then a blast-radius lens projecting dependency arcs onto nearby files. The image explains how CodeGraph converts raw source into reusable context and impact analysis.
The value chain is short: parse, resolve, store, query. That is what makes the system repeatable.

The part that makes it feel production-grade

This is where CodeGraph stops feeling like a clever indexer and starts feeling like infrastructure. The detached daemon keeps the shared state alive. The proxy lets fresh agent sessions connect without paying the cold-start cost every time. The mutexes and file locks keep concurrent indexing from trampling the database.

LayerWhat it solvesWhy it matters
Detached daemonAvoids starting a full server for every sessionCuts cold-start overhead and keeps the graph hot
Proxy bridgeConnects short-lived agent sessions to shared statePreserves a simple stdio experience for clients
Mutex and file lockPrevents concurrent corruption during indexingMakes SQLite viable under real agent churn
PPID watchdogKills orphaned processes when the parent IDE diesStops zombie servers from lingering after crashes

That operational hardening is the product. If the tool only worked in ideal conditions, agents would abandon it quickly. CodeGraph’s reliability choices are what make the graph feel like a shared memory layer instead of a demo.

Your AI coding agent has a dirty secret: It doesn't understand your codebase. It greps it. Over and over. Burning your tokens on every search. Watch Claude Code on a big repo — it spawns Explore agents that grep, glob, and Read files in loops just to figure out what calls what.

Shruti Tiwari, HeyShruti7 · @HeyShruti7 on X

Blast radius is the killer feature

The most useful move in CodeGraph is not answering where a function lives. It is telling you what might break if you move it. That is a different kind of question, and it is closer to how real engineering decisions happen.

Blast radius takes the graph from passive index to decision support. The agent can expand from a symbol to callers, dependent functions, and affected files before making a change. That is especially valuable during refactors, where the cost of missing one dependency can be higher than the cost of a few extra queries.

CodeGraph versus the old way

ApproachSetup frictionPersistenceToken efficiencyPrivacyImpact analysis
Manual grep and readingNoneNoneLowLocalWeak
Cloud semantic retrievalModerateShared, not localBetterDepends on serviceVariable
Plain MCP server without daemonizationLow at firstOften per sessionBetter than grepLocalBasic
CodeGraphModerate once, then reusablePersistent across sessionsHighLocal-firstStrong

The tradeoff is clear. Grep is cheap to start and expensive to repeat. Cloud retrieval can be powerful, but it pushes context out of the machine. CodeGraph sits in the middle with a local, persistent graph that agents can keep using.

What this says about agent tooling

CodeGraph points to a bigger shift in AI tooling. The winning abstraction may not be endless retrieval from scratch. It may be durable local memory that sits close to the code, survives across sessions, and does the boring infrastructural work that makes agents reliable.

That is why the project is more than a search tool. It is a small operating system for agent context. And in a world where every session is tempted to start over, that is a real product insight.