IA al Día
the efficient way to stay informed
Tools June 8, 2026 news 3 min read

CodeGraph: The code graph that cuts your AI agent's token usage by 47%

CodeGraph builds a local knowledge graph of your codebase using Tree-sitter and serves it via MCP. Its verified benchmarks show 47% fewer tokens, 58% fewer tool calls, and 22% faster responses on architecture questions over real codebases.

By IA al Día

If you use AI agents like Claude Code, Cursor, or Codex CLI on large codebases, you know how fast tokens burn through. Every grep, every file read, every directory scan — it all costs. CodeGraph (github.com/colbymchenry/codegraph, 43k+ stars) attacks the problem at its root: instead of having the agent discover the code structure by exploring the filesystem, it delivers a pre-built knowledge graph.

How it works

CodeGraph parses your codebase with Tree-sitter and builds a local SQLite database containing the complete code structure: function definitions, classes, imports, dependencies, and file relationships. It then serves this information through the Model Context Protocol (MCP), the open standard for agent tooling.

Instead of the agent executing a dozen tool calls to answer “how does the caching system work?”, it asks CodeGraph directly, which returns the relevant fragments in a single call.

The real numbers (verified)

CodeGraph published detailed benchmarks across 7 real codebases, 7 languages, measuring 4 rounds per test with Claude Opus 4.8. The verified averages:

MetricImprovement
Tokens consumed47% fewer
Tool calls58% fewer
Cost16% cheaper
Response time22% faster

The savings are even more dramatic on large codebases:

CodebaseLanguageFilesToken reduction
VS CodeTypeScript~10,00064%
DjangoPython~3,00060%
OkHttpJava~64554%
AlamofireSwift~11064%
TokioRust~79038%
GinGo~11023%
ExcalidrawTypeScript~64025%

The logic is simple: larger codebases have more structure to discover, and the agent spends more tokens on discovery. CodeGraph eliminates that expense almost entirely.

100% local and no API keys

CodeGraph is completely local: the SQLite database lives on your machine, no data leaves, it doesn’t need external API keys, and there are no cloud services. It supports more than 20 languages via Tree-sitter (TypeScript, Python, Go, Rust, Java, C#, PHP, Ruby, C/C++, Swift, Kotlin, Dart, Lua, Svelte, and more).

It includes a native watcher (inotify on Linux, FSEvents on macOS, ReadDirectoryChangesW on Windows) that keeps the graph automatically synced as you code.

Compatibility

CodeGraph works as an MCP server, meaning it’s compatible with any agent that supports MCP: Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity IDE, and Kiro. Integration is simple: add the MCP server to your agent’s configuration and you’re done.

The honest caveat

CodeGraph’s benchmarks focus on architecture/understanding questions. For code generation tasks, bug fixing, or refactoring, the savings may differ. Also worth noting that results improve with codebase size — on small projects (<200 files), the improvement is modest and may not justify the setup.

That said, if you work on a medium or large codebase and your Claude/Cursor/Codex API bills hurt, CodeGraph will likely save you money from day one.