An open-source tool called CodeGraph is tackling one of Claude Code's most expensive habits: re-reading your entire codebase every time you ask it to do something.
The problem is straightforward. When you ask Claude Code to review a commit or add a feature, it uses Explore agents that scan files with grep, glob, and read operations to understand your project. On a small repo, that is fine. On a FastAPI project with 2,915 files or a Next.js codebase with 27,732 files, it reads thousands of files that have nothing to do with your change. You pay for every token of that wasted context, and the extra noise actually makes the output worse.
How It Works
CodeGraph, built by developer Colby McHenry, uses tree-sitter (a fast code parser) to build a persistent semantic graph of your codebase stored in a local SQLite database. It maps every function, class, import, and call relationship. When Claude Code needs to understand your project, it queries this pre-built index through MCP (Model Context Protocol) instead of scanning raw files.
The tool supports 19 languages including TypeScript, Python, Go, Rust, Java, and C#. It runs entirely locally with no API keys or external services. Claude Code hooks keep the index automatically synced as you work.
Eight MCP tools give Claude Code structured access: search by meaning (not just text matching), trace callers and callees of any function, analyze the impact radius of a change, and build focused context for specific tasks.
The Numbers
Benchmarks from running the same complex task three times with and without CodeGraph:
- Explore agent tokens: 157.8k dropped to 111.7k (29% reduction)
- Per-agent tokens: 74.0k dropped to 46.4k (37% reduction)
- Tool calls: 60 dropped to 45 (25% fewer)
- Main context usage: 28.7% to 24.0%
Those savings compound quickly. If you are running Claude Code on a large project and spending $50-100/day on API costs, a 30% reduction is real money.
Installation is a single npx @colbymchenry/codegraph command that configures everything, including MCP server setup and Claude Code hooks. The project has 243 stars on GitHub and is MIT licensed.