Code Review Graph

Local knowledge graph that builds a persistent structural map of your codebase so AI assistants read only what matters - 8.2x fewer tokens on average.

Why

AI coding tools re-read the entire codebase on every task. Code-review-graph fixes that by parsing your repo into an AST with Tree-sitter, storing it as a graph of nodes (functions, classes, imports) and edges (calls, inheritance, test coverage), then querying at review time to compute the minimal set of files the assistant needs. Local SQLite storage, no cloud dependency. Source: https://github.com/tirth8205/code-review-graph

Install

pip install code-review-graph
code-review-graph install          # auto-detects Cursor, Claude Code, Windsurf, Zed, etc.
code-review-graph build            # initial parse (~10s for 500 files)

install writes MCP config and injects graph-aware rules for each detected platform. Target a specific platform with --platform cursor or --platform claude-code. Requires Python 3.10+. Prefers uv/uvx if available.

Enforced Usage

Every project Kevin works on must have code-review-graph installed and built. This is not optional - it is part of the standard project setup alongside linting (Ultracite) and formatting.

On project init or first clone:

  1. pip install code-review-graph (or pipx install code-review-graph)
  2. code-review-graph install
  3. code-review-graph build

The graph auto-updates on every file edit and git commit via hooks. No manual maintenance required.

Key Capabilities

Blast-radius analysis - When a file changes, the graph traces every caller, dependent, and test that could be affected. The AI reads only these files instead of scanning the whole project.

Incremental updates - On every git commit or file save, a hook re-indexes only changed files. A 2,900-file project re-indexes in under 2 seconds.

19 languages + Jupyter notebooks - Full Tree-sitter grammar support: Python, TypeScript/TSX, JavaScript, Vue, Go, Rust, Java, Scala, C#, Ruby, Kotlin, Swift, PHP, Solidity, C/C++, Dart, R, Perl, Lua, .ipynb.

22 MCP tools - build_or_update_graph_tool, get_impact_radius_tool, get_review_context_tool, query_graph_tool, semantic_search_nodes_tool, detect_changes_tool, refactor_tool, get_architecture_overview_tool, and more. The AI assistant uses these automatically once the graph is built.

5 MCP prompts - review_changes, architecture_map, debug_issue, onboard_developer, pre_merge_check.

Benchmarks

8.2x average token reduction across 6 real open-source repos (13 commits). 100% recall on impact analysis (never misses an affected file). Deliberately conservative - over-predicts rather than under-predicts. Source: https://github.com/tirth8205/code-review-graph

Repo Avg Naive Tokens Avg Graph Tokens Reduction
express 693 983 0.7x
fastapi 4,944 614 8.1x
flask 44,751 4,252 9.1x
gin 21,972 1,153 16.4x
httpx 12,044 1,728 6.9x
nextjs 9,882 1,249 8.0x

Small single-file changes can show <1x because graph metadata exceeds the raw file. The value compounds on multi-file changes where irrelevant code is pruned.

CLI Reference

code-review-graph build            # full parse
code-review-graph update           # incremental (changed files only)
code-review-graph status           # graph stats
code-review-graph watch            # auto-update on file changes
code-review-graph visualize        # interactive D3.js force graph
code-review-graph detect-changes   # risk-scored change impact
code-review-graph wiki             # generate markdown wiki from communities

Configuration

Exclude paths via .code-review-graphignore in repo root:

generated/**
*.generated.ts
vendor/**
node_modules/**

Optional extras: [embeddings] for local vector search, [google-embeddings] for Gemini, [communities] for Leiden clustering, [wiki] for LLM-powered wiki generation.


Timeline