code-review-graph Technical Briefing
The Problem
AI coding tools re-read entire codebases on every task, burning tokens unnecessarily. This repo addresses that by building a persistent structural map so assistants read only what matters. The README states 6.8× fewer tokens on reviews and up to 49× on daily coding tasks.
What This Does
code-review-graph uses tree-sitter to parse code structure and tracks changes incrementally. The core graph lives in code_review_graph/graph.py (63 functions, 5 classes, called from 52 other files), while code_review_graph/parser.py (80 functions, 4 classes) handles language-specific parsing. Incremental updates are managed by code_review_graph/incremental.py (35 functions, 2 classes). The system exposes MCP-compatible tools via code_review_graph/main.py — get_minimal_context_tool (line 158, reaches 42 functions) and get_review_context_tool (line 240, reaches 30 functions) are the primary entry points for AI assistant integration. The VS Code extension in code-review-graph-vscode/ provides the UI layer, with src/backend/cli.ts as its entry point.
How It Is Wired
Execution starts at the CLI: code_review_graph/cli.py:315 (main) reaches 280 functions and is called from 4 places. The import graph has 121 modules and 277 edges with zero circular dependencies. The most connected module is code_review_graph/graph (54 importers, 3 imports, instability 0.05), while code_review_graph/tools/__init__ has high instability at 0.72 (5 importers, 13 imports).
Traced paths to external effects: main -> get_db_path triggers filesystem deletion via side.unlink; get_minimal_context_tool -> get_minimal_context -> _has_git_changes runs subprocess.run; get_review_context_tool -> get_review_context reads files via full_path.read_text. The call graph contains 2,585 resolved edges — commit is called from 78 places, NodeInfo from 60, parse_file from 55.
How To Use It
Setup: pip install code-review-graph (or pipx). Then code-review-graph install auto-detects platforms and writes MCP configuration. Supported via --platform cursor, --platform claude-code, or --platform kiro. Requires Python 3.10+; uv is recommended for uvx integration.
Build: code-review-graph parse constructs the graph. Initial build takes ~10 seconds for a 500-file project; subsequent updates happen automatically on file edits and git commits.
Real-World Use
After code-review-graph install, open your project and invoke: Build the code review graph for this project. The assistant then uses get_minimal_context_tool to retrieve only relevant code — the graph ensures it reads ~6.8× fewer tokens during reviews. On daily coding tasks, context is further reduced, keeping the AI focused on the modified area.
Code Health & Issues
Static analysis of 122 code files identified these findings:
- [MEDIUM] Broad exception handling x7 —
code_review_graph/graph.py,code_review_graph/communities.py,code_review_graph/embeddings.py: Bareexceptclauses swallow errors indiscriminately. - [HIGH/cognitive_load] Deep nesting x35 —
code_review_graph/graph.py,code_review_graph/parser.py,code_review_graph/incremental.py: Max indentation depth 7; control flow is hard to follow. Fix: flatten with guard clauses. - [HIGH/cognitive_load] Oversized file x12 — Same files: 1,156-line files ripple changes widely. Fix: split into cohesive units.
- [HIGH/clarity] Hub module x5 —
code_review_graph/graph.pyis depended on by 54 modules; churn here has high-blast-radius. Fix: keep stable and small; move volatile logic out. - [HIGH/clarity] Duplicated code blocks — 2,027 repeated 6-line blocks across 60 files in
code-review-graph-vscode/. Extract shared helpers.
Repository hygiene findings: no Dependabot/Renovate configured, no dependency vulnerability scan in CI, checkout retains token (persist-credentials not disabled), two workflow jobs lack timeouts, and convention files (.editorconfig, .gitattributes) are absent.
The Bottom Line
The graph construction and incremental update logic work well — the token reduction claim is credible given the module mapping and call-graph analysis. However, the codebase shows significant maintainability risk: three files carry most import and call traffic, deep nesting is prevalent, and exception handling is broad. The hygiene gaps (no update bot, no dependency scanning) are easy to remediate. This is worth adopting if you control the AI assistant pipeline and want to reduce token consumption, but plan to allocate engineering time to restructure the high-traffic modules.
Word count: ~480