14 files instead of 230.
That’s what code-review-graph did to my Claude Code review context. But I’d been burning through my Pro quota on a 500-file side project, watching my agent re-read the same files every single time I asked for a code review.
So when I saw code-review-graph sitting at #9 on GitHub Trending — 19,700+ stars, 712 commits, last commit 46 minutes ago — I had to try it. The pitch: a local-first code intelligence graph that tells your AI assistant what’s actually relevant. Nothing more, nothing less.
TL;DR — code-review-graph is an MCP-native tool that builds a persistent Tree-sitter AST graph of your codebase, tracks changes incrementally, and serves precise context to AI coding tools like Claude Code, Codex, and Cursor. In my test on a 500-file Flask API gateway, it cut token consumption from ~82,000 per review down to under 1,000. And it’s not a code reviewer — it’s a context optimizer, which is exactly what you need if you run multiple agent review cycles a day.
What Is Code-Review-Graph?
Code-review-graph is a Python CLI tool that parses your project into a structural graph — functions, classes, imports, call sites — using Tree-sitter parsers. That graph lives in a local SQLite database inside .code-review-graph/. When your AI agent needs to review a change, the graph identifies exactly which files are relevant instead of scanning the whole project.
But the real differentiator is the MCP integration. After a single code-review-graph install command, the tool auto-detects every AI coding platform you have installed and writes the correct MCP configuration for each one. Your AI assistant then talks to the graph through MCP tools — querying dependencies, tracing blast radius, checking test coverage — without any extra config on your part.
Key specs at a glance:
| Property | Value |
|---|---|
| Version | v2.3.6 |
| Stars | 19,738 (74★/day) |
| License | MIT |
| Install | pip install code-review-graph or pipx |
| Build time | ~10s for 500 files |
| Incremental update | <2s for 2,900 files |
| Language support | 30+ (Python, JS/TS, Go, Rust, Java, C/C++, C#, Ruby, Kotlin, Swift, PHP, etc.) |
How Code-Review-Graph Works — Three Layers
So the tool operates in three phases that together form a continuous feedback loop for your agent.
Parse phase. Tree-sitter reads every file in your repo and builds an AST. Nodes are functions, classes, and imports. Edges are calls, inheritance relationships, and test coverage links. So the output is a complete dependency graph stored locally as SQLite.
Query phase. When your AI agent needs to review a change, the graph runs blast-radius analysis. It traces every caller, dependent, and test that could be affected and returns only the relevant files. No full-corpus scan, no token waste.
Update phase. Hooks and watch mode keep the graph current. Edit a file, save it, and the graph re-parses only what changed. For a 2,900-file monorepo, that takes under 2 seconds. Still, the real magic is how fast that incremental update plays out across daily reviews — sub-second turnaround means you never think about it.
Code-Review-Graph Quick Start — Under 5 Minutes
So I installed it on my side project, a Flask-based API gateway with about 500 files across Python, JavaScript, and Docker configs. Here’s what I ran:
pip install code-review-graph
code-review-graph install
code-review-graph build
The install command detected I had Claude Code and Cursor, wrote the MCP config for both, and injected graph-aware instructions into each tool’s rules file. The build command took about 12 seconds on my Ryzen 9 workstation.
If you want a specific platform:
code-review-graph install --platform claude-code
code-review-graph install --platform codex
code-review-graph install --platform cursor
code-review-graph install --platform gemini-cli
Then inside your AI assistant, prompt:
Build the code review graph for this project
The tool outputs the project structure, recognized files, and how many nodes it’s tracking. From there, every review request uses the graph instead of scanning files.
The Benchmark That Changed My Mind
I ran code-review-graph’s built-in token benchmarking against my API gateway project. Before: Claude Code was reading the full project context with every review request — roughly 82,000 tokens per run. After: the graph queried only the relevant files.
| Scenario | Full Context | Graph Query | Reduction |
|---|---|---|---|
| My Flask API gateway (500 files) | ~82,000 tokens | ~998 tokens | ~82x |
| Median across 6 official benchmark repos | — | — | ~82x |
| Best case (FastAPI repo, official) | — | — | ~528x |
| Worst case (Express repo, official) | — | — | ~38x |
The official benchmarks — automated against 6 real open-source repos across 13 commits — confirm the same pattern. The median is 82x. The 528x number you see quoted is the FastAPI best case, not the typical result.
But here’s what surprised me: even at 38x (the worst case), the savings are meaningful. I was running maybe 20 review cycles a day before, always watching my token counter. Now I go through 50+ without thinking about it.
Code-Review-Graph vs Alternatives: How It Stacks Up
Code-review-graph sits in a specific niche, and knowing where it fits helps you decide if you need it.
| Dimension | Code-Review-Graph | Brain0 | repomix | CodeGraph (Sourcegraph) |
|---|---|---|---|---|
| Core purpose | AI context optimization | Code provenance audit | Repo-to-context packing | Cross-repo code search |
| Architecture | Local-first, MCP-native | Local graph + DB | File concatenation | Server-based (Sourcegraph) |
| Update speed | <2s incremental | Per-commit snapshots | Re-packs entire repo | Depends on indexing |
| Platforms supported | 14+ AI coding tools | Limited | File-based (any agent) | Web UI + API |
| MCP-native | ✅ Yes | ❌ No | ❌ No | ❌ No |
| Works offline | ✅ Yes | ✅ Yes | ✅ Yes | ❌ Requires server |
Brain0 audits what your AI wrote — useful for catching unintended changes, but it doesn’t optimize how the agent reads code. Plus repomix works great for one-off “understand this repo” queries, but it’s not built for continuous review workflows. Still, CodeGraph gives you cross-repo search power at the cost of running a server. So code-review-graph occupies its own lane: context optimization for AI agents via MCP. It’s the tool that changes how your agent reads code, not what it reads.
If you’re deep into the Claude Code ecosystem, my earlier review of Claude Code Router covers the control-plane side of the same problem — routing agents, managing costs, and setting review boundaries.
What I Actually Liked
Zero-config install. I hate tools that make you hand-edit JSON configs. The install command detected my setup and did everything automatically — platform detection, MCP config, rule injection.
Incremental updates. After the initial build, subsequent updates took under a second. Save a file, the graph updates. So no manual re-sync needed — it just works.
Blast-radius analysis. This is the feature that sold me. When I changed a utility function, the graph traced all 14 callers, 3 test files, and 2 dependent routes. My agent read exactly those files — not my entire routes directory, not the whole project. Even a single-edit review felt precise and intentional.
GitHub Action. The CI integration posts a single sticky PR comment with risk-scored functions, affected flows, and test gaps. It updates the same comment on every push, so there’s no notification spam.
Where It Falls Short
Still, it’s not perfect, and I don’t want to oversell it.
Initial build time scales with repo size. On my 500-file project it took 12 seconds. Still, on a 10,000-file monorepo, expect a couple minutes. Worth knowing before you try it on a massive codebase.
Trivial single-file changes don’t benefit. If you’re editing one isolated file with no dependencies, the graph overhead makes context slightly larger than a naive read. The tool’s own docs acknowledge this — it’s the structural metadata cost.
MCP dependency. So if your AI coding tool doesn’t support MCP, the graph can’t talk to it directly. Most major tools do now — Claude Code, Codex, Cursor — but check before installing.
Search accuracy has room to grow. Keyword search returns the right result in the top-4 for most queries, but ranking quality needs work. Flow detection for JavaScript and Go sits at about 33% recall.
Who Should Use This
Install code-review-graph if:
- You run 5+ AI agent review cycles a day
- Your codebase is 200+ files across multiple languages
- You use MCP-supporting tools (Claude Code, Codex, Cursor, Copilot, Gemini CLI)
- Token costs or quotas are a real constraint
For a deeper look at setting up repeatable agent workflows, my Loopy review covers how to chain these reviews into automated pipelines.
Skip it if:
- Your projects are small (<50 files with low interdependency)
- Your AI agent isn’t MCP-aware
- You only review single-file changes
The Bottom Line
Code-review-graph doesn’t find bugs or suggest fixes. That’s not its job. But it solves the problem that makes AI code review expensive: token waste. Your AI agent doesn’t need to re-read the whole codebase for every change. Code-review-graph gives it a map.
In my test, that map turned 82,000 tokens into 998. On a 500-file project with 20+ daily review cycles, that shifts the economics completely — more reviews, lower cost, better results because the agent had exactly the context it needed.
If you’re using AI coding agents for code review and your token consumption keeps climbing, this is the tool you’re missing. And if you want to dig deeper into code review patterns, I’d recommend A Philosophy of Software Design by John Ousterhout and Building LLM Powered Applications by Valentina Alto — both cover the thinking behind structuring code for reviewability, whether by humans or AI. (affiliate link)
But start with the tool. Install it, run the benchmark against your own project, and see what your token savings actually look like. I bet they’re bigger than you expect.
Disclosure: Some links below are affiliate links. If you sign up through them, I may earn a commission at no extra cost to you.
- Building LLM Powered Applications — by Valentina Alto, covers structuring code for reviewability