Generated banner for code-review-graph
Generated logo for code-review-graph

code-review-graph

Memory server

Created by Tirth

Published in tirth8205/code-review-graph. Publisher page

32,711 GitHub stars

What it is

Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.
— the description by Tirth

AutoGineer overview, from the brain’s own files

code-review-graph is a local-first memory system designed to solve the token-heavy problem of AI code review. By parsing a repository into a structural map of functions, classes, imports, and tests using Tree-sitter, it stores the codebase as a graph in a local SQLite database. When an AI agent needs to review a change, the system calculates the blast radius—identifying only the relevant callers, dependents, and tests—and serves this compact context over the Model Context Protocol (MCP). This approach significantly reduces the token count required for agents to understand code impact, often by orders of magnitude. The system supports incremental updates via file system hooks and watch mode, ensuring the graph remains accurate without full re-parsing. It is designed for local execution, keeping data on the user's machine, and integrates directly with various AI coding tools and CLI environments.

How it works

Memory model: Hybrid

AutoGineer overview, from the brain’s own files

The system uses Tree-sitter to parse source code into an Abstract Syntax Tree (AST), which is then stored as nodes and edges in a local SQLite database. When a user requests a review or code analysis, the system queries this graph to determine the blast radius of a change. It then provides the AI agent with a minimal, relevant subset of the codebase rather than the entire repository. The graph is kept up-to-date incrementally; hooks and watch mode detect file changes, diff them, and re-parse only the affected files and their immediate dependents.

Folders
FolderRoleFiles
.githubagent-config15
docsdocs13
hookshooks2
scriptsscripts7
skillsagent-instructions7
teststests354
.beadsfolder9
code-review-graph-vscodefolder32
code_review_graphfolder103
diagramsfolder12
evaluatefolder24

The agent reads

The agent writes

Requirements

Apps: Docker

Runtimes: Python >=3.10

Databases: Neo4j, SQLite

API keys (by name): CRG_OPENAI_API_KEY, GITHUB_TOKEN, GOOGLE_API_KEY, MINIMAX_API_KEY, VOYAGE_API_KEY

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Google Antigravity, Kiro, OpenCode, Amp, Roo Code, Cline, JetBrains Junie, Devin (ex-Windsurf)

Set it up

  1. This brain runs code automatically: 3 hooks (claude-code). Review hooks/hooks.json before opening the folder in Claude Code. No step below turns a hook on for you.

    • hooks/hooks.json: cat >/dev/null || true; command -v code-review-graph >/dev/null 2>&1 || exit 0; git rev-parse --git-dir >/dev/null 2>&1 && code-review-graph status --repo "$(git rev-parse --show-toplevel 2>/dev/null)" || echo 'Not a git repo, skipping'
    • hooks/hooks.json: cat >/dev/null || true; code-review-graph build >/dev/null 2>&1 &
    • hooks/hooks.json: command -v code-review-graph >/dev/null 2>&1 && code-review-graph hook-update; cat >/dev/null || true
  2. Not scanned by AutoGineerIts dependencies are installed by pip or uv when you run it and were not scanned by AutoGineer (9 declared). https://pypi.org/project/code-review-graph/
  3. Created by Tirth. Published in tirth8205/code-review-graph. Licence: MIT License.

Usage

AutoGineer overview, from the brain’s own files

  • Install the tool via pip and run the install command to configure your AI coding tools.
  • Build the initial knowledge graph for your project.
  • Use MCP-enabled AI agents to query the graph for impact analysis, code reviews, or architectural questions.
  • Rely on automatic incremental updates triggered by file changes to keep the graph in sync.
“Build the code review graph for this project”
The system parses the repository and initializes the SQLite graph database for use by AI agents.
“What is the impact of changing this function?”
The agent uses the graph to identify and present the callers, dependents, and tests affected by the change.

Documentation by Tirth

<h1 align="center">code-review-graph</h1>

<p align="center"> <a href="https://trendshift.io/repositories/23329?utm_source=repository-badge&amp;utm_medium=badge&amp;utm_campaign=badge-repository-23329" target="_blank" rel="noopener noreferrer"> <img src="https://trendshift.io/api/badge/repositories/23329" alt="tirth8205%2Fcode-review-graph | Trendshift" width="250" height="55" /> </a> </p>

<p align="center"> <strong>A local code knowledge graph that gives AI coding tools precise review context over MCP.</strong> </p> <p align="center"> <a href="README.md">English</a> | <a href="README.zh-CN.md">简体中文</a> | <a href="README.ja-JP.md">日本語</a> | <a href="README.ko-KR.md">한국어</a> | <a href="README.hi-IN.md">हिन्दी</a> </p>

<p align="center"> <a href="https://pypi.org/project/code-review-graph/"><img src="https://img.shields.io/pypi/v/code-review-graph?style=flat-square&color=blue" alt="PyPI"></a> <a href="https://pepy.tech/project/code-review-graph"><img src="https://img.shields.io/pepy/dt/code-review-graph?style=flat-square" alt="Downloads"></a> <a href="https://github.com/tirth8205/code-review-graph/stargazers"><img src="https://img.shields.io/github/stars/tirth8205/code-review-graph?style=flat-square" alt="Stars"></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="MIT Licence"></a> <a href="https://github.com/tirth8205/code-review-graph/actions/workflows/ci.yml"><img src="https://github.com/tirth8205/code-review-graph/actions/workflows/ci.yml/badge.svg?branch=staging" alt="CI"></a> <a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.10%2B-blue.svg?style=flat-square" alt="Python 3.10+"></a> <a href="https://modelcontextprotocol.io/"><img src="https://img.shields.io/badge/MCP-compatible-green.svg?style=flat-square" alt="MCP"></a> <a href="https://code-review-graph.com"><img src="https://img.shields.io/badge/website-code--review--graph.com-blue?style=flat-square" alt="Website"></a> <a href="https://discord.gg/3p58KXqGFN"><img src="https://img.shields.io/badge/discord-join-5865F2?style=flat-square&logo=discord&logoColor=white" alt="Discord"></a> </p>

<p align="center"> <a href="docs/USAGE.md">Usage</a> · <a href="docs/COMMANDS.md">Commands</a> · <a href="docs/FAQ.md">FAQ</a> · <a href="docs/TROUBLESHOOTING.md">Troubleshooting</a> · <a href="docs/GITHUB_ACTION.md">GitHub Action</a> · <a href="docs/REPRODUCING.md">Reproducing the benchmarks</a> · <a href="docs/ROADMAP.md">Roadmap</a> </p>

<br>

AI coding tools often re-read large parts of a codebase to review a change. code-review-graph builds a structural map of the code with Tree-sitter, keeps it updated incrementally, and serves compact context over MCP, so the assistant reads only the files a change touches.

<p align="center"> <img src="diagrams/diagram1_before_vs_after.png" alt="The Token Problem: reading flask's whole corpus costs 143,594 tokens, a graph answer costs 2,196 (65x fewer)" width="85%" /> </p>

What it does

  • Maps your code. Functions, classes, imports, calls and tests become one graph.

  • Shows what a change can break. The callers, dependents and tests it can reach, with a risk score.

  • Stays up to date. Hooks and watch mode parse again only the files that changed.

  • Works with your AI tools. One install sets up each tool it finds.

  • Stays on your machine. One SQLite file, no cloud service; cloud embeddings are opt-in.


Quick Start

Requires Python 3.10+.

pip install code-review-graph          # or: pipx install code-review-graph
code-review-graph install              # detect installed AI coding tools and configure each one
code-review-graph build                # parse the codebase

<details> <summary><strong>What <code>install</code> changes, and how to preview it first</strong></summary> <br>

install detects which AI coding tools you have, writes an MCP server entry for each, installs hooks and skills where the platform supports them, and adds graph instructions to the platform's rules file. The MCP entry uses poetry run or uv run inside a Poetry or uv project environment, uvx code-review-graph serve when uvx is on PATH, and otherwise the current Python interpreter. Nothing is written until install has listed the files it will change and you have answered its question about instruction files; install --dry-run shows each change as a diff and writes nothing. Restart the editor or tool afterwards.

The files install writes, such as .claude/ and .mcp.json, stay visible to git in case your team commits them. install --gitignore adds the ones that run created to a marked block in .gitignore; uninstall removes the block.

For Codex, the installer also places a global code-review-graph Skill under $CODEX_HOME/skills/code-review-graph/ (default: ~/.codex/skills/code-review-graph/). It prefers CRG MCP tools and falls back to the bundled read-only CLI when MCP is unavailable; a missing, empty, or stale graph never triggers an implicit build or update. WSL and Windows Codex runtimes have separate CODEX_HOME directories and tool inventories, so install and refresh the runtime that will execute the task.

</details>

<details> <summary><strong>Every supported platform, and how to set up just one</strong></summary> <br>

<p align="center"> <img src="diagrams/diagram8_supported_platforms.png" alt="One install, every platform: detects Codex, Claude Code, CodeBuddy Code, Cursor, Windsurf, Zed, Continue, OpenCode, MiMo Code, Antigravity, Gemini CLI, Qwen Code, Qoder, Kiro, GitHub Copilot, GitHub Copilot CLI, Hermes Agent and DeepSeek Harness" width="85%" /> </p>

To configure one platform, pass --platform with one of codex, claude-code, cursor, windsurf, zed, continue, opencode, mimo, antigravity, gemini-cli, qwen, kiro, qoder, copilot, copilot-cli, codebuddy, hermes, or dsh:

code-review-graph install --platform cursor
code-review-graph install --platform codebuddy

Config file locations are listed in docs/USAGE.md. Requires Python 3.10+.

</details>

<details> <summary><strong>Remove it again with <code>uninstall</code></strong></summary> <br>

uninstall removes CRG-owned files and entries from a Git or SVN working tree and leaves other MCP servers, hooks, skills and JSONC comments alone. Run it from anywhere inside the tree. Shared config files are replaced atomically, so a failed write leaves the original intact.

code-review-graph uninstall --dry-run    # preview only
code-review-graph uninstall              # preview, confirm, apply
code-review-graph uninstall --yes        # apply without prompting
code-review-graph uninstall --all-repos  # also clean every registered repository
code-review-graph uninstall --keep-data  # remove integrations, keep graph databases
code-review-graph uninstall --keep-user-configs --repo .  # this project only

</details>

Restart the editor or tool after install. Then open the project and ask the assistant:

Build the code review graph for this project

<details> <summary><strong>How long a build takes, and what a partial build means</strong></summary> <br>

Build time scales with repository size; a cold build of a ~3,000-file repository took about 40 seconds (measured). After that, hooks and watch mode keep the graph updated. If some files fail to parse, the result has status partial and names them in its summary; the CLI also prints a Warning: line on stderr, and those files keep their previous graph rows.

</details>

Run with Docker or Podman

<details> <summary><strong>Build the image, then run it on your repository</strong></summary> <br>

Build the image from the repository root:

docker build -t code-review-graph:local .

From the repository you want to analyse, run:

docker run --rm \
  --user "$(id -u):$(id -g)" \
  --env HOME=/tmp \
  --volume "$PWD:/workspace" \
  code-review-graph:local build

The mounted repository must be writable. The command above uses your user and group IDs so the generated .code-review-graph/ directory remains owned by your user. Run these commands as a non-root host user.

For Podman, build the same Dockerfile and preserve your user mapping:

podman build -t code-review-graph:local .
podman run --rm \
  --userns=keep-id \
  --env HOME=/tmp \
  --volume "$PWD:/workspace" \
  code-review-graph:local build

The graph persists in .code-review-graph/ in the mounted repository and stores absolute container paths such as /workspace/app.py. Run update and detect-changes through Docker or Podman with the same /workspace mount. A host update on this graph can fail with "built with a different repository root". To switch to host commands, run code-review-graph build on the host to rebuild the graph with host paths.

Replace build with status to inspect the saved graph. The image includes Git and defaults to a non-root user. No graph is generated during image construction.

These examples use macOS/Linux shell syntax. On macOS, start your Docker-compatible engine or Podman machine before running them. On a host with SELinux on, such as Fedora, add :z to the mount ("$PWD:/workspace:z"), or the container is refused access to the repository.

</details>

How It Works

The repository is parsed into ASTs with Tree-sitter and stored as a graph of nodes (functions, classes, imports) and edges (calls, inheritance, test coverage). At review time the graph is queried for the smallest set of files the assistant needs to read.

<details> <summary><strong>Two diagrams: how the assistant uses the graph, and the build pipeline</strong></summary> <br>

<p align="center"> <img src="diagrams/diagram7_mcp_integration_flow.png" alt="How the assistant uses the graph: the user asks for a review, the assistant calls MCP tools, the graph returns blast radius and risk scores, the assistant reads only the affected files" width="80%" /> </p>

<p align="center"> <img src="diagrams/diagram2_architecture_pipeline.png" alt="Architecture pipeline: Repository to Tree-sitter parser to SQLite graph to blast radius to minimal review set" width="100%" /> </p>

</details>

Blast-radius analysis

<details> <summary><strong>Every caller, dependent and test a change can affect</strong></summary> <br>

When a file changes, the graph traces every caller, dependent and test that could be affected. The assistant reads those files instead of scanning the whole project.

<p align="center"> <img src="diagrams/diagram3_blast_radius.png" alt="Blast radius: a change to login() propagates to callers, dependents, and tests" width="70%" /> </p>

</details>

Incremental updates

<details> <summary><strong>Only changed files are parsed again (about 2.5 s for a two-file edit)</strong></summary> <br>

Editor hooks, git hooks (pre-commit, post-checkout, post-merge, post-rewrite) and watch mode trigger incremental updates. The update diffs changed files, finds their dependents through the graph's import and call edges, and re-parses only the files whose SHA-256 hash changed. On a ~3,000-file project (django) a two-file edit re-indexes in about 2.5 seconds on the path the hooks use, of which ~1.4 s is process start-up; a no-op update costs only that start-up. See Incremental update latency.

<p align="center"> <img src="diagrams/diagram4_incremental_update.png" alt="Incremental update flow: a hook or watch update triggers a git diff, dependents are found through graph edges, and only files whose SHA-256 hash changed are re-parsed" width="90%" /> </p>

</details>

Whole codebase or targeted answer?

<details> <summary><strong>A slice of the graph shaped to the question, not the whole codebase</strong></summary> <br>

Instead of feeding a whole corpus to the model, the graph returns a slice shaped to the question. In the 2026-08-02 capture of this repository at 84bde354, 208,821 source tokens became ~3,190 tokens per question. The repository has grown a lot since that snapshot, so both numbers are larger today.

<p align="center"> <img src="diagrams/diagram6_monorepo_funnel.png" alt="code-review-graph at the 84bde354 snapshot: 208,821 source tokens funnel down to ~3,190 token graph responses, about 65x fewer tokens per question" width="80%" /> </p>

</details>

Language coverage and notebooks

<details> <summary><strong>Python, JavaScript, TypeScript, Go, Rust, Java, C/C++, C# and many more, plus notebooks: the full list</strong></summary> <br>

<p align="center"> <img src="diagrams/diagram9_language_coverage.png" alt="Language coverage by category: Web, Backend, Systems, Mobile, Scripting, Shells, Domain, Config and Other, plus Jupyter and Databricks notebooks" width="90%" /> </p>

The parser extracts functions, classes, imports, call sites, inheritance and tests, using Tree-sitter where a grammar exists and targeted fallbacks elsewhere. Supported: Python, JavaScript/TypeScript/TSX (including .mjs, .cjs, .mts and .cts), Go, Rust, Java, C/C++, C#, VB.NET, Ruby, Kotlin (.kt, .kts), Swift, PHP, Scala, Solidity, Dart, R, Perl, Lua/Luau, Objective-C, shell scripts, Elixir, Zig, PowerShell, Julia, ReScript, GDScript, Nix, Verilog/SystemVerilog, SQL/PL/SQL (Oracle) and dbt models, Terraform/OpenTofu (.tf, and Terraform blocks in .hcl files; an .hcl file with no Terraform blocks keeps only a file node), Ansible YAML (playbooks, roles, tasks), Spring Boot application config (application.properties, application.yml, application.yaml and their application-<profile> variants; key names and value types only, never values), value-free generic YAML structure (translation files in folders such as locales/ become file nodes only), XSLT stylesheets (.xsl, .xslt), value-free JSON structure (.json; translation, test, docs, example and data files keep only a file node, and lock files are skipped), Vue/Svelte SFCs, HTML pages (.html, .htm; inline scripts, plus div, section and article blocks with an id as DocSection nodes), Astro files (parsed with the TypeScript grammar), Jupyter and Databricks notebooks (.ipynb, plus Databricks .py exports), Perl XS files (.xs), Robot Framework files (.robot, .resource), and Liquid templates (.liquid). Other .properties files are not treated as source code.

PHP projects also get repository-bounded Composer PSR-4 resolution, Blade template references, and Laravel Route and Eloquent edges when the source shows explicit framework imports, model inheritance and receiver evidence. Static Laravel routes in routes/*.php emit Endpoint nodes and controller HANDLES edges, including literal group prefixes.

Java projects get Spring dependency-injection call resolution, request endpoints and WebFlux routes, scheduled triggers, application-event publisher-to-listener edges, Spring AOP advice-to-target edges, and Temporal workflow and activity edges. Each resolver runs after the parse and needs the injected field, published event or workflow stub to be visible in the repository.

</details>

Add your own language

<details> <summary><strong>Map a file extension to a bundled Tree-sitter grammar in <code>languages.toml</code></strong></summary> <br>

If your repository uses a language the parser does not cover, add a languages.toml to .code-review-graph/ that maps file extensions to any grammar bundled in tree_sitter_language_pack, plus the node types for functions, classes, imports and calls:

[languages.erlang]
extensions = [".erl"]
grammar = "erlang"
function_node_types = ["function_clause"]
class_node_types = ["record_decl"]
import_node_types = ["import_attribute"]
call_node_types = ["call"]

The generic tree-sitter walker does the extraction. Built-in languages cannot be overridden. See docs/CUSTOM_LANGUAGES.md for the schema, validation rules and a worked example.

</details>

Risk-scored PR reviews in CI (GitHub Action)

<details> <summary><strong>One pull request comment with risk scores, affected flows and test gaps; see the sample workflow</strong></summary> <br>

The same analysis runs as a composite GitHub Action. The graph is built and queried on your CI runner; no source code is sent to an external service. On each pull request the action posts one sticky comment with risk-scored functions, affected execution flows and test gaps, updated in place on every push. The optional fail-on-risk input turns it into a merge gate. The optional details input adds more graph context, folded away and capped in size: why each top symbol scored what it did, the communities, hubs and cross-boundary links the change touches, its impact radius, its untested hotspots, and where the graph came from.

# .github/workflows/code-review-graph.yml
on:
  pull_request:

permissions:
  contents: read
  pull-requests: write

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: tirth8205/[email protected]
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

See docs/GITHUB_ACTION.md for inputs, risk levels and caching, or the workflow this repository runs on itself in .github/workflows/pr-review.yml.

</details>


Benchmarks

The median per-question token reduction across the 6 repositories is about 63x (whole-corpus baseline vs graph query). The 358x maximum is one repository (fastapi, the largest corpus), not the typical result.

<details> <summary><strong>The benchmark board, and how the numbers were made</strong></summary> <br>

<p align="center"> <img src="diagrams/diagram5_benchmark_board.png" alt="Benchmarks across 6 repositories: ~63x median per-question token reduction (358x max), 0.69 average impact F1 against graph-derived ground truth" width="85%" /> </p>

All numbers come from the evaluation runner against 6 open-source repositories (13 commits). Every config pins an upstream SHA, Leiden runs with a fixed seed, and embeddings are deterministic on CPU, so two runs on different machines produce the same numbers. The reproduction recipe is in docs/REPRODUCING.md. A weekly report-only run on the two smallest configs lives in .github/workflows/eval.yml.

</details>

<details> <summary><strong>Token efficiency: ~63x median per-question reduction (range 35x to 358x; whole-corpus vs graph query)</strong></summary> <br>

For a typical agent question ("how does authentication work", "what is the main entry point", and so on), the graph returns ~2,200 to 3,900 tokens of search hits plus neighbour edges instead of every source file. The table averages the 5 sample questions defined in code_review_graph/token_benchmark.py.

RepoSnapshot SHAnaive_corpus_tokensavg graph_tokensReduction
fastapi22381558948,7932,653357.6x
flaska29f88ce143,5942,19665.4x
code-review-graph84bde354208,8213,19065.5x
gin5c00df8a166,8682,76660.3x
httpxb55d4635142,3562,66153.5x
expressb4ab7d65136,0523,93634.6x

Captured 2026-08-02 from clean clones at the pinned SHAs (crg 2.3.7, local all-MiniLM-L6-v2 embeddings). These numbers are lower than the 2026-05-25 capture they replace: node embedding text became richer, so avg graph_tokens rose in every repo. fastapi is measured at its current pin 22381558 rather than the retired 0227991a.

The Reduction column is naive_corpus_tokens / avg graph_tokens, so it divides out from the two columns beside it. The benchmark's own average_reduction_ratio averages the five per-question ratios instead, which always reads higher; those per-question figures are in docs/REPRODUCING.md.

The code-review-graph row is a snapshot, not a current measurement. The repository has grown since 84bde354, so its corpus and graph are both much larger today.

The whole-corpus baseline is an upper bound no real agent pays; an agent greps for identifiers and reads the best-matching files. The agent_baseline eval benchmark measures that case (a pure-Python grep over the corpus, top-3 files by match count, token-counted against the graph query cost). Against that realistic baseline the median across 18 questions on 6 repositories is 6.65x (mean 14.8x, range 4.2x to 72.6x), captured 2026-09-22, before search and this baseline began ranking test files lower, so code-review-graph eval --benchmark agent_baseline --embed now gives different numbers until the capture is redone. The full table is in docs/REPRODUCING.md, under "Canonical capture, 2026-09-22".

The ratio tracks repository size, because the graph answer stays flat (2,432 to 4,021 tokens across every repo measured) while the grep baseline grows with the corpus: 4.5x on express, 52x on fastapi. Both figures measure retrieval cost, the tokens needed to locate an answer. An agent that then opens the files the graph named pays the graph on top of its usual reads rather than instead of them; semantic_search_nodes_tool(include_source=True) returns the code with the locations so it does not have to, and measuring that path end-to-end is open work.

The formal token_efficiency benchmark measures a different scenario, the full get_review_context() JSON against only the changed-file content of a commit, and reports ratios below 1 for small commits because the response carries impact-radius edges and source snippets. The two benchmarks answer different questions; see docs/REPRODUCING.md.

Review and impact tools attach a compact context_savings estimate to their responses. The CLI shows the same figures in the Token Savings panel (see Usage below) and --verify compares them with OpenAI's cl100k_base tokenizer. Calibration across 222 sample files puts the estimate within about 1% of real tokens in aggregate (data).

</details>

<details> <summary><strong>Impact accuracy: 0.69 average F1 against graph-derived ground truth (recall 1.0 is a circular upper bound)</strong></summary> <br>

Blast-radius analysis recovers every file in the ground truth on all 13 evaluation commits. Read that as an upper bound, not as "100% recall": the ground truth (changed files plus files with call or import edges into them) comes from the same graph the predictor traverses. The lower precision is deliberate; flagging an extra file costs less than missing a broken dependency.

RepoCommitsAvg F1Avg PrecisionRecall (graph-derived upper bound)
httpx20.8630.7851.0
code-review-graph20.7340.5841.0
fastapi20.6970.5391.0
express20.6670.5001.0
flask20.6330.4851.0
gin30.6090.4391.0
Average130.6930.5461.000

This table is from the 2026-08-02 capture, taken before the path fix described below. That bug also kept real neighbour files out of the graph-derived ground truth, so these numbers will change when the benchmark is re-run.

The benchmark also runs a co-change mode: the predictor is seeded with one changed file and graded against the other files the author touched in the same commit, which is evidence from git history rather than from the graph. Both modes appear in the result CSVs (ground_truth_mode column). In the 2026-08-02 capture co-change mode returned predicted_files = 0 on every graded commit, code seeds included (for example code_review_graph/cli.py and gin's context.go). The cause was a path bug in the benchmark: git diff gives repo-relative paths, the graph stores absolute ones, so the seed never matched a node. That bug is now fixed, but the benchmark has not been re-run yet, so no co-change number is quoted.

</details>

<details> <summary><strong>Build stats</strong></summary> <br>

From the same 2026-08-02 clean-room build at the pinned SHAs above. Embedding counts are lower than node counts because File nodes are not embedded. The code-review-graph row is that snapshot, not the repository as it stands now.

RepoNodesEdgesEmbeddings
fastapi6,28732,0365,159
express1,99019,4921,849
gin1,58917,2371,491
code-review-graph1,4469,0941,354
flask1,4158,2591,329
httpx1,2638,2361,193

</details>

Limitations

<details> <summary><strong>Five known limits: circular recall, small edits, search ranking, flow detection, false positives</strong></summary> <br>

  • Impact "recall 1.0" is circular. The historical ground truth comes from the same graph edges the predictor walks, so it is an upper bound by construction. Co-change numbers are not quoted until the benchmark is re-run with the path fix.

  • Small single-file changes. Graph context can exceed a plain file read for trivial edits. The overhead is the structural metadata that makes multi-file analysis possible.

  • Search ranking. Keyword search usually finds the right result near the top, but ranking needs work. Express queries can return no hits because of module-pattern naming.

  • Flow detection. Entry-point detection is strongest for Python and PHP/Laravel. JavaScript and Go flow detection needs work.

  • Precision vs recall. Impact analysis is conservative. It flags files that might be affected, which means false positives in large dependency graphs.

</details>


Features

Updates, impact analysis, search, visualisation, CI reviews, refactoring and multi-repo support, all kept on your machine.

<details> <summary><strong>The full feature table</strong></summary> <br>

FeatureDetails
Incremental updatesRe-parses only files whose hash changed. On a ~3,000-file repo a two-file edit takes ~2.5 s on the hook path (measured).
Language and notebook supportSee Language coverage above.
Framework-aware PHP parsingRepository-bounded Composer PSR-4 imports, Blade template references, evidence-gated Laravel Route-to-controller and Eloquent relationship edges
Framework-aware Java parsingSpring dependency-injection call resolution, request endpoints and WebFlux routes, scheduled triggers, application-event publisher-to-listener edges, Spring AOP advice edges, Temporal workflow and activity edges, and Spring Boot config keys indexed without their values
Blast-radius analysisWhich functions, classes and files are likely affected by a change
Auto-update hooksEditor hooks, git hooks (before each commit, after checkout, merge and rebase) and watch mode update the graph as you work
Semantic searchOptional vector embeddings via sentence-transformers, Google Gemini, MiniMax, Voyage AI, or any OpenAI-compatible endpoint
Interactive visualisationD3.js force-directed graph with search, community legend toggles and degree-scaled nodes, plus a neighbourhood view seeded from a symbol, file, flow or change
Hub and bridge detectionMost-connected nodes and chokepoints (betweenness centrality)
Surprise scoringUnexpected coupling: cross-community, cross-language, peripheral-to-hub edges
Knowledge gap analysisIsolated nodes, untested hotspots, thin communities, import cycles
Suggested questionsReview questions generated from bridges, hubs and surprises
Edge confidenceFour tiers (EXTRACTED, INFERRED, AMBIGUOUS, UNRESOLVED) with float scores on edges, so a call the graph could not bind says so
Graph traversalBFS/DFS from any node with configurable depth and token budget; path_to shows how one symbol reaches another and names the weakest hop
Export formatsGraphML, Neo4j Cypher, Obsidian vault, JSON, and SVG (SVG needs matplotlib from the eval extra)
Token benchmarkingcode_review_graph/token_benchmark.py measures whole-corpus tokens against graph query tokens per question
Estimated context savingscontext_savings metadata (estimated, saved_tokens, saved_percent) on review, impact, detect-changes and architecture responses
Community auto-splitCommunities above 25% of the graph are split recursively with Leiden
Execution flowsCall chains from entry points, sorted by weighted criticality
Community detectionLeiden clustering with resolution scaled to graph size
Architecture overviewCommunity-based architecture map with coupling warnings
Risk-scored reviewsdetect_changes maps diffs to affected functions, YAML and JSON paths, flows and test gaps
Custom languagesNew languages via .code-review-graph/languages.toml, no fork needed
GitHub ActionSticky risk-scored PR review comments in CI, with an optional fail-on-risk merge gate
Refactoring toolsRename preview, framework-aware dead code detection, community-driven suggestions
Wiki generationMarkdown wiki from community structure
Multi-repo registryRegister several repos and search across them
Multi-repo daemoncrg-daemon watches several repos as child processes, with health checks and restart
MCP prompts5 workflow templates: review, architecture, debug, onboard, pre-merge
Full-text searchFTS5 hybrid search combining keyword and vector similarity
Local storageOne SQLite file in .code-review-graph/; no external database or cloud service

</details>


Usage

Your assistant uses the graph by itself once it is built. Open a part below for skills, commands, MCP tools and settings.

<details> <summary><strong>Skills</strong></summary> <br>

install writes these four skills for the platforms that support them (Claude Code, Gemini CLI, CodeBuddy Code, Hermes Agent and Qoder). Ask for one by name.

SkillDescription
explore-codebaseNavigate and understand codebase structure using the knowledge graph
review-changesPerform a structured code review using change detection and impact
debug-issueSystematically debug issues using graph-powered code navigation
refactor-safelyPlan and execute safe refactoring using dependency analysis

Qoder also gets build-graph, review-delta and review-pr from the repository's skills/ directory.

</details>

<details> <summary><strong>CLI reference</strong></summary> <br>

code-review-graph install          # Detect and configure all platforms
code-review-graph install --platform <name>  # One platform
code-review-graph install --steering  # Claude Code: graph context beside each search and read
code-review-graph uninstall --dry-run  # Preview removal of installed artifacts
code-review-graph build            # Parse the whole codebase
code-review-graph build --follow-symlinks  # Also index symlinked folders
code-review-graph update           # Incremental update (changed files only)
code-review-graph status           # Graph statistics
code-review-graph watch            # Update on file changes
code-review-graph forget <path>    # Drop already-parsed files from the graph
code-review-graph dead-code        # Functions and classes with no callers or tests
code-review-graph query path_to <from> --to <to>  # How one symbol reaches another
code-review-graph impact --detail-level compact  # Blast radius as ranked file paths
code-review-graph visualize        # Interactive HTML graph
code-review-graph visualize --seed-symbol <name>  # Neighbourhood of one symbol
code-review-graph visualize --format json      # Export graph data as JSON
code-review-graph visualize --format graphml   # Export as GraphML
code-review-graph visualize --format svg       # Export as SVG (needs matplotlib)
code-review-graph visualize --format obsidian  # Export as Obsidian vault
code-review-graph visualize --format cypher    # Export as Neo4j Cypher
code-review-graph wiki             # Markdown wiki from communities
code-review-graph detect-changes --brief         # Risk panel + token savings (read-only)
code-review-graph detect-changes --brief --base main  # Against the merge base of main and HEAD
code-review-graph update --brief                 # Refresh graph + same panel
code-review-graph detect-changes --brief --verify  # Cross-check against tiktoken
code-review-graph detect-changes --details all  # Add graph context to the JSON
code-review-graph context-history  # Trend of the opt-in savings log (CRG_CONTEXT_HISTORY=1)
code-review-graph register <path>  # Register repo in the multi-repo registry
code-review-graph unregister <path|alias>  # Remove repo from the registry
code-review-graph repos            # List registered repositories
code-review-graph daemon start     # Start the multi-repo watch daemon
code-review-graph daemon stop      # Stop the daemon
code-review-graph daemon status    # Daemon status and repos
code-review-graph eval --all       # Run every evaluation benchmark
code-review-graph serve            # Start the MCP server (stdio)
code-review-graph serve --http     # MCP over Streamable HTTP on localhost:5555
code-review-graph serve --http --multi-repo  # One HTTP server for every registered repo
code-review-graph serve --multi-worktree  # One child server per linked Git worktree

This is a selection. code-review-graph --help lists every command, and docs/COMMANDS.md documents their flags.

When detect-changes --base names a branch, the diff runs against the merge base of that branch and HEAD. Commit hashes and other revisions are used as given.

visualize --format svg needs matplotlib, which ships in the eval extra (pip install "code-review-graph[eval]"). The other export formats need no extra install.

JSON exports are written inside the local graph data directory, which Git ignores by default. They can contain absolute paths and code-structure metadata, so inspect an export before publishing it.

</details>

<details> <summary><strong>Token Savings panel: <code>detect-changes --brief</code> vs <code>update --brief</code></strong></summary> <br>

Both commands print the same panel showing how many tokens the graph saved compared with handing the changed files to an agent raw. They differ in one thing: whether the graph is refreshed first.

┌─────────────────────── Token Savings ────────────────────────┐
│ Full context would be:     12,921 tokens                     │
│ Graph context used:           762 tokens                     │
│ Saved:                     12,159 tokens (~94%)              │
│ Breakdown: Functions 244 · Tests 191 · Risk 244 · Other 83   │
└──────────────────────────────────────────────────────────────┘
CommandWhat it doesWhen to use
detect-changes --briefRead-only. Queries the existing graph for the current changes and prints the panel.Most of the time; hooks or crg-daemon keep the graph fresh.
update --briefRe-parses the changed files into the graph first, then prints the same panel.After a rebase, a large change set, or whenever the graph may be stale.

Add --verify to either command to compare the figures with OpenAI's cl100k_base tokenizer (needs pip install tiktoken). The estimate is within about 1% of real tokens in aggregate; see docs/REPRODUCING.md.

The same context_savings metadata is attached to the JSON responses of the get_impact_radius, get_review_context, detect_changes and get_architecture_overview MCP tools.

To see these estimates over time, set CRG_CONTEXT_HISTORY=1 (off by default). Each estimate then adds one line to a local log next to graph.db, holding token counts, tool names, a timestamp, a detail level and file and depth counts, never file names, paths or source text, and code-review-graph context-history prints it per day or per tool. See docs/USAGE.md.

</details>

<details> <summary><strong>Multi-repo daemon</strong></summary> <br>

If install gives your editor no hooks (for example Windsurf or Zed), or you want the graph kept fresh without editor integration, the daemon watches your repositories and updates their graphs. It ships with code-review-graph; no separate install.

# 1. Register the repos to watch
crg-daemon add ~/project-a --alias proj-a
crg-daemon add ~/project-b

# 2. Start the daemon (runs in the background)
crg-daemon start

# 3. Check on it
crg-daemon status                 # daemon and per-repo watcher status
crg-daemon logs --repo proj-a -f  # tail logs for one repo
crg-daemon stop                   # stop the daemon and all watchers

Also available as code-review-graph daemon start|stop|status|....

crg-daemon add writes to ~/.code-review-graph/watch.toml, which you can also edit directly:

[[repos]]
path = "/home/user/project-a"
alias = "proj-a"

[[repos]]
path = "/home/user/project-b"
alias = "project-b"

The daemon watches this file and starts or stops watcher processes as repos are added or removed. A health check every 30 seconds restarts dead watchers.

See docs/COMMANDS.md for the full config reference.

</details>

<details> <summary><strong>30 MCP tools</strong></summary> <br>

The assistant uses these once the graph is built. The 25 tools that only read carry readOnlyHint: true, so a client can run them without asking; the five that write (build_or_update_graph_tool, run_postprocess_tool, embed_graph_tool, apply_refactor_tool, generate_wiki_tool) do not.

ToolDescription
build_or_update_graph_toolBuild or incrementally update the graph
run_postprocess_toolRe-run flow detection, community detection and FTS indexing
get_minimal_context_toolCompact context (~100 tokens); call this first
get_impact_radius_toolBlast radius of changed files; detail_level="compact" gives ranked file paths
get_review_context_toolReview context with structural summary
query_graph_toolCallers, callees, tests, imports, inheritance, and path_to between two symbols
traverse_graph_toolBFS/DFS traversal from any node with a token budget
semantic_search_nodes_toolSearch code entities by name or meaning
embed_graph_toolCompute vector embeddings for semantic search
list_graph_stats_toolGraph size and health
get_docs_section_toolRetrieve documentation sections
find_large_functions_toolFunctions, classes or files above a line-count threshold
list_flows_toolExecution flows sorted by criticality
get_flow_toolOne execution flow
get_affected_flows_toolFlows affected by changed files
list_communities_toolDetected code communities
get_community_toolOne community
get_architecture_overview_toolArchitecture overview from community structure
detect_changes_toolRisk-scored change impact analysis
get_hub_nodes_toolMost-connected nodes
get_bridge_nodes_toolChokepoints by betweenness centrality
get_knowledge_gaps_toolStructural weaknesses, untested hotspots and import cycles
get_surprising_connections_toolUnexpected cross-community coupling
get_suggested_questions_toolReview questions generated from the analysis
refactor_toolRename preview, dead code detection, suggestions
apply_refactor_toolApply a previously previewed refactoring
generate_wiki_toolMarkdown wiki from communities
get_wiki_page_toolOne wiki page
list_repos_toolRegistered repositories
cross_repo_search_toolSearch registered repositories; repos limits the search to a subset

MCP prompts (5 workflow templates): review_changes, architecture_map, debug_issue, onboard_developer, pre_merge_check

</details>

<details> <summary><strong>Configuration</strong></summary> <br>

To exclude paths from indexing, create a .code-review-graphignore file in the repository root:

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

In git repositories a build reads tracked files plus untracked files git does not ignore (git ls-files and git ls-files --others --exclude-standard), so gitignored files are skipped. Use .code-review-graphignore to exclude other files or when git is not available. The default ignore list is in docs/USAGE.md.

Optional dependency groups:

pip install "code-review-graph[embeddings]"          # Local vector embeddings (sentence-transformers)
pip install "code-review-graph[google-embeddings]"   # Google Gemini embeddings
pip install "code-review-graph[communities]"         # Community detection (igraph)
pip install "code-review-graph[enrichment]"          # Python call resolution with Jedi (then build --enrich)
pip install "code-review-graph[eval]"                # Evaluation benchmarks and SVG export (matplotlib)
pip install "code-review-graph[wiki]"                # ollama client (not used by the current wiki generator)
pip install "code-review-graph[all]"                 # All optional dependencies
Environment Variables
VariableDescriptionDefault
CRG_GIT_TIMEOUTTimeout in seconds for Git operations (build, update, watch)30
CRG_DISCOVERY_TIMEOUTTimeout in seconds for each Git command that discovers what changed, when a review tool or command was not given an explicit file list. Running out reports an error, never "no changes"5, or CRG_GIT_TIMEOUT when you set that explicitly
CRG_DATA_DIRDirectory for graph databases and generated artefacts-
CRG_HOOK_WORKTREESSet to 1 to let the generated git hooks run in linked git worktrees-
CRG_EMBEDDING_MODELDefault model for local vector embeddingsall-MiniLM-L6-v2
CRG_ACCEPT_CLOUD_EMBEDDINGSSet to 1 to suppress the cloud embedding egress warning-
CRG_ALLOW_REMOTE_CODEAllow HuggingFace models that require trust_remote_code=True0
CRG_VECTOR_CACHESet to 1 to keep the decoded embedding vectors in memory between semantic searches instead of reading them all back from SQLite on every query. Costs RAM (vectors × dimensions × 4 bytes per cached index) and one open read connection per cached database for the life of the process: on Windows, graph.db cannot be deleted or replaced while it is open-
CRG_MAX_IMPACT_NODESMaximum nodes in impact analysis500
CRG_MAX_IMPACT_DEPTHSearch depth for blast-radius analysis2
CRG_MAX_BFS_DEPTHMaximum depth for graph traversal15
CRG_MAX_CHANGED_FUNCSMaximum changed functions analysed in one change report500
CRG_MAX_DELETION_FILESMaximum files whose old version is read in one change report, to name the functions and classes a diff deleted100
CRG_MAX_CHANGED_YAML_PATHSMaximum changed YAML paths analysed in one change report, and separately the same number of JSON paths200
CRG_MAX_TRANSITIVE_FRONTIERMaximum callees followed per hop when tests_for and detect-changes look for tests. The first by name are kept, so one graph always gives one answer50
CRG_CALLER_TEST_ROUTE_DEPTHHops to walk up incoming CALLS when looking for a tested caller of an untested changed symbol. Reported as a note, never as coverage2
CRG_CALLER_TEST_ROUTE_MAX_CALLERSMaximum callers examined while looking for that tested caller500
CRG_TOOL_TIMEOUTTimeout in seconds for read-only MCP tools (0 disables). Does not bound the tools that write: build, postprocess, embed, wiki and apply-refactor0
CRG_CHURN_WINDOW_DAYSWindow for detect-changes --churn commit counts90
CRG_CONTEXT_HISTORYSet to 1 to keep a local log of each context_savings estimate in .code-review-graph/context-history.jsonl; read it with code-review-graph context-history. Holds token counts, tool names, a timestamp, a detail level and file and depth counts, never file names, paths or source text, and is never sent anywhere-
CRG_LEIDEN_SEEDSeed for Leiden community detection42
CRG_RECURSE_SUBMODULESInclude git submodules when set to 1, true or yes-
CRG_FOLLOW_SYMLINKSFollow symlinked folders, inside or outside the repository, when set to 1, true, yes or on; same as --follow-symlinks. See Symlinked folders-
CRG_MAX_FOLLOWED_FILESMost files taken through followed symlinked folders10000
CRG_TOOLSComma-separated allowlist of MCP tools to expose when serving-
GOOGLE_API_KEYAPI key for Google Gemini embeddings-
MINIMAX_API_KEYAPI key for MiniMax embeddings-
VOYAGE_API_KEYAPI key for Voyage embeddings-
CRG_VOYAGE_MODELModel for Voyage embeddingsvoyage-code-3
CRG_VOYAGE_OUTPUT_DIMENSIONOutput dimension for Voyage embeddings1024
CRG_VOYAGE_OUTPUT_DTYPEOutput dtype for Voyage embeddingsfloat
CRG_VOYAGE_BASE_URLVoyage embeddings endpointhttps://api.voyageai.com/v1
CRG_VOYAGE_BATCH_SIZEBatch size for Voyage requests100
CRG_VOYAGE_MIN_INTERVAL_SECMinimum delay between Voyage requests0
CRG_OPENAI_BASE_URLOpenAI-compatible embeddings endpoint-
CRG_OPENAI_API_KEYAPI key for OpenAI-compatible embeddings-
CRG_OPENAI_MODELModel for OpenAI-compatible embeddings-
CRG_OPENAI_DIMENSIONPin the embedding dimension (v3 models support reduction)-
CRG_OPENAI_BATCH_SIZEBatch size for OpenAI-compatible requests100
NO_COLORDisable ANSI colours in the terminal-
CRG_SERIAL_PARSESet to 1 to disable parallel parsing (for debugging)-
CRG_ENABLE_ENRICHMENTSet to 1 to resolve Python method calls with Jedi on every build and update (needs the enrichment extra; about a second more per Python file). Same as build --enrichoff
CRG_DISABLE_ENRICHMENTSet to 1 to never run Jedi, even when asked for-

OpenAI-compatible embeddings need no extra install. Set the variables and pass provider="openai" to embed_graph:

export CRG_OPENAI_BASE_URL=http://127.0.0.1:3000/v1     # or https://api.openai.com/v1
export CRG_OPENAI_API_KEY=sk-...
export CRG_OPENAI_MODEL=text-embedding-3-small          # whatever your gateway serves
# optional:
export CRG_OPENAI_DIMENSION=1536                        # pin dim (v3 models support reduction)
export CRG_OPENAI_BATCH_SIZE=100                        # lower for gateways with tight limits

The cloud-egress warning is skipped when the base URL points at localhost (127.0.0.1, localhost, 0.0.0.0, ::1).

Voyage embeddings need no extra install. Set VOYAGE_API_KEY and pass provider="voyage" to embed_graph; the default model is voyage-code-3:

export VOYAGE_API_KEY=pa-...
export CRG_ACCEPT_CLOUD_EMBEDDINGS=1
code-review-graph embed --provider voyage --model voyage-code-3

Model selection. Avoid -preview, -beta or -exp model IDs for an index you plan to keep; preview models can change weights (a different dimension forces a full re-embed) or be withdrawn. Prefer GA releases such as text-embedding-3-small / text-embedding-3-large (OpenAI) or gemini-embedding-001 (native Gemini provider, which needs GOOGLE_API_KEY).

The embedding text is identifiers, signatures, structural context, and a bounded first-paragraph docstring or doc-comment summary. Function bodies are not sent. Graphs created before documentation extraction was added need one full code-review-graph build before re-embedding. Routine builds never refresh embeddings; to refresh after a build, pass both --embedding-provider and --embedding-model. Cloud providers receive this source-derived text and may charge for it.

Tool Filtering

CRG exposes 30 MCP tools by default. To limit the server to a subset, use --tools or the CRG_TOOLS environment variable:

# CLI flag
code-review-graph serve --tools query_graph_tool,semantic_search_nodes_tool,detect_changes_tool

# Environment variable
CRG_TOOLS=query_graph_tool,semantic_search_nodes_tool code-review-graph serve

The flag takes precedence over the variable. When neither is set, all tools are available. In an MCP client config:

{
  "mcpServers": {
    "code-review-graph": {
      "command": "code-review-graph",
      "args": ["serve", "--tools", "query_graph_tool,semantic_search_nodes_tool,detect_changes_tool,get_review_context_tool"]
    }
  }
}

</details>


FAQ and comparisons

Answers in docs/FAQ.md:

<details> <summary><strong>How it compares with LSP, RAG and grep, when not to use it, and more</strong></summary> <br>

</details>

Troubleshooting

More cases, including Windows/WSL, are in docs/TROUBLESHOOTING.md.

pip / pipx cannot download hatchling (or Errno 9 / Bad file descriptor to PyPI)

<details> <summary><strong>How to fix it</strong></summary> <br>

Installing from a source tree (for example pipx install .) needs build dependencies from PyPI. If you see Could not find a version that satisfies the requirement hatchling after connection warnings, the Python in that terminal may not be able to open an HTTPS connection to pypi.org. This is seen most often in an editor's integrated terminal, and sometimes with a VPN, firewall or proxy.

  1. Run the same command from a terminal outside the editor, such as Terminal.app.

  2. Install from a checkout with uv, which uses different download machinery:

    cd /path/to/code-review-graph
    uv tool install . --force
  3. For development in a clone, use uv sync and uv run code-review-graph ....

To diagnose: python3 scripts/diagnose_pypi_connectivity.py. If it prints FAILED, the problem is the network environment, not the package name.

</details>

Windows: Invalid JSON: EOF while parsing or MCP error -32000: Connection closed

<details> <summary><strong>How to fix it</strong></summary> <br>

Do not use a cmd /c wrapper in the Claude Code config. Point ~/.claude.json at the .exe directly and set UTF-8 through the config:

"code-review-graph": {
  "command": "C:\\path\\to\\your\\venv\\Scripts\\code-review-graph.exe",
  "args": ["serve", "--repo", "C:\\path\\to\\your\\project"],
  "env": { "PYTHONUTF8": "1" }
}

</details>

Contributing

Pull requests target staging (the default branch). Changes are promoted staging → testing → main, and releases are tagged from main. No promotion is automatic: a person reviews and merges each one. See CONTRIBUTING.md for the full flow.

<details> <summary><strong>Set up a development copy and run the tests</strong></summary> <br>

git clone https://github.com/tirth8205/code-review-graph.git
cd code-review-graph
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

</details>

<details> <summary><strong>Add a built-in language</strong></summary> <br>

To add a built-in language, edit code_review_graph/parser.py: add the extension to EXTENSION_TO_LANGUAGE and node type mappings to _CLASS_TYPES, _FUNCTION_TYPES, _IMPORT_TYPES and _CALL_TYPES. Include a test fixture and open a PR. For a language you only need in one repository, use languages.toml instead.

</details>

Licence

MIT. See LICENSE.

<p align="center"> <br> <a href="https://code-review-graph.com">code-review-graph.com</a><br><br> <code>pip install code-review-graph && code-review-graph install</code> </p>

README.zh-CN.md

<h1 align="center">code-review-graph</h1>

<p align="center"> <a href="https://trendshift.io/repositories/23329?utm_source=repository-badge&amp;utm_medium=badge&amp;utm_campaign=badge-repository-23329" target="_blank" rel="noopener noreferrer"> <img src="https://trendshift.io/api/badge/repositories/23329" alt="tirth8205%2Fcode-review-graph | Trendshift" width="250" height="55" /> </a> </p>

<p align="center"> <strong>本地代码知识图谱,通过 MCP 为 AI 编码工具提供精准的审查上下文。</strong> </p> <p align="center"> <a href="README.md">English</a> | <a href="README.zh-CN.md">简体中文</a> | <a href="README.ja-JP.md">日本語</a> | <a href="README.ko-KR.md">한국어</a> | <a href="README.hi-IN.md">हिन्दी</a> </p>

<p align="center"> <a href="https://pypi.org/project/code-review-graph/"><img src="https://img.shields.io/pypi/v/code-review-graph?style=flat-square&color=blue" alt="PyPI"></a> <a href="https://pepy.tech/project/code-review-graph"><img src="https://img.shields.io/pepy/dt/code-review-graph?style=flat-square" alt="Downloads"></a> <a href="https://github.com/tirth8205/code-review-graph/stargazers"><img src="https://img.shields.io/github/stars/tirth8205/code-review-graph?style=flat-square" alt="Stars"></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="MIT Licence"></a> <a href="https://github.com/tirth8205/code-review-graph/actions/workflows/ci.yml"><img src="https://github.com/tirth8205/code-review-graph/actions/workflows/ci.yml/badge.svg?branch=staging" alt="CI"></a> <a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.10%2B-blue.svg?style=flat-square" alt="Python 3.10+"></a> <a href="https://modelcontextprotocol.io/"><img src="https://img.shields.io/badge/MCP-compatible-green.svg?style=flat-square" alt="MCP"></a> <a href="https://code-review-graph.com"><img src="https://img.shields.io/badge/website-code--review--graph.com-blue?style=flat-square" alt="Website"></a> <a href="https://discord.gg/3p58KXqGFN"><img src="https://img.shields.io/badge/discord-join-5865F2?style=flat-square&logo=discord&logoColor=white" alt="Discord"></a> </p>

<p align="center"> <a href="docs/USAGE.md">使用说明</a> · <a href="docs/COMMANDS.md">命令</a> · <a href="docs/FAQ.md">常见问题</a> · <a href="docs/TROUBLESHOOTING.md">故障排查</a> · <a href="docs/GITHUB_ACTION.md">GitHub Action</a> · <a href="docs/REPRODUCING.md">复现基准测试</a> · <a href="docs/ROADMAP.md">路线图</a> </p>

<br>

AI 编码工具为了审查一次改动,常常要重新读取代码库的大部分内容。code-review-graph 用 Tree-sitter 构建代码的结构图,增量保持更新,并通过 MCP 提供紧凑的上下文,让助手只读取改动涉及的文件。

<p align="center"> <img src="diagrams/diagram1_before_vs_after.png" alt="Token 问题:读完 flask 的全部语料需要 143,594 个 token,图给出的回答只需 2,196 个(少 65 倍)" width="85%" /> </p>

它能做什么

  • 为你的代码建图。 函数、类、导入、调用和测试组成一张图谱。

  • 指出一次改动可能弄坏什么。 它能波及的调用者、依赖方和测试,并附带风险评分。

  • 保持最新。 钩子和 watch 模式只重新解析变更的文件。

  • 配合你的 AI 工具。 一次 install 就能配置它找到的每个工具。

  • 留在你的机器上。 一个 SQLite 文件,没有云服务;云端嵌入需要主动开启。


快速开始

需要 Python 3.10+。

pip install code-review-graph          # or: pipx install code-review-graph
code-review-graph install              # detect installed AI coding tools and configure each one
code-review-graph build                # parse the codebase

<details> <summary><strong><code>install</code> 会改动什么,以及如何先预览</strong></summary> <br>

install 会检测你安装了哪些 AI 编码工具,为每个工具写入一条 MCP 服务器配置,在平台支持的地方安装钩子和技能,并把图谱说明加入平台的规则文件。在 Poetry 或 uv 项目环境中,MCP 配置使用 poetry run 或 uv run;当 PATH 上有 uvx 时使用 uvx code-review-graph serve;否则使用当前的 Python 解释器。install 会先列出要改动的文件,并在你回答它关于说明文件的问题之后才写入任何内容;install --dry-run 把每处改动显示为 diff,什么都不写。安装后请重启编辑器或工具。

install 写入的文件(例如 .claude/ 和 .mcp.json)对 git 仍然可见,以便你的团队提交它们。install --gitignore 会把本次运行新建的文件加入 .gitignore 中一个带标记的块;uninstall 会移除这个块。

对于 Codex,安装程序还会在 $CODEX_HOME/skills/code-review-graph/(默认: ~/.codex/skills/code-review-graph/)放置一个全局的 code-review-graph Skill。它优先使用 CRG MCP 工具, MCP 不可用时回退到随包提供的只读 CLI(read-only CLI);图谱缺失、为空或过期时,绝不会隐式触发构建或更新。 WSL 和 Windows 上的 Codex 运行环境各有自己的 CODEX_HOME 目录和工具清单, 所以请在实际执行任务的那个运行环境中安装和刷新。

</details>

<details> <summary><strong>所有支持的平台,以及如何只配置其中一个</strong></summary> <br>

<p align="center"> <img src="diagrams/diagram8_supported_platforms.png" alt="一次安装,覆盖所有平台:检测 Codex、Claude Code、CodeBuddy Code、Cursor、Windsurf、Zed、Continue、OpenCode、MiMo Code、Antigravity、Gemini CLI、Qwen Code、Qoder、Kiro、GitHub Copilot、GitHub Copilot CLI、Hermes Agent 和 DeepSeek Harness" width="85%" /> </p>

只配置一个平台时,给 --platform 传入 codex、claude-code、cursor、windsurf、zed、continue、opencode、mimo、antigravity、gemini-cli、qwen、kiro、qoder、copilot、copilot-cli、codebuddy、hermes 或 dsh 之一:

code-review-graph install --platform cursor
code-review-graph install --platform codebuddy

配置文件的位置列在 docs/USAGE.md 中。需要 Python 3.10+。

</details>

<details> <summary><strong>用 <code>uninstall</code> 再次移除</strong></summary> <br>

uninstall 会从 Git 或 SVN 工作树中移除 CRG 自己写入的文件和配置项,不动其他 MCP 服务器、钩子、技能和 JSONC 注释。在工作树内的任意位置运行即可。共享配置文件采用原子替换,写入失败时原文件保持完整。

code-review-graph uninstall --dry-run    # preview only
code-review-graph uninstall              # preview, confirm, apply
code-review-graph uninstall --yes        # apply without prompting
code-review-graph uninstall --all-repos  # also clean every registered repository
code-review-graph uninstall --keep-data  # remove integrations, keep graph databases
code-review-graph uninstall --keep-user-configs --repo .  # this project only

</details>

运行 install 后请重启编辑器或工具。 然后打开项目,对助手说:

Build the code review graph for this project

<details> <summary><strong>构建需要多久,以及部分构建是什么意思</strong></summary> <br>

构建时间随仓库规模增长;一个约 3,000 个文件的仓库冷构建约需 40 秒(实测)。之后由钩子和 watch 模式保持图谱更新。如果部分文件解析失败,结果状态为 partial 并在摘要中列出这些文件;CLI 还会在 stderr 上打印一行 Warning:,这些文件保留原有的图谱记录。

</details>

使用 Docker 或 Podman 运行

<details> <summary><strong>构建镜像,然后在你的仓库上运行</strong></summary> <br>

在本仓库根目录构建镜像:

docker build -t code-review-graph:local .

在要分析的仓库目录中运行:

docker run --rm \
  --user "$(id -u):$(id -g)" \
  --env HOME=/tmp \
  --volume "$PWD:/workspace" \
  code-review-graph:local build

挂载的仓库必须可写。上述命令使用你的用户 ID 和组 ID, 使生成的 .code-review-graph/ 目录仍归你的用户所有。 请以非 root 主机用户运行这些命令。

使用 Podman 时,构建同一个 Dockerfile 并保留用户映射:

podman build -t code-review-graph:local .
podman run --rm \
  --userns=keep-id \
  --env HOME=/tmp \
  --volume "$PWD:/workspace" \
  code-review-graph:local build

图会保存在挂载仓库的 .code-review-graph/ 中,并记录 /workspace/app.py 等容器内的绝对路径。 请通过 Docker 或 Podman 使用相同的 /workspace 挂载路径运行 update 和 detect-changes。 在宿主机上对该图运行 update 可能会报错 "built with a different repository root"。 如需改用宿主机命令,请先在宿主机上运行 code-review-graph build,使用宿主机路径重新构建图。

将 build 替换为 status 可查看已保存的图。 镜像包含 Git,默认以非 root 用户运行。 构建镜像时不会生成图。

这些示例使用 macOS/Linux shell 语法。在 macOS 上, 运行前请启动兼容 Docker 的容器引擎或 Podman 虚拟机。 在启用 SELinux 的主机(如 Fedora)上,请在挂载中加上 :z("$PWD:/workspace:z"),否则容器无法访问仓库。

</details>

工作原理

仓库通过 Tree-sitter 解析为 AST,并以节点(函数、类、导入)和边(调用、继承、测试覆盖)的形式存为图谱。审查时查询图谱,得到助手需要读取的最小文件集合。

<details> <summary><strong>两张图:助手如何使用图谱,以及构建流程</strong></summary> <br>

<p align="center"> <img src="diagrams/diagram7_mcp_integration_flow.png" alt="助手如何使用图谱:用户请求审查,助手调用 MCP 工具,图谱返回影响半径和风险评分,助手只读取受影响的文件" width="80%" /> </p>

<p align="center"> <img src="diagrams/diagram2_architecture_pipeline.png" alt="架构流程:仓库 → Tree-sitter 解析器 → SQLite 图谱 → 影响半径 → 最小审查集" width="100%" /> </p>

</details>

影响半径分析

<details> <summary><strong>一次改动可能影响的每个调用者、依赖方和测试</strong></summary> <br>

文件变更时,图谱会追踪所有可能受影响的调用者、依赖方和测试。助手读取这些文件,而不是扫描整个项目。

<p align="center"> <img src="diagrams/diagram3_blast_radius.png" alt="影响半径:login() 的改动传播到调用者、依赖方和测试" width="70%" /> </p>

</details>

增量更新

<details> <summary><strong>只重新解析变更的文件(修改两个文件约 2.5 秒)</strong></summary> <br>

编辑器钩子、git 钩子(pre-commit、post-checkout、post-merge、post-rewrite)和 watch 模式都会触发增量更新。更新时对变更文件做 diff,沿图谱的导入边和调用边找出依赖方,并只重新解析 SHA-256 哈希发生变化的文件。在一个约 3,000 个文件的项目(django)上,修改两个文件后沿钩子路径重新索引约需 2.5 秒,其中约 1.4 秒是进程启动;空更新只花这段启动时间。参见增量更新延迟。

<p align="center"> <img src="diagrams/diagram4_incremental_update.png" alt="增量更新流程:钩子或 watch 更新触发 git diff,通过图谱的边找到依赖方,只重新解析 SHA-256 哈希发生变化的文件" width="90%" /> </p>

</details>

整个代码库,还是有的放矢的回答?

<details> <summary><strong>按问题裁剪的图谱切片,而不是整个代码库</strong></summary> <br>

图谱不会把整个语料喂给模型,而是返回按问题裁剪的切片。在 2026-08-02 对本仓库 84bde354 的快照中,208,821 个源码 token 变成每个问题约 3,190 个 token。此后仓库增长了很多,所以今天这两个数字都更大。

<p align="center"> <img src="diagrams/diagram6_monorepo_funnel.png" alt="code-review-graph 在 84bde354 快照:208,821 个源码 token 收敛为约 3,190 token 的图谱响应,每个问题的 token 约少 65 倍" width="80%" /> </p>

</details>

语言覆盖与笔记本

<details> <summary><strong>Python、JavaScript、TypeScript、Go、Rust、Java、C/C++、C# 等众多语言,外加笔记本:完整列表</strong></summary> <br>

<p align="center"> <img src="diagrams/diagram9_language_coverage.png" alt="按类别划分的语言覆盖:Web、后端、系统、移动端、脚本、Shell、领域专用、配置和其他,外加 Jupyter 和 Databricks 笔记本" width="90%" /> </p>

解析器提取函数、类、导入、调用点、继承和测试:有语法的地方用 Tree-sitter,其他地方用有针对性的回退解析。支持范围:Python、JavaScript/TypeScript/TSX(包括 .mjs、.cjs、.mts 和 .cts)、Go、Rust、Java、C/C++、C#、VB.NET、Ruby、Kotlin(.kt、.kts)、Swift、PHP、Scala、Solidity、Dart、R、Perl、Lua/Luau、Objective-C、shell 脚本、Elixir、Zig、PowerShell、Julia、ReScript、GDScript、Nix、Verilog/SystemVerilog、SQL/PL/SQL(Oracle)和 dbt 模型、Terraform/OpenTofu(.tf,以及 .hcl 文件中的 Terraform 块;不含 Terraform 块的 .hcl 文件只保留文件节点)、Ansible YAML(playbook、role、task)、Spring Boot 应用配置(application.properties、application.yml、application.yaml 及其 application-<profile> 变体;只记录键名和值的类型,绝不记录值)、不含值的通用 YAML 结构(locales/ 等文件夹中的翻译文件只生成文件节点)、XSLT 样式表(.xsl、.xslt)、不含值的 JSON 结构(.json;翻译、测试、文档、示例和数据文件只保留文件节点,锁文件会被跳过)、Vue/Svelte 单文件组件、HTML 页面(.html、.htm;内联脚本,以及带 id 的 div、section 和 article 块作为 DocSection 节点)、Astro 文件(用 TypeScript 语法解析)、Jupyter 和 Databricks 笔记本(.ipynb,以及 Databricks 导出的 .py 文件)、Perl XS 文件(.xs)、Robot Framework 文件(.robot、.resource),以及 Liquid 模板(.liquid)。其他 .properties 文件不被当作源代码。

PHP 项目还会得到仓库范围内的 Composer PSR-4 解析、Blade 模板引用,以及在源码中出现明确的框架导入、模型继承和接收者证据时生成的 Laravel Route 与 Eloquent 边。routes/*.php 中的静态 Laravel 路由会生成 Endpoint 节点和指向控制器的 HANDLES 边,包括字面量的路由组前缀。

Java 项目会得到 Spring 依赖注入的调用解析、请求端点与 WebFlux 路由、定时触发器、应用事件的发布者到监听者的边、Spring AOP 通知到目标的边,以及 Temporal 工作流与活动的边。每个解析器都在解析之后运行,并且需要被注入的字段、发布的事件或工作流 stub 在仓库中可见。

</details>

添加你自己的语言

<details> <summary><strong>在 <code>languages.toml</code> 中把文件扩展名映射到自带的 Tree-sitter 语法</strong></summary> <br>

如果你的仓库使用了解析器尚未覆盖的语言,在 .code-review-graph/ 中添加一个 languages.toml,把文件扩展名映射到 tree_sitter_language_pack 中自带的任意语法,并给出函数、类、导入和调用的节点类型:

[languages.erlang]
extensions = [".erl"]
grammar = "erlang"
function_node_types = ["function_clause"]
class_node_types = ["record_decl"]
import_node_types = ["import_attribute"]
call_node_types = ["call"]

提取工作由通用的 tree-sitter 遍历器完成。内置语言不能被覆盖。schema、校验规则和完整示例见 docs/CUSTOM_LANGUAGES.md。

</details>

在 CI 中做风险评分的 PR 审查(GitHub Action)

<details> <summary><strong>一条 pull request 评论,列出风险评分、受影响的执行流和测试缺口;见示例工作流</strong></summary> <br>

同样的分析也以组合式 GitHub Action 的形式运行。图谱在你的 CI runner 上构建和查询,不会把源代码发送给外部服务。每个 pull request 上,该 action 会发布一条常驻评论,列出风险评分的函数、受影响的执行流和测试缺口,并在每次推送时就地更新。可选的 fail-on-risk 输入可以把它变成合并门禁。可选的 details 输入会加入更多图谱上下文,默认折叠并限制大小:每个排名靠前的符号为什么得到这个分数、改动涉及的社区、枢纽和跨边界连接、它的影响半径、未测试的热点,以及图谱的来源。

# .github/workflows/code-review-graph.yml
on:
  pull_request:

permissions:
  contents: read
  pull-requests: write

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: tirth8205/[email protected]
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

输入参数、风险等级和缓存见 docs/GITHUB_ACTION.md,本仓库自己运行的工作流见 .github/workflows/pr-review.yml。

</details>


基准测试

6 个仓库上每个问题的 token 减少中位数约为 63 倍(全语料基线对比图谱查询)。358 倍的最大值只属于一个仓库(fastapi,语料最大),不是典型结果。

<details> <summary><strong>基准测试总览图,以及这些数字是怎么得出的</strong></summary> <br>

<p align="center"> <img src="diagrams/diagram5_benchmark_board.png" alt="6 个仓库的基准测试:每个问题的 token 减少中位数约 63 倍(最高 358 倍),对图谱生成的基准答案平均影响 F1 为 0.69" width="85%" /> </p>

所有数字都来自针对 6 个开源仓库(13 次提交)的评估运行器。每个配置都固定了上游 SHA,Leiden 使用固定随机种子,嵌入在 CPU 上是确定性的,因此不同机器上的两次运行得到相同的数字。复现步骤见 docs/REPRODUCING.md。在两个最小配置上每周运行一次、只出报告的评估位于 .github/workflows/eval.yml。

</details>

<details> <summary><strong>Token 效率:每个问题减少中位数约 63 倍(范围 35 倍到 358 倍;全语料对比图谱查询)</strong></summary> <br>

对于典型的智能体问题("how does authentication work"、"what is the main entry point" 等),图谱返回约 2,200 到 3,900 个 token 的搜索命中加邻接边,而不是每一个源文件。表格对 code_review_graph/token_benchmark.py 中定义的 5 个样例问题取平均。

仓库快照 SHAnaive_corpus_tokensavg graph_tokens减少倍数
fastapi22381558948,7932,653357.6x
flaska29f88ce143,5942,19665.4x
code-review-graph84bde354208,8213,19065.5x
gin5c00df8a166,8682,76660.3x
httpxb55d4635142,3562,66153.5x
expressb4ab7d65136,0523,93634.6x

2026-08-02 从固定 SHA 的干净克隆中采集(crg 2.3.7,本地 all-MiniLM-L6-v2 嵌入)。这些数字低于它们取代的 2026-05-25 采集:节点嵌入文本变得更丰富,因此每个仓库的 avg graph_tokens 都上升了。fastapi 按当前固定的 22381558 测量,而不是已退役的 0227991a。

减少倍数一列是 naive_corpus_tokens / avg graph_tokens,因此可以由旁边两列直接除出来。基准测试自己的 average_reduction_ratio 取的是五个问题各自比率的平均值,那个值总是更高;每个问题的数字见 docs/REPRODUCING.md。

code-review-graph 这一行是快照,不是当前测量值。仓库自 84bde354 以来有所增长,其语料和图谱今天都大得多。

全语料基线是任何真实智能体都不会付出的上限;智能体会 grep 标识符并读取最匹配的文件。agent_baseline 评估基准测量的就是这种情况(纯 Python 对语料做 grep,按匹配数取前 3 个文件,再与图谱查询开销做 token 对比)。在这一更贴近现实的基线下,6 个仓库 18 个问题的中位数是 6.65x(均值 14.8x,范围 4.2x 到 72.6x),采集于 2026-09-22,早于搜索和此基线开始降低测试文件排名,因此在重新采集之前,code-review-graph eval --benchmark agent_baseline --embed 会给出不同的数字。完整表格见 docs/REPRODUCING.md 的“Canonical capture, 2026-09-22”一节。

该比值随仓库规模变化:图谱答案的体量保持稳定(本次测量的所有仓库均为 2,432 到 4,021 tokens),而 grep 基线随语料增长,因此 express 为 4.5x,fastapi 为 52x。两个数字衡量的都是检索成本,即定位答案所需的 token。若智能体随后仍去读取图谱指出的文件,图谱开销就是叠加而非替代;semantic_search_nodes_tool(include_source=True) 会连同位置一并返回代码,使其不必再读,而端到端地测量这条路径仍是待办工作。

正式的 token_efficiency 基准测量的是另一个场景:完整的 get_review_context() JSON 对比一次提交中仅变更文件的内容;对于小提交,它报告的比率低于 1,因为响应里带有影响半径的边和源码片段。这两个基准回答的是不同的问题,见 docs/REPRODUCING.md。

审查和影响类工具会在响应中附带紧凑的 context_savings 估算。CLI 在 Token Savings 面板中显示同样的数字(见下文使用方式),--verify 会把它们与 OpenAI 的 cl100k_base 分词器做对比。在 222 个样本文件上的校准表明,总体估算与真实 token 的偏差约在 1% 以内(数据)。

</details>

<details> <summary><strong>影响准确度:对图谱生成的基准答案平均 F1 为 0.69(召回率 1.0 是循环论证得出的上限)</strong></summary> <br>

在全部 13 次评估提交上,影响半径分析都找回了基准答案中的每一个文件。请把它读作上限,而不是"100% 召回":基准答案(变更文件加上有调用边或导入边指向它们的文件)来自预测器所遍历的同一张图谱。较低的精确率是有意为之;多标一个文件的代价小于漏掉一个被破坏的依赖。

仓库提交数平均 F1平均精确率召回率(图谱生成的上限)
httpx20.8630.7851.0
code-review-graph20.7340.5841.0
fastapi20.6970.5391.0
express20.6670.5001.0
flask20.6330.4851.0
gin30.6090.4391.0
平均130.6930.5461.000

此表来自 2026-08-02 的采集,早于下文所述的路径修复。那个 bug 也让真实的相邻文件没能进入图谱生成的基准答案,所以重新运行基准后这些数字会变化。

该基准还会运行一种共变更模式:给预测器一个变更文件作为种子,再用作者在同一次提交中改动的其他文件来评分,这是来自 git 历史而非图谱的证据。两种模式都出现在结果 CSV 中(ground_truth_mode 列)。在 2026-08-02 的采集中,共变更模式在每个被评分的提交上都返回 predicted_files = 0,代码种子也不例外(例如 code_review_graph/cli.py 和 gin 的 context.go)。原因是基准中的一个路径 bug:git diff 给出相对仓库的路径,而图谱存储的是绝对路径,所以种子从未匹配到任何节点。这个 bug 现已修复,但基准还没有重新运行,因此不引用任何共变更数字。

</details>

<details> <summary><strong>构建统计</strong></summary> <br>

来自上文固定 SHA 的同一次 2026-08-02 干净构建。嵌入数量低于节点数量,因为 File 节点不做嵌入。code-review-graph 这一行是那个快照,不是仓库现在的状态。

仓库节点边嵌入
fastapi6,28732,0365,159
express1,99019,4921,849
gin1,58917,2371,491
code-review-graph1,4469,0941,354
flask1,4158,2591,329
httpx1,2638,2361,193

</details>

局限

<details> <summary><strong>五个已知局限:循环论证的召回率、小改动、搜索排序、执行流检测、误报</strong></summary> <br>

  • 影响分析的"召回率 1.0"是循环论证。 历史基准答案来自预测器所遍历的同一批图谱边,因此按构造它就是一个上限。在带着路径修复重新运行基准之前,不引用共变更数字。

  • 小的单文件改动。 对于琐碎的编辑,图谱上下文可能比直接读文件还大。多出来的是让多文件分析成为可能的结构化元数据。

  • 搜索排序。 关键词搜索通常能把正确结果排在靠前位置,但排序还需要改进。由于模块模式的命名方式,针对 Express 的查询可能返回零命中。

  • 执行流检测。 入口点检测对 Python 和 PHP/Laravel 最强。JavaScript 和 Go 的流检测还需要改进。

  • 精确率与召回率。 影响分析偏保守。它会标出可能受影响的文件,这意味着在大型依赖图中会出现误报。

</details>


功能

更新、影响分析、搜索、可视化、CI 审查、重构和多仓库支持,全部留在你的机器上。

<details> <summary><strong>完整功能表</strong></summary> <br>

功能说明
增量更新只重新解析哈希发生变化的文件。在一个约 3,000 个文件的仓库上,修改两个文件沿钩子路径约需 2.5 秒(实测)。
语言与笔记本支持见上文语言覆盖。
框架感知的 PHP 解析仓库范围内的 Composer PSR-4 导入、Blade 模板引用、有证据支撑的 Laravel Route 到控制器以及 Eloquent 关系边
框架感知的 Java 解析Spring 依赖注入的调用解析、请求端点与 WebFlux 路由、定时触发器、应用事件的发布者到监听者的边、Spring AOP 通知边、Temporal 工作流与活动的边,以及只索引键名不索引值的 Spring Boot 配置键
影响半径分析一次改动可能影响哪些函数、类和文件
自动更新钩子编辑器钩子、git 钩子(每次提交前,以及 checkout、merge 和 rebase 之后)和 watch 模式在你工作时更新图谱
语义搜索可选的向量嵌入,通过 sentence-transformers、Google Gemini、MiniMax、Voyage AI,或任何 OpenAI 兼容端点
交互式可视化D3.js 力导向图,支持搜索、社区图例开关和按度数缩放的节点,还有以某个符号、文件、执行流或改动为种子的邻域视图
枢纽与桥接检测连接最多的节点和瓶颈点(介数中心性)
意外度评分意外耦合:跨社区、跨语言、外围到枢纽的边
知识缺口分析孤立节点、未测试的热点、稀薄的社区、导入环
建议问题从桥接点、枢纽和意外耦合生成的审查问题
边置信度四级置信度(EXTRACTED、INFERRED、AMBIGUOUS、UNRESOLVED),边上带浮点分数,图谱无法绑定的调用会如实标明
图谱遍历从任意节点出发的 BFS/DFS,深度和 token 预算可配置;path_to 显示一个符号如何到达另一个符号,并指出最弱的一跳
导出格式GraphML、Neo4j Cypher、Obsidian 知识库、JSON,以及 SVG(SVG 需要 eval 附加依赖中的 matplotlib)
Token 基准测试code_review_graph/token_benchmark.py 按问题测量全语料 token 与图谱查询 token
估算的上下文节省在审查、影响、detect-changes 和架构响应上附带 context_savings 元数据(estimated、saved_tokens、saved_percent)
社区自动拆分占图谱 25% 以上的社区用 Leiden 递归拆分
执行流从入口点出发的调用链,按加权关键度排序
社区检测Leiden 聚类,分辨率随图谱规模调整
架构概览基于社区结构的架构图,附带耦合警告
风险评分审查detect_changes 把 diff 映射到受影响的函数、YAML 和 JSON 路径、执行流和测试缺口
自定义语言通过 .code-review-graph/languages.toml 添加新语言,无需 fork
GitHub Action在 CI 中发布常驻的风险评分 PR 审查评论,可选 fail-on-risk 合并门禁
重构工具重命名预览、框架感知的死代码检测、基于社区的建议
Wiki 生成从社区结构生成 Markdown Wiki
多仓库注册表注册多个仓库并跨仓库搜索
多仓库守护进程crg-daemon 以子进程方式监视多个仓库,带健康检查和重启
MCP 提示模板5 个工作流模板:审查、架构、调试、入职、合并前检查
全文搜索FTS5 混合搜索,结合关键词与向量相似度
本地存储.code-review-graph/ 中的一个 SQLite 文件;没有外部数据库或云服务

</details>


使用方式

图谱构建好后,助手会自己使用它。展开下面各部分,查看技能、命令、MCP 工具和设置。

<details> <summary><strong>技能</strong></summary> <br>

install 会为支持技能的平台(Claude Code、Gemini CLI、CodeBuddy Code、Hermes Agent 和 Qoder)写入以下四个技能。按名字调用即可。

技能说明
explore-codebase使用知识图谱浏览并理解代码库结构
review-changes用变更检测与影响分析做结构化的代码审查
debug-issue借助图谱驱动的代码导航系统性地排查问题
refactor-safely用依赖分析规划并执行安全的重构

Qoder 还会从本仓库的 skills/ 目录得到 build-graph、review-delta 和 review-pr。

</details>

<details> <summary><strong>CLI 参考</strong></summary> <br>

code-review-graph install          # Detect and configure all platforms
code-review-graph install --platform <name>  # One platform
code-review-graph install --steering  # Claude Code: graph context beside each search and read
code-review-graph uninstall --dry-run  # Preview removal of installed artifacts
code-review-graph build            # Parse the whole codebase
code-review-graph build --follow-symlinks  # Also index symlinked folders
code-review-graph update           # Incremental update (changed files only)
code-review-graph status           # Graph statistics
code-review-graph watch            # Update on file changes
code-review-graph forget <path>    # Drop already-parsed files from the graph
code-review-graph dead-code        # Functions and classes with no callers or tests
code-review-graph query path_to <from> --to <to>  # How one symbol reaches another
code-review-graph impact --detail-level compact  # Blast radius as ranked file paths
code-review-graph visualize        # Interactive HTML graph
code-review-graph visualize --seed-symbol <name>  # Neighbourhood of one symbol
code-review-graph visualize --format json      # Export graph data as JSON
code-review-graph visualize --format graphml   # Export as GraphML
code-review-graph visualize --format svg       # Export as SVG (needs matplotlib)
code-review-graph visualize --format obsidian  # Export as Obsidian vault
code-review-graph visualize --format cypher    # Export as Neo4j Cypher
code-review-graph wiki             # Markdown wiki from communities
code-review-graph detect-changes --brief         # Risk panel + token savings (read-only)
code-review-graph detect-changes --brief --base main  # Against the merge base of main and HEAD
code-review-graph update --brief                 # Refresh graph + same panel
code-review-graph detect-changes --brief --verify  # Cross-check against tiktoken
code-review-graph detect-changes --details all  # Add graph context to the JSON
code-review-graph context-history  # Trend of the opt-in savings log (CRG_CONTEXT_HISTORY=1)
code-review-graph register <path>  # Register repo in the multi-repo registry
code-review-graph unregister <path|alias>  # Remove repo from the registry
code-review-graph repos            # List registered repositories
code-review-graph daemon start     # Start the multi-repo watch daemon
code-review-graph daemon stop      # Stop the daemon
code-review-graph daemon status    # Daemon status and repos
code-review-graph eval --all       # Run every evaluation benchmark
code-review-graph serve            # Start the MCP server (stdio)
code-review-graph serve --http     # MCP over Streamable HTTP on localhost:5555
code-review-graph serve --http --multi-repo  # One HTTP server for every registered repo
code-review-graph serve --multi-worktree  # One child server per linked Git worktree

这是一份精选列表。code-review-graph --help 会列出全部命令,docs/COMMANDS.md 记录了它们的参数。

当 detect-changes --base 指定的是一个分支时,diff 会针对该分支与 HEAD 的合并基做。提交哈希和其他 revision 按原样使用。

visualize --format svg 需要 matplotlib,它随 eval 附加依赖提供(pip install "code-review-graph[eval]")。其他导出格式无需额外安装。

JSON 导出写在本地图谱数据目录中,该目录默认被 Git 忽略。导出内容可能包含绝对路径和代码结构元数据,发布前请先检查。

</details>

<details> <summary><strong>Token Savings 面板:<code>detect-changes --brief</code> 对比 <code>update --brief</code></strong></summary> <br>

两个命令打印同一个面板,显示相比把变更文件原样交给智能体,图谱节省了多少 token。它们只有一点不同:是否先刷新图谱。

┌─────────────────────── Token Savings ────────────────────────┐
│ Full context would be:     12,921 tokens                     │
│ Graph context used:           762 tokens                     │
│ Saved:                     12,159 tokens (~94%)              │
│ Breakdown: Functions 244 · Tests 191 · Risk 244 · Other 83   │
└──────────────────────────────────────────────────────────────┘
命令作用何时使用
detect-changes --brief只读。针对当前改动查询已有图谱并打印面板。大多数时候;钩子或 crg-daemon 会保持图谱新鲜。
update --brief先把变更文件重新解析进图谱,再打印同样的面板。rebase 之后、改动集很大时,或图谱可能已过期时。

给任一命令加上 --verify,可以把数字与 OpenAI 的 cl100k_base 分词器做对比(需要 pip install tiktoken)。总体估算与真实 token 的偏差约在 1% 以内;见 docs/REPRODUCING.md。

同样的 context_savings 元数据也附在 get_impact_radius、get_review_context、detect_changes 和 get_architecture_overview 这几个 MCP 工具的 JSON 响应上。

若想查看这些估算随时间的变化,设置 CRG_CONTEXT_HISTORY=1(默认关闭)。之后每次估算都会在 graph.db 旁的本地日志中追加一行,含 token 数、工具名、时间戳、详细级别以及文件数和深度,从不含文件名、路径或源代码;code-review-graph context-history 按天或按工具打印。见 docs/USAGE.md。

</details>

<details> <summary><strong>多仓库守护进程</strong></summary> <br>

如果 install 没有为你的编辑器安装钩子(例如 Windsurf 或 Zed),或者你想在没有编辑器集成的情况下保持图谱新鲜,守护进程会监视你的仓库并更新它们的图谱。它随 code-review-graph 一起提供,无需单独安装。

# 1. Register the repos to watch
crg-daemon add ~/project-a --alias proj-a
crg-daemon add ~/project-b

# 2. Start the daemon (runs in the background)
crg-daemon start

# 3. Check on it
crg-daemon status                 # daemon and per-repo watcher status
crg-daemon logs --repo proj-a -f  # tail logs for one repo
crg-daemon stop                   # stop the daemon and all watchers

也可以用 code-review-graph daemon start|stop|status|...。

crg-daemon add 写入 ~/.code-review-graph/watch.toml,你也可以直接编辑该文件:

[[repos]]
path = "/home/user/project-a"
alias = "proj-a"

[[repos]]
path = "/home/user/project-b"
alias = "project-b"

守护进程会监视这个文件,并随着仓库的增删启动或停止 watcher 进程。每 30 秒一次的健康检查会重启已死的 watcher。

完整配置参考见 docs/COMMANDS.md。

</details>

<details> <summary><strong>30 个 MCP 工具</strong></summary> <br>

图谱构建完成后,助手会使用这些工具。只读的 25 个工具带有 readOnlyHint: true,客户端可以不经询问直接运行;会写入的五个(build_or_update_graph_tool、run_postprocess_tool、embed_graph_tool、apply_refactor_tool、generate_wiki_tool)则没有。

工具说明
build_or_update_graph_tool构建或增量更新图谱
run_postprocess_tool重新运行执行流检测、社区检测和 FTS 索引
get_minimal_context_tool紧凑上下文(约 100 token);先调用这个
get_impact_radius_tool变更文件的影响半径;detail_level="compact" 给出排好序的文件路径
get_review_context_tool带结构摘要的审查上下文
query_graph_tool调用者、被调用者、测试、导入、继承查询,以及两个符号之间的 path_to
traverse_graph_tool从任意节点出发的 BFS/DFS 遍历,带 token 预算
semantic_search_nodes_tool按名称或语义搜索代码实体
embed_graph_tool计算用于语义搜索的向量嵌入
list_graph_stats_tool图谱规模与健康状况
get_docs_section_tool获取文档章节
find_large_functions_tool超过行数阈值的函数、类或文件
list_flows_tool按关键度排序的执行流
get_flow_tool单个执行流
get_affected_flows_tool受变更文件影响的执行流
list_communities_tool检测到的代码社区
get_community_tool单个社区
get_architecture_overview_tool基于社区结构的架构概览
detect_changes_tool风险评分的变更影响分析
get_hub_nodes_tool连接最多的节点
get_bridge_nodes_tool按介数中心性得出的瓶颈点
get_knowledge_gaps_tool结构性弱点、未测试的热点和导入环
get_surprising_connections_tool意外的跨社区耦合
get_suggested_questions_tool由分析生成的审查问题
refactor_tool重命名预览、死代码检测、建议
apply_refactor_tool应用先前预览的重构
generate_wiki_tool从社区生成 Markdown Wiki
get_wiki_page_tool单个 Wiki 页面
list_repos_tool已注册的仓库
cross_repo_search_tool搜索已注册的仓库;repos 可把搜索限定到一个子集

MCP 提示模板(5 个工作流模板): review_changes、architecture_map、debug_issue、onboard_developer、pre_merge_check

</details>

<details> <summary><strong>配置</strong></summary> <br>

要把某些路径排除在索引之外,在仓库根目录创建 .code-review-graphignore 文件:

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

在 git 仓库中,构建会读取被跟踪的文件,以及未被 git 忽略的未跟踪文件(git ls-files 和 git ls-files --others --exclude-standard),因此被 gitignore 的文件会跳过。用 .code-review-graphignore 来排除其他文件,或在没有 git 时使用。默认忽略列表见 docs/USAGE.md。

可选依赖组:

pip install "code-review-graph[embeddings]"          # Local vector embeddings (sentence-transformers)
pip install "code-review-graph[google-embeddings]"   # Google Gemini embeddings
pip install "code-review-graph[communities]"         # Community detection (igraph)
pip install "code-review-graph[enrichment]"          # Python call resolution with Jedi (then build --enrich)
pip install "code-review-graph[eval]"                # Evaluation benchmarks and SVG export (matplotlib)
pip install "code-review-graph[wiki]"                # ollama client (not used by the current wiki generator)
pip install "code-review-graph[all]"                 # All optional dependencies
环境变量
变量说明默认值
CRG_GIT_TIMEOUTGit 操作的超时秒数(build / update / watch)30
CRG_DISCOVERY_TIMEOUT审查工具或命令未显式给出文件清单时,用于识别变更的每个 Git 命令的超时秒数。超时会返回错误,而不会报告“没有变更”5(显式设置 CRG_GIT_TIMEOUT 时取该值)
CRG_DATA_DIR存放图谱数据库和生成产物的目录-
CRG_HOOK_WORKTREES设为 1 时允许生成的 git 钩子在链接的 git worktree 中运行-
CRG_EMBEDDING_MODEL本地向量嵌入的默认模型all-MiniLM-L6-v2
CRG_ACCEPT_CLOUD_EMBEDDINGS设为 1 可抑制云端嵌入的出网警告-
CRG_ALLOW_REMOTE_CODE允许需要 trust_remote_code=True 的 HuggingFace 模型0
CRG_VECTOR_CACHE设为 1 时,在多次语义搜索之间把解码后的嵌入向量保留在内存中,不再每次查询都从 SQLite 全部重新读取。代价是内存(每个缓存的索引占 向量数 × 维度 × 4 字节),以及每个缓存的数据库在进程存续期间保持打开的一个读取连接:在 Windows 上,连接打开期间无法删除或替换 graph.db-
CRG_MAX_IMPACT_NODES影响分析中的最大节点数500
CRG_MAX_IMPACT_DEPTH影响半径分析的搜索深度2
CRG_MAX_BFS_DEPTH图谱遍历的最大深度15
CRG_MAX_CHANGED_FUNCS单份变更报告中分析的最大变更函数数500
CRG_MAX_DELETION_FILES单份变更报告中读取旧版本的最大文件数,用于列出差异删除的函数和类100
CRG_MAX_CHANGED_YAML_PATHS单份变更报告中分析的最大变更 YAML 路径数,JSON 路径另按同一上限计算200
CRG_MAX_TRANSITIVE_FRONTIERtests_for 和 detect-changes 查找测试时每一跳最多跟随的被调用者数。按名称取前面的,因此同一张图谱总是给出同一个答案50
CRG_CALLER_TEST_ROUTE_DEPTH为没有测试的变更符号向上回溯 CALLS 寻找已测试调用者的跳数。仅作为提示报告,不计为覆盖率2
CRG_CALLER_TEST_ROUTE_MAX_CALLERS寻找该已测试调用者时检查的调用者数量上限500
CRG_TOOL_TIMEOUT只读 MCP 工具的超时秒数(0 表示禁用)。不限制写入类工具:build、postprocess、embed、wiki 和 apply-refactor0
CRG_CHURN_WINDOW_DAYSdetect-changes --churn 统计提交数的时间窗口90
CRG_CONTEXT_HISTORY设为 1 时,把每次 context_savings 估算记入本地日志 .code-review-graph/context-history.jsonl;用 code-review-graph context-history 查看。记录 token 数、工具名、时间戳、详细级别以及文件数和深度,从不记录文件名、路径或源代码,也从不外发-
CRG_LEIDEN_SEEDLeiden 社区检测的随机种子42
CRG_RECURSE_SUBMODULES设为 1、true 或 yes 时包含 git 子模块-
CRG_FOLLOW_SYMLINKS设为 1、true、yes 或 on 时跟随符号链接文件夹(仓库内外均可),与 --follow-symlinks 相同。见 符号链接文件夹-
CRG_MAX_FOLLOWED_FILES通过符号链接文件夹最多读取的文件数10000
CRG_TOOLS提供服务时暴露的 MCP 工具白名单,逗号分隔-
GOOGLE_API_KEYGoogle Gemini 嵌入的 API 密钥-
MINIMAX_API_KEYMiniMax 嵌入的 API 密钥-
VOYAGE_API_KEYVoyage 嵌入的 API 密钥-
CRG_VOYAGE_MODELVoyage 嵌入使用的模型voyage-code-3
CRG_VOYAGE_OUTPUT_DIMENSIONVoyage 嵌入的输出维度1024
CRG_VOYAGE_OUTPUT_DTYPEVoyage 嵌入的输出 dtypefloat
CRG_VOYAGE_BASE_URLVoyage 嵌入端点https://api.voyageai.com/v1
CRG_VOYAGE_BATCH_SIZEVoyage 请求的批大小100
CRG_VOYAGE_MIN_INTERVAL_SECVoyage 请求之间的最小间隔0
CRG_OPENAI_BASE_URLOpenAI 兼容的嵌入端点-
CRG_OPENAI_API_KEYOpenAI 兼容嵌入的 API 密钥-
CRG_OPENAI_MODELOpenAI 兼容嵌入使用的模型-
CRG_OPENAI_DIMENSION固定嵌入维度(v3 模型支持降维)-
CRG_OPENAI_BATCH_SIZEOpenAI 兼容请求的批大小100
NO_COLOR关闭终端中的 ANSI 颜色-
CRG_SERIAL_PARSE设为 1 可关闭并行解析(用于调试)-
CRG_ENABLE_ENRICHMENT设为 1 后每次 build 和 update 都用 Jedi 解析 Python 方法调用(需要 enrichment 附加包,每个 Python 文件约多 1 秒)。等同 build --enrich关闭
CRG_DISABLE_ENRICHMENT设为 1 后即使请求也不运行 Jedi-

OpenAI 兼容嵌入无需额外安装。设置变量并给 embed_graph 传入 provider="openai":

export CRG_OPENAI_BASE_URL=http://127.0.0.1:3000/v1     # or https://api.openai.com/v1
export CRG_OPENAI_API_KEY=sk-...
export CRG_OPENAI_MODEL=text-embedding-3-small          # whatever your gateway serves
# optional:
export CRG_OPENAI_DIMENSION=1536                        # pin dim (v3 models support reduction)
export CRG_OPENAI_BATCH_SIZE=100                        # lower for gateways with tight limits

当 base URL 指向 localhost(127.0.0.1、localhost、0.0.0.0、::1)时,会跳过云端出网警告。

Voyage 嵌入无需额外安装。设置 VOYAGE_API_KEY 并给 embed_graph 传入 provider="voyage";默认模型是 voyage-code-3:

export VOYAGE_API_KEY=pa-...
export CRG_ACCEPT_CLOUD_EMBEDDINGS=1
code-review-graph embed --provider voyage --model voyage-code-3

模型选择。 对于打算长期保留的索引,避免使用 -preview、-beta 或 -exp 结尾的模型 ID;预览模型可能更换权重(维度一变就要全量重新嵌入)或被下架。请优先选择正式发布的模型,例如 text-embedding-3-small / text-embedding-3-large(OpenAI)或 gemini-embedding-001(原生 Gemini 提供方,需要 GOOGLE_API_KEY)。

嵌入文本包含标识符、签名、结构上下文,以及有长度上限的首段 docstring 或文档注释摘要。函数体不会被发送。在文档提取功能加入之前创建的图谱,需要先完整执行一次 code-review-graph build 再重新嵌入。常规构建不会刷新嵌入;要在构建后刷新,请同时传入 --embedding-provider 和 --embedding-model。云端提供方会收到这些由源码派生的文本,并可能据此收费。

工具过滤

CRG 默认暴露 30 个 MCP 工具。要把服务器限制到一个子集,使用 --tools 或 CRG_TOOLS 环境变量:

# CLI flag
code-review-graph serve --tools query_graph_tool,semantic_search_nodes_tool,detect_changes_tool

# Environment variable
CRG_TOOLS=query_graph_tool,semantic_search_nodes_tool code-review-graph serve

命令行参数优先于环境变量。两者都未设置时,所有工具都可用。在 MCP 客户端配置中:

{
  "mcpServers": {
    "code-review-graph": {
      "command": "code-review-graph",
      "args": ["serve", "--tools", "query_graph_tool,semantic_search_nodes_tool,detect_changes_tool,get_review_context_tool"]
    }
  }
}

</details>


常见问题与对比

答案见 docs/FAQ.md:

<details> <summary><strong>与 LSP、RAG 和 grep 的对比、什么时候不要用它,以及更多</strong></summary> <br>

</details>

故障排查

更多情况,包括 Windows/WSL,见 docs/TROUBLESHOOTING.md。

pip / pipx 无法下载 hatchling(或出现 Errno 9 / Bad file descriptor 连 PyPI 的错误)

<details> <summary><strong>如何修复</strong></summary> <br>

从源码树安装(例如 pipx install .)需要从 PyPI 取构建依赖。如果在一堆连接警告之后看到 Could not find a version that satisfies the requirement hatchling,那么该终端里的 Python 可能无法与 pypi.org 建立 HTTPS 连接。这在编辑器的集成终端里最常见,有时也与 VPN、防火墙或代理有关。

  1. 改在编辑器之外的系统终端(例如 Terminal.app)中运行同一条命令。

  2. 用 uv 从 checkout 安装,它使用不同的下载机制:

    cd /path/to/code-review-graph
    uv tool install . --force
  3. 在克隆中做开发时,使用 uv sync 和 uv run code-review-graph ...。

诊断方法:python3 scripts/diagnose_pypi_connectivity.py。如果它打印 FAILED,问题出在网络环境,而不是包名。

</details>

Windows:Invalid JSON: EOF while parsing 或 MCP error -32000: Connection closed

<details> <summary><strong>如何修复</strong></summary> <br>

不要在 Claude Code 配置中使用 cmd /c 包装。让 ~/.claude.json 直接指向 .exe,并通过配置设置 UTF-8:

"code-review-graph": {
  "command": "C:\\path\\to\\your\\venv\\Scripts\\code-review-graph.exe",
  "args": ["serve", "--repo", "C:\\path\\to\\your\\project"],
  "env": { "PYTHONUTF8": "1" }
}

</details>

参与贡献

Pull request 请提交到 staging(默认分支)。变更按 staging → testing → main 的顺序推进,版本从 main 打标签。没有任何推进是自动的: 每一次都由人审查并合并。完整流程见 CONTRIBUTING.md。

<details> <summary><strong>搭建开发副本并运行测试</strong></summary> <br>

git clone https://github.com/tirth8205/code-review-graph.git
cd code-review-graph
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

</details>

<details> <summary><strong>添加内置语言</strong></summary> <br>

要添加内置语言,编辑 code_review_graph/parser.py:把扩展名加入 EXTENSION_TO_LANGUAGE,并把节点类型映射加入 _CLASS_TYPES、_FUNCTION_TYPES、_IMPORT_TYPES 和 _CALL_TYPES。附上测试 fixture 并提交 PR。如果某种语言只在一个仓库里需要,请改用 languages.toml。

</details>

许可证

MIT。见 LICENSE。

<p align="center"> <br> <a href="https://code-review-graph.com">code-review-graph.com</a><br><br> <code>pip install code-review-graph && code-review-graph install</code> </p>

512 files · 480 not served here

Advantages

  • Drastically reduces token usage by providing only the relevant code context for a specific change. evidence: README.md
  • Maintains data privacy by storing the knowledge graph locally in a SQLite file without requiring cloud services. evidence: README.md

Limitations

Security

Risk level: Medium risk

This brain runs

MCP servers (2)

  • .mcp.json (code-review-graph): uvx code-review-graph serve
  • README.md (code-review-graph): code-review-graph serve --tools query_graph_tool,semantic_search_nodes_tool,detect_changes_tool,get_review_context_tool

Agent instructions that run or fetch something (38)

  • AGENTS.md: Other commands that may prompt: `scp` and `ssh` (`-o BatchMode=yes`), `apt-get` (`-y`), `brew` (`HOMEBREW_NO_AUTO_UPDATE=1`). · uses the network
  • CLAUDE.md: `locking.py`: the cross-process lock that lets one graph write run at a time.
  • CLAUDE.md: `skills.py`: `install` (platform MCP configs, hooks, skills, instruction blocks).
  • CLAUDE.md: `install_plan.py`: every install read and write goes through it, so `install --dry-run` can show each change as a diff and a real install writes nothing before its question is answered.
  • CLAUDE.md: `jsonc.py`: comment-preserving JSONC tokenising and splices, shared by install and uninstall so neither flattens a commented config.
  • CLAUDE.md: `install_gitignore.py`: the opt-in `install --gitignore` block listing the files a run created.
  • CLAUDE.md: `uninstall.py`: reverses `install`.
  • CLAUDE.md: uv run pytest tests/ --tb=short -q
  • CLAUDE.md: uv run ruff check code_review_graph/
  • CLAUDE.md: uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional
  • CLAUDE.md: uv run code-review-graph build # full build
  • CLAUDE.md: uv run code-review-graph update # incremental update
  • CLAUDE.md: uv run code-review-graph status # graph statistics
  • CLAUDE.md: uv run code-review-graph detect-changes # risk-scored change analysis (read-only)
  • CLAUDE.md: uv run code-review-graph forget PATH # drop files from the graph
  • CLAUDE.md: uv run code-review-graph serve # MCP server (stdio; --http for localhost)
  • CLAUDE.md: uv run code-review-graph wiki # Markdown wiki
  • CLAUDE.md: uv run code-review-graph register <path> # add a repo to the multi-repo registry
  • CLAUDE.md: uv run code-review-graph eval --all # benchmarks
  • CLAUDE.md: uv run code-review-graph --help # full command list
  • CLAUDE.md: Install and platforms: `test_skills.py`, `test_cli_install.py`, `test_uninstall.py`, `test_git_hook_worktree.py`, `test_hermes_install.py`, `test_qoder_bundled_skills.py`, `test_installer_ownership.py` (what install may rewrite and what belongs to the user), `test_install_gitignore_blo …[+283 chars]
  • CLAUDE.md: Builds a wheel and an sdist with `python -m build`, installs each into its own virtual environment, and drives the installed program with the checkout out of reach.
  • CLAUDE.md: Run it before a release with `uv run --python 3.13 python -m pytest tests/test_packaging.py -m packaging`.
  • CLAUDE.md: upgrade-path: manual run only.
  • code_review_graph/assets/code-review-graph/SKILL.md: Resolve the active repository root from the workspace or `git rev-parse --show-toplevel`.
  • code_review_graph/assets/code-review-graph/SKILL.md: Without MCP, run the bundled helper’s `status` command (it forwards `--json` to the CLI).
  • code_review_graph/assets/code-review-graph/SKILL.md: python3 <skill-root>/scripts/crg_readonly.py status --repo "<repo-root>"
  • code_review_graph/assets/code-review-graph/SKILL.md: python3 <skill-root>/scripts/crg_readonly.py architecture --repo "<repo-root>"
  • code_review_graph/assets/code-review-graph/SKILL.md: python3 <skill-root>/scripts/crg_readonly.py search "<query>" --repo "<repo-root>"
  • code_review_graph/assets/code-review-graph/SKILL.md: python3 <skill-root>/scripts/crg_readonly.py query callers_of "<symbol>" --repo "<repo-root>"
  • code_review_graph/assets/code-review-graph/SKILL.md: python3 <skill-root>/scripts/crg_readonly.py query path_to "<symbol>" --to "<other>" --repo "<repo-root>"
  • code_review_graph/assets/code-review-graph/SKILL.md: python3 <skill-root>/scripts/crg_readonly.py impact --repo "<repo-root>"
  • code_review_graph/assets/code-review-graph/SKILL.md: python3 <skill-root>/scripts/crg_readonly.py detect-changes --brief --repo "<repo-root>"
  • code_review_graph/assets/code-review-graph/SKILL.md: A Windows-mounted path such as `/mnt/e/...` is not by itself a failure: verify that the selected runtime can execute the CLI and access that path.
  • skills/build-graph/SKILL.md: Hooks installed by `code-review-graph install` run an update after each edit, before each commit and after a branch switch, merge or rebase, so manual builds are rarely needed.
  • skills/review-delta/SKILL.md: Changes come from `git diff` against `HEAD~1`;
  • skills/review-pr/SKILL.md: The graph tools read the files on disk, so check out what you review first: `git switch <branch>`, or for a PR `git fetch origin pull/<n>/head:pr-<n>` then `git switch pr-<n>`, then call `build_or_update_graph_tool()`. · uses the network
  • skills/review-pr/SKILL.md: Diff it against `main` (or `master`) with `git diff --name-only main...HEAD`, and use that ref as `base` below.

Hooks (3)

  • hooks/hooks.json (SessionStart): cat >/dev/null || true; command -v code-review-graph >/dev/null 2>&1 || exit 0; git rev-parse --git-dir >/dev/null 2>&1 && code-review-graph status --repo "$(git rev-parse --show-toplevel 2>/dev/null)" || echo 'Not a git repo, skipping'
  • hooks/hooks.json (PostToolUse): cat >/dev/null || true; code-review-graph build >/dev/null 2>&1 &
  • hooks/hooks.json (PostToolUse): command -v code-review-graph >/dev/null 2>&1 && code-review-graph hook-update; cat >/dev/null || true
  • Medium risk: runs-mcp-server-unpinned-runner (.mcp.json)
  • Medium risk: runs-instruction-instruction-network (AGENTS.md:17)
  • Medium risk: runs-instruction-instruction-network (skills/review-pr/SKILL.md:13)

Attribution and licence

Created by
Tirth
Declared authors
  • Tirth (declared in pyproject.toml)
Publisher
Tirth Kanani (Community)
Source
tirth8205/code-review-graph · commit e7f2fb2
Licence
MIT License (files served here)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Tirth.

Install from source

480 of its files are not served here, so there is no ZIP. tirth8205/code-review-graph at e7f2fb2