# How Code Review Graph (CRG) Improves AI Coding Assistant Efficiency

> Discover how Code Review Graph (CRG) drastically cuts AI coding assistant token usage by 71×, replacing full scans with efficient SQLite knowledge graph queries. Boost your AI's performance today.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: how-to-guide
- Published: 2026-08-08

---

**Code Review Graph reduces token consumption by up to 71× by replacing full-repository scans with targeted queries against a compact, local SQLite knowledge graph.**

The tirth8205/code-review-graph repository solves the "token-bloat" bottleneck that degrades AI coding assistant efficiency. Traditional agents often re-read entire codebases to answer single questions, consuming hundreds of thousands of tokens, whereas CRG maintains a structural knowledge graph that delivers precise context using only a fraction of the token budget.

## The Token-Bloat Problem

AI-based code reviewers face a critical efficiency challenge when handling large repositories. Answering a question about the Flask corpus requires approximately **143,000 tokens** when reading the entire repository sequentially, while a graph-driven answer needs only **~2,000 tokens**—a **71× reduction** [README.md#L49-L53]. This disparity occurs because standard retrieval methods lack structural awareness, forcing language models to process irrelevant files to locate dependencies and call chains.

## Architectural Components

CRG achieves efficiency through a multi-layered architecture that persists code structure in a queryable format.

### Tree-Sitter AST Parsing

At the ingestion layer, [`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py) leverages Tree-sitter to extract abstract syntax tree (AST) nodes including functions, classes, imports, and definitions across approximately **30 programming languages** plus notebooks. This parsing step transforms raw source code into a normalized graph representation.

### SQLite-Backed GraphStore

The core persistence mechanism lives in [`code_review_graph/graph.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/graph.py), which implements the `GraphStore` class. This module defines a minimal SQLite schema [L74-L106] that stores nodes and typed edges (CALLS, IMPORTS, TESTED_BY, etc.) locally without external databases or telemetry. The graph remains language-agnostic and portable, residing in `~/.code-review-graph/graph.db`.

### Incremental Update Engine

Rather than re-parsing the entire repository on every change, CRG tracks file SHA-256 hashes to detect modifications. The update logic in [`code_review_graph/graph.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/graph.py) [L59-L66] executes incremental refreshes within a single SQLite transaction, touching only changed files and maintaining graph integrity without full rebuilds.

## MCP Integration and Blast-Radius Analysis

CRG exposes **30 MCP tools** [README.md#L65-L70] that allow AI assistants to query the graph directly instead of performing raw text searches, leveraging prompt templates defined in [`code_review_graph/prompts.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/prompts.py).

### Blast-Radius Traversal

When a developer modifies a file, the `detect_changes_tool` and `get_impact_radius_tool` traverse the graph to identify every caller, dependent module, and affected test. This blast-radius analysis [README.md#L30-L34] returns only the minimal set of files relevant to the change, ensuring the AI reads strictly necessary context.

### Token-Savings Verification

The CLI provides transparency into efficiency gains through `--brief` flags. Commands like `detect-changes --brief` and `update --brief` display exact token savings per operation [README.md#L91-L99], allowing teams to measure AI coding assistant efficiency improvements quantitatively.

## Measurable Efficiency Gains

The graph-based approach delivers concrete performance benefits:

- **Token Reduction**: Up to 71× fewer tokens consumed compared to full-repository scans
- **Accuracy**: Approximately **0.69 F1 score** for impact analysis tasks [README.md#L51-L57]
- **Latency**: Local SQLite queries execute in milliseconds versus seconds for recursive text searches
- **Coverage**: Multi-hop dependency resolution across the entire codebase via [`code_review_graph/flows.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/flows.py) criticality scoring

## Implementation Workflow

Deploying CRG follows a three-phase pattern:

1. **Build**: Initialize the graph database
   ```bash
   code-review-graph install   # Auto-detects AI tools and configures MCP

   code-review-graph build     # Parses entire repo once (~10s for 500 files)

   ```

2. **Update**: Refresh incrementally after edits
   ```bash
   code-review-graph update    # Only processes changed files via SHA-256 diff

   ```

3. **Query**: Interface through Python or MCP tools
   ```python
   from code_review_graph.graph import GraphStore

   # Open the SQLite graph directly (e.g., for custom scripts)

   with GraphStore("~/.code-review-graph/graph.db") as store:
       # Find all callers of a function (multi-hop)

       callers = store.get_nodes_by_file("src/auth.py")
       for node in callers:
           print(node.qualified_name)

       # Compute blast-radius for a changed file

       impact = store.get_transitive_tests("src/auth.py", max_depth=2)
       print(f"Affected tests: {[t['qualified_name'] for t in impact]}")
   ```

The [`code_review_graph/graph_diff.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/graph_diff.py) module handles differential updates between snapshots, while [`code_review_graph/flows.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/flows.py) detects critical call chains and scores their importance.

## Summary

- **Code Review Graph** eliminates token bloat by storing codebase structure in a local SQLite graph rather than requiring full-text scans.
- **Tree-sitter parsing** in [`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py) extracts AST nodes across 30+ languages to populate the graph.
- **Incremental updates** via SHA-256 hashing in [`code_review_graph/graph.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/graph.py) ensure only modified files trigger re-processing.
- **MCP tools** like `detect_changes_tool` enable AI assistants to query precise blast-radius context instead of reading entire repositories.
- **71× token reduction** demonstrates measurable improvements in AI coding assistant efficiency and response latency.

## Frequently Asked Questions

### How much token reduction can I expect when using CRG?

According to benchmarks in the repository documentation, analyzing the Flask corpus requires approximately 143,000 tokens with traditional full-repository scanning, while CRG delivers equivalent context in roughly 2,000 tokens—achieving a **71× reduction** in token consumption.

### What programming languages does CRG support?

The parser in [`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py) supports approximately **30 programming languages** plus Jupyter notebooks through Tree-sitter, making the graph construction process language-agnostic regardless of whether your codebase uses Python, JavaScript, Rust, or other supported languages.

### How does the incremental update mechanism work?

CRG tracks file SHA-256 hashes to detect changes. When you run `code-review-graph update`, the system compares current hashes against the stored graph state and re-parses only modified files within a single SQLite transaction [code_review_graph/graph.py#L59-L66], avoiding full repository rebuilds.

### Where is the graph data stored?

All structural data persists in a local SQLite database located at `~/.code-review-graph/graph.db` by default. This local-first approach requires no external database infrastructure, sends no telemetry, and allows AI assistants to query codebase structure instantly without network latency.