Code Review Graph: The Open-Source Tool With 28,000+ GitHub Stars That Cuts AI Coding Token Costs by 65x
Code Review Graph builds a structural AST map of your codebase using Tree-sitter, giving AI coding assistants precise context via MCP — cutting token usage by up to 65x with support for 30+ languages and 15+ platforms.
pip install code-review-graph, and your AI stops re-reading your entire repo on every question.
If you've ever watched your AI coding assistant churn through thousands of tokens just to answer "what does this function do?", you've felt the pain. Large codebases are token furnaces. Every question, every review, every refactor request sends the model re-reading files it doesn't need — burning money, context window space, and your patience.
Code Review Graph (CRG) fixes this at the root. Instead of letting your AI assistant blindly scan your entire codebase, CRG builds a persistent structural map of your code — functions, classes, imports, call chains, inheritance, test coverage — and feeds the model only what's relevant to each specific question. The result? A ~65x median token reduction per query across real-world open-source repositories, with benchmarks to prove it.
Trending on GitHub today with over 28,800 stars and 2,600+ forks, CRG has quickly become one of the most popular developer tools of 2026. Here's everything you need to know.
What Is Code Review Graph?
Code Review Graph is a local-first, open-source Python tool that parses your repository 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), and exposes that graph to AI coding tools via the Model Context Protocol (MCP).
When you ask your AI assistant a question — "how does authentication work?", "what breaks if I change this function?", "where are the test gaps?" — CRG queries the graph and returns a precisely scoped slice of your codebase instead of the whole thing.
Think of it as giving your AI assistant a map of your code instead of a pile of files.
# Install
pip install code-review-graph # or: pipx install code-review-graph
# Configure for all your AI tools (auto-detects Codex, Cursor, Claude Code, etc.)
code-review-graph install
# Parse your codebase
code-review-graph build
That's it. Three commands. The install step auto-detects which AI coding platforms you have installed — Claude Code, Cursor, Codex, GitHub Copilot, Windsurf, Zed, and 12+ more — and configures MCP for each one.
How It Works: The Architecture
Understanding CRG's architecture helps explain why it's so effective:
1. Tree-Sitter AST Parsing
CRG uses Tree-sitter — the same incremental parser used by GitHub's code navigation and Neovim — to build a concrete syntax tree of every file in your repository. This captures functions, classes, imports, call sites, inheritance relationships, and test detection across 30+ programming languages.
2. Graph Construction
The parsed AST data is stored as a directed graph where:
- Nodes = functions, classes, modules, files
- Edges = function calls, imports, inheritance, test coverage
- Communities = clusters of related code (via Leiden algorithm)
3. MCP Integration
The graph is exposed to AI tools via the Model Context Protocol (MCP). When your AI assistant needs context, it queries CRG instead of reading files directly.
4. Blast Radius Analysis
When a file changes, CRG traces every caller, dependent, and test that could be affected — the "blast radius" of your change. Your AI reads only these files instead of scanning the whole project.
# After making changes, ask your AI:
"Build the code review graph for this project and show me what's affected by my changes"
The Numbers: Real Benchmarks on Real Repos
CRG's benchmarks are refreshingly honest. They test against 6 real open-source repositories at pinned commits, with deterministic embeddings and reproducible results:
| Repository | Corpus Tokens | Graph Query Tokens | Reduction |
|---|---|---|---|
| FastAPI | 948,793 | 2,653 | 375.6x |
| Flask | 143,594 | 2,196 | 71.0x |
| Gin (Go) | 166,868 | 2,766 | 61.9x |
| HTTPX | 142,356 | 2,661 | 60.6x |
| Express.js | 136,052 | 3,936 | 36.0x |
Median reduction: ~65x. For a typical agent question, the graph returns ~2,000–3,500 tokens of targeted context instead of forcing the agent to process hundreds of thousands of tokens.
The project is also transparent about limitations: search quality (MRR 0.35) needs improvement, flow detection (33% recall) works best for Python and PHP, and small single-file changes can actually cost more tokens through graph overhead. These are real trade-offs, not hidden gotchas.
30+ Languages, 15+ Platforms — One Tool
CRG's language support is remarkably broad:
- Web: JavaScript, TypeScript/TSX, Vue, Svelte, Astro
- Systems: Rust, C/C++, Go, Zig
- Enterprise: Java, C#, VB.NET, Kotlin, Scala
- Scripting: Python, Ruby, PHP, Perl, Lua, PowerShell
- Mobile: Swift, Kotlin, Dart
- Specialized: Solidity, SQL, Terraform, Ansible, Verilog
- Notebooks: Jupyter/Databricks (.ipynb)
And it integrates with virtually every AI coding platform:
# Target a specific platform:
code-review-graph install --platform codex # OpenAI Codex
code-review-graph install --platform cursor # Cursor
code-review-graph install --platform claude-code # Claude Code
code-review-graph install --platform copilot # GitHub Copilot
code-review-graph install --platform windsurf # Windsurf
code-review-graph install --platform zed # Zed
code-review-graph install --platform gemini-cli # Gemini CLI
code-review-graph install --platform kiro # Kiro
# ... and 8 more
PHP projects get extra love: CRG includes repository-bounded Composer PSR-4 resolution, Blade template references, and Laravel Route/Eloquent semantic edges.
Real-World Example: AI Code Review in CI/CD
One of CRG's most powerful features is its GitHub Action. Add this to your workflow, and every pull request gets an AI-powered review with risk-scored functions, affected execution flows, and test gap analysis:
# .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 }}
The action posts a single sticky comment on each PR — updated in place on every push — with risk-scored functions, affected execution flows, and test gaps. An optional fail-on-risk input turns the review into a merge gate.
And it stays local-first: the knowledge graph is built and queried entirely on your CI runner, with no source code sent to any external service.
Real-World Example: Large Monorepo Development
Imagine you're working on a 3,000-file Django monorepo. You change two files in an authentication module. Without CRG, your AI assistant might try to read the entire 200K+ token codebase to understand the impact.
With CRG:
- You save the files
- CRG's watch mode detects the changes
- It re-parses only the 2 changed files (~2.5 seconds)
- It traces the blast radius: 12 dependent functions, 3 API endpoints, 2 test files
- Your AI assistant gets ~3,000 tokens of precisely scoped context
That's the difference between a $0.50 API call and a $0.01 API call. Multiply that by dozens of questions per day, across a team of developers, and the savings compound fast.
Key Benefits
- 65x token reduction — Median across 6 real-world repositories, with benchmarks you can reproduce yourself
- Local-first privacy — Your code never leaves your machine or CI runner
- Incremental updates — Only changed files are re-parsed; a two-file edit on a 3,000-file repo takes ~2.5 seconds
- 30+ languages — From Python to Solidity, with custom language support via TOML config
- 15+ platform integrations — One
installcommand configures all your AI tools - CI/CD ready — GitHub Action with risk-scored PR reviews and optional merge gates
- Open source (MIT) — 28,000+ stars, 2,600+ forks, active community
- Graph visualization — D3.js force-directed graph with search and community toggles
- Export formats — GraphML (Gephi), Neo4j Cypher, Obsidian vault, SVG
Getting Started in Under 60 Seconds
# 1. Install (Python 3.10+)
pip install code-review-graph
# 2. Configure for all your AI tools
code-review-graph install
# 3. Build the graph for your project
code-review-graph build
# 4. Start coding — your AI assistant now has precise context
# Example prompt: "What functions are affected by changes in auth.py?"
For even better performance, install uv — CRG will use uvx for faster MCP startup if available.
When CRG Might Not Be For You
To be fair, CRG has trade-offs worth knowing:
- Small projects: If your codebase is under ~50 files, the token savings are minimal. The overhead of maintaining the graph isn't worth it for tiny projects.
- Search quality: The built-in keyword search has an MRR of 0.35 — it finds the right result in the top-4, but ranking needs work. Semantic search via embeddings helps but adds a dependency.
- Initial build time: A 500-file project takes ~10 seconds for the first build. Not bad, but not instant.
- Flow detection: Currently at 33% recall, strongest for Python and PHP. JavaScript and Go flow detection is improving but not production-grade yet.
For large, multi-language codebases where AI token costs are a real concern, CRG is transformative. For a weekend side project? Probably overkill.
Frequently Asked Questions
What is Code Review Graph and how does it work?
Code Review Graph is an open-source Python tool that parses your codebase into an Abstract Syntax Tree (AST) using Tree-sitter, stores it as a graph of functions, classes, and relationships, and exposes that graph to AI coding tools via MCP. Instead of reading your entire codebase, your AI assistant queries the graph for precisely scoped context — reducing token usage by ~65x on average.
How much does Code Review Graph cost?
Code Review Graph is completely free and open-source under the MIT license. There are no paid tiers. The tool itself doesn't cost anything; the savings come from reduced API token usage when working with AI coding assistants like Claude, GPT-4, or Gemini.
Which AI coding tools does Code Review Graph support?
CRG supports 15+ platforms including Claude Code, OpenAI Codex (app and CLI), Cursor, GitHub Copilot (VS Code and CLI), Windsurf, Zed, Gemini CLI, Kiro, Antigravity, Continue, OpenCode, Qwen, Qoder, CodeBuddy, and more. A single code-review-graph install command auto-detects and configures all of them.
Does Code Review Graph send my code to external servers?
No. Code Review Graph is local-first. Your code is parsed, stored, and queried entirely on your machine or CI runner. No source code is sent to any external service. The knowledge graph lives on your filesystem.
What programming languages does Code Review Graph support?
CRG supports 30+ languages including Python, JavaScript/TypeScript, Go, Rust, Java, C/C++, C#, Ruby, Kotlin, Swift, PHP, Scala, Solidity, Dart, Perl, Lua, Objective-C, Elixir, Zig, PowerShell, Julia, SQL, Terraform, and more. You can also add custom languages via a languages.toml config file.
How does the 65x token reduction benchmark work?
The benchmark measures naive full-corpus tokens (all source files) versus graph query tokens (the precise slice CRG returns for a specific question) across 6 real open-source repositories at pinned commits. The median reduction is ~65x, with a range of 36x (Express.js) to 376x (FastAPI, the largest corpus). Results are reproducible — the full methodology is in the project's REPRODUCING.md.
Can I use Code Review Graph in CI/CD pipelines?
Yes. CRG provides a GitHub Action (tirth8205/code-review-graph@v2.3.6) that runs on every pull request, posts risk-scored review comments with affected functions and test gaps, and optionally acts as a merge gate. The graph is built entirely on the CI runner — no code leaves your pipeline.