SuperAPI AI Directory

code-review-graph

Builds a structural code graph with Tree-sitter, tracks incremental changes, and exposes precise review context to AI coding assistants via MCP to reduce redundant codebase reads.

Open website

About this tool

code-review-graph is a local-first code knowledge graph that provides precise code review context to AI coding tools through MCP.

Purpose AI coding tools often reread large portions of the codebase when reviewing changes. code-review-graph uses Tree-sitter to build a structured map of the code, maintains updates incrementally, and provides compact context through MCP, so the assistant reads only the files relevant to the change.

Main capabilities

  • Blast radius analysis: when a file changes, the graph traces all potentially affected callers, dependents, and tests, and the assistant reads only those files.
  • Incremental updates: triggered through hooks, pre-commit hooks, and watch mode; updates compare changed files, find dependents along import and call edges, and reparse only files whose SHA-256 hash has changed. On a project of about 3,000 files (django), a two-file edit reindexes through the hook path in about 2.5 seconds, of which about 1.4 seconds is process startup; a no-op update consumes only that startup time.
  • Return slices for targeted questions: instead of feeding the entire corpus to the model, it returns trimmed content by question.
  • Language coverage: supports Python, JavaScript/TypeScript/TSX, Go, Rust, Java, C/C++, C#, VB.NET, Ruby, Kotlin, Swift, PHP, Scala, Solidity, Dart, R, Perl, Lua/Luau, Objective-C, shell scripts, Elixir, Zig, PowerShell, Julia, ReScript, GDScript, Nix, Verilog/SystemVerilog, SQL, Terraform/OpenTofu (.tf; other .hcl files become file nodes only), Ansible YAML, Spring Boot application configuration, Vue/Svelte SFC, Astro, Jupyter and Databricks notebooks (.ipynb), Perl XS (.xs). Other YAML and .properties files are not treated as source code.
  • Framework parsing: PHP supports Composer PSR-4 resolution, Blade template references, Laravel Route and Eloquent edges; Java supports Spring dependency injection call resolution, request endpoints, WebFlux routes, scheduled triggers, application event publisher-to-listener edges, Temporal workflow and activity edges.
  • Custom languages: you can add languages.toml under .code-review-graph/ to map extensions to grammars in tree_sitter_language_pack, and specify the node types for functions, classes, imports, and calls; built-in languages cannot be overridden.
  • CI risk-scoring PR review: the same analysis runs as a composite GitHub Action, with graph construction and queries both completed on the CI runner, without sending source code to external services; each PR posts one sticky comment containing risk-scoring functions, affected execution flows, and test gaps, updated in place on each push; the optional fail-on-risk input can turn it into a merge gate.
  • Token savings estimates: the review and impact tools attach a context_savings estimate to responses; the CLI's Token Savings panel displays the same numbers, and --verify compares them against the OpenAI cl100k_base tokenizer. Calibration across 222 sample files shows that the estimates differ from actual tokens by about 1% overall.

Usage

  • Installation: install detects installed AI coding tools, writes an MCP server entry for each tool, installs hooks and skills when the platform supports it, and adds graph notes to the platform's rules file. MCP entries use poetry run or uv run within a Poetry or uv project environment; if uvx is in PATH, use uvx code-review-graph serve; otherwise use the current Python interpreter. After installation, restart the editor or tool. Requires Python 3.10+.
  • Specify platform: pass codex, claude-code, cursor, windsurf, zed, continue, opencode, antigravity, gemini-cli, qwen, kiro, qoder, copilot, copilot-cli, codebuddy, or hermes through --platform. Configuration file locations are in docs/USAGE.md.
  • Uninstall: uninstall removes CRG's own files and entries from a Git or SVN working tree, preserving other MCP servers, hooks, skills, and JSONC comments; it can be run anywhere within the tree; shared configuration files are replaced atomically, and the original file remains intact if a write fails.
  • Daemon: if the editor does not support hooks (such as Cursor, OpenCode), or if you want to keep the graph fresh without relying on editor integration, you can use the built-in daemon to watch the repository and update the graph, with no separate installation required.

Use cases

  • Code review and change impact analysis.
  • AI-assisted workflows in large repositories.
  • Risk scoring and merge gating for PRs in CI.
  • Providing code knowledge graph context to AI coding assistants via MCP.

Limitations

  • Small single-file changes: graph context may exceed reading the file directly; the overhead comes from the structured metadata that makes multi-file analysis possible.
  • Search ranking: keyword search usually puts the correct results first, but ranking still needs improvement; Express queries may return zero results due to module pattern naming.
  • Flow detection: entry point detection is strongest in Python and PHP/Laravel; flow detection in JavaScript and Go still needs improvement.
  • Precision and recall: impact analysis is conservative and flags files that may be affected, producing false positives in large dependency graphs.
  • The impact "recall 1.0" in the benchmark is circular: the historical ground truth comes from the same graph edges traversed by the predictor, so it is an upper bound by construction; co-change mode is not yet available, and in the 2026-08-02 capture, predicted_files = 0 for every scored commit.
  • Cold-start build time grows with repository size; a repository of about 3000 files takes about 40 seconds.
  • When some files fail to parse, the status is partial, the CLI prints a Warning to stderr, and those files retain their previous graph rows.