Code Review Graph Cuts AI Token Consumption in PR Reviews by 82x
Open-source tool code-review-graph uses Tree-sitter AST parsing to build localized structural code maps for AI coding assistants. By querying only impacted call graphs during code reviews, it achieves a median 82x token reduction across supported platforms.
Impact: High
Why it matters
Developers can reduce context window waste and lower API costs by feeding AI review agents precise Tree-sitter dependency graphs instead of entire codebases.
TL;DR
- 01Install code-review-graph via pip or pipx to auto-configure MCP tools
- 02Cut PR review token consumption by ~82x using localized AST dependency graphs
- 03Run risk-scored PR checks locally in CI via the provided GitHub Action
Key facts
- Median Token Reduction
- 82x (range 38x–528x)
- Re-index Speed
- <2s for 2,900 files
- Parsing Engine
- Tree-sitter AST
Structural AST Parsing with Tree-sitter
code-review-graph builds a local-first structural map of a codebase using Tree-sitter. It parses functions, classes, imports, and test coverage into a graph database. Initial indexing takes ~10 seconds for a 500-file project, while incremental updates for changed files complete in under 2 seconds on a 2,900-file project.
82x Median Token Savings
Instead of loading full file trees into LLM context windows, code-review-graph queries neighboring graph nodes to calculate the 'blast radius' of changes. Automated evaluation across 6 real open-source repositories demonstrated a median per-question token reduction of ~82x (ranging from 38x up to 528x on large codebases like FastAPI).
Multi-Platform MCP Support
The tool configures MCP integrations automatically across major platforms using code-review-graph install. Supported platforms include Claude Code, Cursor, Codex, Gemini CLI, Copilot, and Kiro. It also offers a local-first GitHub Action for risk-scored PR reviews in CI.
Try it in 2 minutes
pip install code-review-graph && code-review-graph installbash
✓ When to use
- When conducting automated AI code reviews on large codebases or monorepos
- When looking to drastically cut token costs for Claude Code or Cursor context windows
✕ When NOT to use
- When working on single-file scripts where full context easily fits in memory
What to do today
- Install code-review-graph locally using pip install code-review-graph
- Run code-review-graph install to configure Cursor, Claude Code, or Codex
- Add the code-review-graph GitHub Action to pull request workflows
Sources