Code-Review-Graph: The Open-Source Tool That Cuts AI Code Review Tokens by 82x — 23,681 GitHub Stars
Code-Review-Graph builds a persistent intelligence graph of your codebase using Tree-sitter and MCP, achieving up to 82x median token reduction on AI-powered code reviews. With 23,681 GitHub stars and support for 35+ languages, it's transforming how developers use AI coding assistants.
pip install code-review-graph, run one command, and it auto-configures for Cursor, Claude Code, Copilot, Codex, and more.
If you've ever watched your AI coding assistant chew through hundreds of thousands of tokens just to review a small pull request, you already feel the pain that code-review-graph was built to solve.
The open-source project — which has exploded to 23,681 GitHub stars and 2,297 forks since its launch in early 2026 — takes a fundamentally different approach to AI-powered code review. Instead of feeding your entire codebase to an LLM, it builds a structural map of your code and tells your AI exactly which files matter for any given change.
The result? A median 82x reduction in tokens consumed per review question, with benchmarks showing up to 528x savings on large repos like FastAPI. For teams paying per-token on GPT-4, Claude, or Gemini, that's not just an optimization — it's a budget revolution.
What Is Code-Review-Graph and Why Does It Matter?
Code-review-graph is a local-first code intelligence graph that parses your codebase into an Abstract Syntax Tree (AST) using Tree-sitter, stores it as a graph of nodes (functions, classes, imports) and edges (calls, inheritance, test coverage), then queries that graph at review time to compute the minimal set of files your AI assistant needs to read.
Think of it as a GPS for your AI coding tools. Instead of wandering through every street in a city, it calculates the exact route to your destination.
The tool integrates seamlessly with the Model Context Protocol (MCP), the emerging standard for connecting AI assistants to external tools. One install command auto-detects and configures support for:
- Cursor — The AI-first code editor
- Claude Code — Anthropic's CLI coding agent
- GitHub Copilot — Both VS Code and CLI versions
- Codex — OpenAI's coding agent
- Gemini CLI — Google's terminal-based coding assistant
- Kiro — AWS's AI IDE
- CodeBuddy — Tencent's coding agent
# Install in three commands
pip install code-review-graph
code-review-graph install # auto-detects all your AI tools
code-review-graph build # parse your codebase
How the Blast Radius Analysis Works
The core innovation of code-review-graph is what its creator calls "blast radius" analysis. When a file changes in your codebase, the graph traces every caller, dependent, and test that could be affected. Your AI then reads only these files instead of scanning the whole project.
Here's a real-world example. Imagine you modify a utility function called validateUser() in a 500-file project. Without code-review-graph, your AI assistant might need to process the entire codebase (~125,000 tokens for a medium project) to understand the impact. With the graph, it identifies:
{
"changed_files": ["src/utils/validation.ts"],
"affected_functions": [
"src/auth/login.ts → authenticateUser()",
"src/auth/register.ts → registerUser()",
"src/api/middleware.ts → authMiddleware()",
"src/tests/auth.test.ts → 4 test cases"
],
"total_affected_files": 4,
"tokens_needed": 2169,
"tokens_saved": "98.3%"
}
The graph computed that only 4 files are in the blast radius — reducing context from ~125,000 tokens to just ~2,169 tokens. That's a 57x reduction for a single function change.
Benchmark Results: The Numbers That Matter
The project ships with a rigorous benchmarking suite tested against 6 real open-source repositories (13 commits total). Every configuration pins an upstream SHA, and results are fully reproducible.
| Repository | Corpus Tokens | Graph Query Tokens | Reduction |
|---|---|---|---|
| FastAPI | 951,071 | 2,169 | 528.4x |
| code-review-graph | 208,821 | 2,495 | 93.0x |
| Gin (Go) | 166,868 | 1,990 | 91.8x |
| Flask | 125,022 | 1,986 | 71.4x |
| Express.js | 135,955 | 3,465 | 40.6x |
| HTTPX | 89,492 | 2,438 | 38.0x |
The median reduction is 82x across all repos. The frequently cited 528x number is the maximum (FastAPI, the largest corpus) — not the typical result. The project is transparent about this, which is refreshing in the AI tooling space.
Build performance is equally impressive:
- Express.js (141 files): 106ms build, 0.7ms search
- FastAPI (1,122 files): 128ms build, 1.5ms search
- Flask (83 files): 95ms build, 0.7ms search
Incremental updates — where only changed files are re-parsed — complete in under 2 seconds even for a 2,900-file project.
Real-World Example: Using Code-Review-Graph in a CI/CD Pipeline
Here's how you'd integrate code-review-graph into a GitHub Actions workflow for automated PR reviews:
# .github/workflows/code-review-graph.yml
on:
pull_request:
permissions:
contents: read
pull-requests: write
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: tirth8205/code-review-graph@v2.3.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
On each pull request, the action posts a sticky comment with risk-scored functions, affected execution flows, and test gaps — updated in place on every push. An optional fail-on-risk input turns the review into a merge gate, blocking PRs that touch high-risk areas without adequate test coverage.
For local development, the workflow is even simpler:
# Start watch mode — graph updates on every file save
code-review-graph watch
# Then ask your AI assistant (via MCP):
# "Review the changes I just made"
# "What's the blast radius of my latest commit?"
# "Which tests should I run for this PR?"
Language Support: 35+ Languages and Counting
Code-review-graph supports an impressive range of languages out of the box:
- Web: JavaScript, TypeScript, TSX, Vue, Svelte, Astro
- Systems: Rust, C, C++, Go, Zig
- Backend: Python, Java, Kotlin, C#, VB.NET, Ruby, PHP, Scala, Elixir
- Mobile: Swift, Dart, Kotlin
- Specialized: Solidity, GDScript, Verilog/SystemVerilog, SQL, Terraform
- Scripting: Shell scripts, PowerShell, Lua/Luau, Perl, R, Julia
- Notebooks: Jupyter/Databricks (.ipynb)
If your language isn't covered, you can add it via a languages.toml file — no fork or code changes needed:
# .code-review-graph/languages.toml
[languages.erlang]
extensions = [".erl"]
grammar = "erlang"
function_node_types = ["function_clause"]
class_node_types = ["record_decl"]
import_node_types = ["import_attribute"]
call_node_types = ["call"]
PHP projects get special treatment with repository-bounded Composer PSR-4 resolution, Blade template references, and Laravel Route/Eloquent semantic edges.
Key Benefits of Code-Review-Graph
- Massive token savings — 82x median reduction means lower API costs and faster AI responses
- Local-first architecture — Your code never leaves your machine. The graph is stored in a local SQLite file.
- Incremental updates — Only changed files are re-parsed, keeping the graph current in seconds
- Multi-platform support — One install configures Cursor, Claude Code, Copilot, Codex, Kiro, and more
- CI/CD integration — GitHub Action provides automated risk-scored PR reviews
- 35+ language support — From Python to Solidity, with custom language configuration
- Community detection — Leiden algorithm clusters related code for architecture insights
- Knowledge gap analysis — Identifies isolated nodes, untested hotspots, and structural weaknesses
- MIT licensed — Fully open source with an active community of 2,297+ forks
Beyond Code Review: Architecture Insights
While the name says "code review," the tool is really a code intelligence platform. The graph enables several powerful analyses beyond PR reviews:
Hub & Bridge Detection: Using betweenness centrality, the tool identifies architectural chokepoints — functions that connect otherwise disconnected parts of your codebase. These are your highest-risk refactoring targets.
Surprise Scoring: Detects unexpected coupling between modules — cross-community, cross-language, or peripheral-to-hub edges that might indicate hidden dependencies.
Execution Flow Tracing: Trace call chains from entry points, sorted by weighted criticality. Perfect for understanding how a request flows through your application.
Interactive Visualization: Generate D3.js force-directed graphs with search, community legend toggles, and degree-scaled nodes. Export as HTML, GraphML (for Gephi/yEd), Neo4j Cypher, or even an Obsidian vault with wikilinks.
# Generate interactive visualization
code-review-graph visualize
# Export for Neo4j
code-review-graph visualize --format cypher
# Export as Obsidian vault
code-review-graph visualize --format obsidian
Getting Started: A Complete Walkthrough
Here's a step-by-step guide to integrating code-review-graph into your workflow:
Step 1: Install
pip install code-review-graph
# Or with pipx for isolation:
pipx install code-review-graph
Step 2: Configure for your AI tools
code-review-graph install
# This auto-detects Cursor, Claude Code, Copilot, etc.
# and writes the correct MCP configuration for each.
Step 3: Build the graph
cd your-project/
code-review-graph build
# Initial build: ~10 seconds for 500 files
Step 4: Start using
# Enable watch mode for automatic updates
code-review-graph watch
# Now ask your AI assistant:
# "Build the code review graph for this project"
# "Review my latest changes"
# "What functions are affected by modifying auth.ts?"
Frequently Asked Questions
1. Is code-review-graph free to use?
Yes, code-review-graph is completely free and open source under the MIT license. You can install it via pip (pip install code-review-graph) and use it in both personal and commercial projects without any cost. The tool itself is free; you still pay for whatever AI model you use (GPT-4, Claude, etc.), but the token savings significantly reduce those costs.
2. Does code-review-graph send my code to external servers?
No. Code-review-graph is fully local-first. Your codebase is parsed and stored locally in a SQLite file at .code-review-graph/ in your project directory. No source code is ever sent to external services. The graph is queried locally, and only the minimal context needed is passed to your AI assistant via MCP.
3. How does code-review-graph compare to GitHub Copilot's built-in context?
GitHub Copilot uses heuristics like open tabs, recent files, and symbol matching to gather context. Code-review-graph uses a structural AST-based graph with call chains, inheritance, and test coverage edges. The graph approach is more precise — it knows exactly which functions call your changed code, which tests cover it, and what the downstream impact is. Benchmarks show 82x fewer tokens needed compared to naive full-corpus approaches.
4. What's the performance impact on my development machine?
Minimal. The initial build takes about 10 seconds for a 500-file project. After that, incremental updates (triggered by file saves or git hooks) complete in under 2 seconds even for large repos. Search queries run in under 2ms. The SQLite database is lightweight, and watch mode uses efficient file system watchers.
5. Can I use code-review-graph with multiple repositories?
Yes. Code-review-graph supports a multi-repo registry. You can register multiple repositories, build graphs for each, and search across all of them. There's also a crg-daemon tool that watches multiple repos as child processes, with health checks and auto-restart — perfect for monorepo setups or teams managing multiple services.
6. What happens when code-review-graph doesn't support my programming language?
You can add custom language support by creating a .code-review-graph/languages.toml file that maps file extensions to Tree-sitter grammars and specifies node types for functions, classes, imports, and calls. No fork or code changes are needed — the generic tree-sitter walker handles extraction automatically. The project already covers 35+ languages out of the box.
7. How accurate is the blast radius prediction?
Benchmarks show an average F1 score of 0.71 against graph-derived ground truth, with precision at 0.578 and recall at 1.0 (circular upper bound). The tool is deliberately conservative — it's better to flag too many files than miss a broken dependency. For real-world validation, the project also measures co-change mode (grading against files actually modified together in git history).
Want to level up your development skills? Check out CoddyKit's interactive coding courses to master modern programming languages and tools.