# How to Set Up the code-review-graph Repository Locally: Complete Installation Guide

> Learn how to set up the code-review-graph repository locally. This guide covers cloning, installation, auto-configuration, and building your knowledge graph with ease.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: getting-started
- Published: 2026-08-17

---

**You can set up code-review-graph by cloning the repository, installing the CLI via `pip` or `uv`, running `code-review-graph install` to auto-configure MCP integrations, and executing `code-review-graph build` to generate the initial SQLite knowledge graph.**

The `code-review-graph` tool creates a persistent, incrementally-updated knowledge graph of your codebase using Tree-sitter parsing and SQLite storage. Setting up the repository locally gives you a local-first AI code review system with no telemetry, exposing functionality through both a command-line interface and an MCP server for integration with AI coding assistants.

## Prerequisites

Before beginning the local setup, ensure you have **Python 3.x** installed on your system. The tool supports installation via `pip`, `pipx`, or `uv`, though a virtual environment is strongly recommended to isolate dependencies.

## Step-by-Step Local Setup

### Clone the Repository

First, download the source code from GitHub and navigate into the project directory:

```bash
git clone https://github.com/tirth8205/code-review-graph.git
cd code-review-graph

```

This provides access to the core parser logic in [`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py) and the documentation in [`docs/architecture.md`](https://github.com/tirth8205/code-review-graph/blob/main/docs/architecture.md).

### Create a Python Virtual Environment

Isolate your dependencies to avoid conflicts with system packages:

```bash
python3 -m venv .venv
source .venv/bin/activate

```

On Windows, use `.venv\Scripts\activate` instead.

### Install the CLI Tool

Choose one of three installation methods depending on your workflow:

- **Pip** (standard): `pip install code-review-graph`
- **Pipx** (global CLI isolation): `pipx install code-review-graph`
- **uv** (fast Rust-based installer): `uv tool install . --force`

All methods install the `code-review-graph` command-line interface. According to the source, the `install` sub-command will later handle platform-specific hook configurations.

### Configure Platform Integrations

Auto-detect your AI coding tools and write the correct MCP configuration files:

```bash
code-review-graph install

```

This command inspects your environment for supported editors and AI assistants, then installs the appropriate hooks and MCP server configurations needed for integration.

### Build the Initial Knowledge Graph

Parse your entire repository and create the SQLite graph database:

```bash
code-review-graph build

```

This first build parses all tracked files using the Tree-sitter grammar engine implemented in [`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py), extracting nodes (files, classes, functions) and edges (calls, imports, inheritance). For a typical 500-file project, expect approximately 10 seconds for completion. The graph persists to `.code-review-graph/graph.db`.

### Enable Live Updates (Optional)

Start a file watcher to keep the graph synchronized automatically:

```bash
code-review-graph watch

```

The incremental engine detects changed files via Git or SVN, re-parsing only modified files plus their dependents rather than rebuilding the entire graph.

### Verify the Installation

Confirm the graph is operational and view statistics:

```bash
code-review-graph status
code-review-graph detect-changes --brief

```

These commands display graph statistics and a token-savings panel, confirming that the SQLite store at `.code-review-graph/graph.db` is properly initialized and accessible.

## Understanding the Core Architecture

The local setup creates three primary components on your machine:

- **Parser** – Uses Tree-sitter grammars in [`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py) to extract AST-based structural nodes and edges from every tracked file.
- **Graph Store** – A SQLite database located at `.code-review-graph/graph.db` that persists nodes, edges, metadata, and optional embeddings.
- **Incremental Engine** – Detects file changes and updates only the affected portions of the graph, making subsequent builds nearly instantaneous.

## Key Configuration Files

After setup, several files govern the tool's behavior:

| File | Purpose |
|------|---------|
| `.code-review-graph/graph.db` | The SQLite database containing the persisted knowledge graph (auto-generated after first build). |
| `.code-review-graphignore` | Custom ignore patterns for indexing; uses the same syntax as `.gitignore`. Create this in your repository root as needed. |
| [`docs/USAGE.md`](https://github.com/tirth8205/code-review-graph/blob/main/docs/USAGE.md) | Detailed documentation for CLI commands and platform-specific options. |
| [`docs/architecture.md`](https://github.com/tirth8205/code-review-graph/blob/main/docs/architecture.md) | System overview and data-flow diagrams describing how the parser and incremental engine interact. |

## Summary

- **Clone** the repository from `https://github.com/tirth8205/code-review-graph.git` to access the source.
- **Install** using `pip`, `pipx`, or `uv` to obtain the `code-review-graph` CLI.
- **Configure** MCP integrations automatically with `code-review-graph install`.
- **Build** the initial SQLite graph using `code-review-graph build`, which leverages [`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py) for AST extraction.
- **Maintain** freshness via `code-review-graph watch` for incremental updates or manual rebuilds.
- **Customize** indexing behavior using `.code-review-graphignore` files in your project root.

## Frequently Asked Questions

### What Python version is required to run code-review-graph locally?

The repository requires **Python 3.x** or higher. While specific minimum versions depend on dependencies like Tree-sitter bindings, any modern Python 3 installation should suffice. Using a virtual environment prevents conflicts with system packages.

### Where does code-review-graph store the knowledge graph data?

All data persists locally in a **SQLite database** at `.code-review-graph/graph.db`. This local-first approach ensures no telemetry is transmitted unless you explicitly opt-in to cloud embeddings. The database stores nodes (files, classes, functions), edges (calls, imports), and metadata.

### How do I integrate code-review-graph with my AI coding assistant?

Run `code-review-graph install` after installation. This command auto-detects supported AI tools and editors on your system, then writes the necessary **MCP (Model Context Protocol)** configuration files. Once configured, you can ask your MCP client: "Review my recent changes with risk scoring" to leverage the graph for contextual code review.

### Can I exclude specific files from the knowledge graph indexing?

Yes. Create a `.code-review-graphignore` file in your repository root using standard `.gitignore` syntax. The parser respects these patterns during both full builds and incremental updates, allowing you to exclude generated files, dependencies, or test data from the graph.