tirth8205 / code-review-graph
Summary
code-review-graph is a Python 3.10+ tool designed to optimize AI code review by significantly reducing token consumption. It constructs a structural map of a codebase using Tree-sitter, storing it as a graph of nodes and edges. This graph enables incremental updates and provides AI assistants with precise context via the Model Context Protocol (MCP), ensuring they only review relevant code. Benchmarks show a median per-question token reduction of approximately 82x, with a maximum of 528x, across six real repositories. The tool supports a wide array of programming languages, including Python, JavaScript, Go, Rust, Java, PHP, and Jupyter notebooks, and integrates with platforms like Codex, Claude Code, Cursor, and GitHub Copilot. Key functionalities include blast-radius analysis, sub-2-second incremental updates for large projects, monorepo optimization, custom language definitions, and risk-scored pull request reviews through a GitHub Action.
Key takeaway
For AI Engineers or MLOps teams managing large codebases and AI-assisted reviews, code-review-graph offers a critical solution to reduce token costs and improve review accuracy. You should integrate this tool to provide your AI assistants with precise, graph-derived context, drastically cutting down on unnecessary token consumption. This enables faster, more focused reviews and ensures your models analyze only the most relevant code changes, enhancing efficiency and reducing operational expenses.
Key insights
AI code review efficiency hinges on providing precise, minimal context to large language models.
Principles
- Graph-based code representation reduces context.
- Incremental parsing maintains graph freshness.
- Blast-radius analysis targets relevant changes.
Method
code-review-graph parses a repository into an AST using Tree-sitter, storing it as a graph. This graph is incrementally updated and queried at review time to compute a minimal set of files for AI assistants, delivered via MCP.
In practice
- Install code-review-graph and run "install" to configure AI tools.
- Use "build" to parse your codebase into a graph.
- Integrate the GitHub Action for CI/CD risk-scored reviews.
Topics
- AI Code Review
- Token Optimization
- Model Context Protocol
- Code Graph Analysis
- Tree-sitter
- CI/CD Integration
Code references
Best for: Machine Learning Engineer, AI Architect, Software Engineer, AI Engineer, MLOps Engineer
Related on AIssential
See Counsel's argued verdicts on the open AI decisions leaders are weighing →
Editorial summary, takeaway, and curation by AIssential. Original article published by Github Trending: All languages.