Code Review · Detailed guide · verified 2026-08-28

code-review-graph:Detailed Guide

Lets AI review only the relevant code by building a local code knowledge graph; for large codebases.

code-review-graph Detailed Guide

Version 2.3.8~2.3.8 | category gate | security (reviewed) | sources: official project docs (Chinese README.zh-CN.md) + measured in this marketplace (2026-08-28)
Companion: site docs (manifest + guide + evidence) | quick version: site docs

1. When to use it

code-review-graph (by tirth8205, MIT, ~31k stars) is a local-first code intelligence graph: it uses tree-sitter to parse your codebase into a graph (functions, classes and imports as nodes; calls, inheritance and test coverage as edges), and during review only feeds the files the AI actually needs — saving tokens and boosting efficiency. It offers both MCP and CLI access, plus official Chinese documentation.

In one sentence: when AI reviews code, let it "only look at what matters" instead of stuffing the whole repo into the context.

AI code review either looks at too much or misses things. code-review-graph builds a local knowledge graph of your codebase (tree-sitter parsing, SQLite stored in the workspace's .code-review-graph/), so the AI only reviews relevant code — change one function and it tells you which files the change affects.

When to use it:

  • Giving AI reviews "impact surface" context (changing A affects B);
  • Running build to build the graph, watch for incremental watching, status for stats inside a codebase;
  • Registering the graph as an MCP server for Claude/Codex/Cursor (install).

When not to use it: small repos, single-file changes, where the graph costs more than it saves.

Notes: multi-registration heavyweight — install registers MCP/hooks with detected platforms (writes ~/.claude.json, ~/.codex/hooks.json etc.); the official uninstall cleans everything up.

2. Capability list

CapabilityPurpose
build/updatefull/incremental graph construction
query/impact/searchgraph query, impact analysis, semantic search
dead-code/refactordead code and refactoring suggestions
mcp/serveMCP server and local service
watchauto-update on file changes
tree-sitter code graphSee the agent-executable guide
MCP integrationSee the agent-executable guide
dead-code/impact analysisSee the agent-executable guide
Official Chinese docsSee the agent-executable guide

3. Quick install

note: Verified path on this machine; mainland must use the Tsinghua mirror (PyPI official timeout, probe 2026-08-27)
# Source: Trove detailed guide · verified 2026-08-28
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple code-review-graph==2.3.8
code-review-graph --version

Expected output: code-review-graph 2.3.8

Step 1: Confirm the graph exists

Why: after build, the workspace has a .code-review-graph/ directory (SQLite graph data) — the most direct proof that "the graph was built".

# Source: Trove detailed guide · verified 2026-08-28
ls -d .code-review-graph 2>/dev/null && echo "graph dir: OK" || echo "graph dir: MISSING"
code-review-graph status

Expected output: graph dir: OK plus node/edge/file stats

Stuck? How to recover:

  • directory missing → rerun build from "Step by step" step 2, confirm you are in a git repo root;
  • status errors → check whether the current directory has graph data (running status elsewhere reads no graph for this repo).

Step 2: Confirm the AI can actually use it (if you registered MCP)

Why: after install, check that the corresponding platform config shows a code-review-graph section — the agent-side hookup is in place.

# Source: Trove detailed guide · verified 2026-08-28
grep -l "code-review-graph" ~/.claude.json ~/.codex/hooks.json ~/.cursor/mcp.json 2>/dev/null || echo "check config files manually"

Expected output: at least one config file path (platforms with registration); none means not registered

Stuck? How to recover:

  • not in platform config → rerun install, confirm the platform is detected;
  • CLI-only is fine → skip install; build/status/watch are already enough.

Install variants

PathCommandMeasured
Main path (measured)pip install -i https://pypi.tuna.tsinghua.edu.cn/simple code-review-graph==2.3.8…✅ measured in this marketplace
Mirror/proxySee quick guide and semi_auto_note; for China installs follow the code-review-graph guidemeasured
Semi-auto note: measured command = pip install -i Tsinghua mirror code-review-graph==2.3.8 (2026-08-28 verified in this environment, isolated venv, Python 3.14); China must use the Tsinghua mirror (official PyPI times out); optional pipx install (official recommendation, not measured on this machine); code-review-graph install registers MCP/hooks for Claude/Codex/Cursor/OpenCode (writes ~/.claude.json, ~/.codex/hooks.json, workspace .mcp.json etc., see guide shared surfaces); crg-daemon is a background process
  • Non-git repos: verified build/status do NOT error (2026-08-30), but cross-file references are not resolved (sample: 1 file → 0 edges) — impact analysis is meaningless; still recommended to run at a git repo root for a full graph.
  • Windows / macOS: same pip install commands (Tsinghua mirror still recommended); MCP config paths differ from Linux (on Windows ~/.claude.json is in the user dir, .cursor config under %USERPROFILE%); uninstall cleanup logic is the same.
  • venv / conda: if the command is not found after install, activate the virtualenv first; pipx install is the officially recommended path (not verified here, command surface identical to pip).
  • First build time: the bigger the repo, the slower the first build — normal; use watch/update for incremental afterwards.

4. Why this happens (mechanism & shared surface)

CLI installed via pip (pipx also possible, officially recommended, not verified here). Inside a workspace (git repo), build builds the full graph (tree-sitter parse → SQLite), watch incrementally watches file changes (background crg-daemon), status shows stats, detect-changes read-only analyzes change impact (change A → know B). install registers an MCP server with detected platforms (multi-platform write surface, see dependency warnings). build/status/detect-changes/watch verified on an isolated repo (2026-08-30).

Key concepts:

  • Graph data: workspace .code-review-graph/ (SQLite);
  • crg-daemon: the background process in watch mode;
  • MCP registration: the multi-platform config sections install writes.

Where it writes: the pip environment + workspace .code-review-graph/; after install: ~/.claude.json (mcpServers), ~/.codex/hooks.json, ~/.cursor/mcp.json, ~/.config/opencode/plugins/crg-plugin.ts, workspace .claude/settings.json and .mcp.json.

  • Workspace: .code-review-graph/ (SQLite graph data), .claude/settings.json (mcpServers section), .mcp.json (MCP registration)
  • HOME: ~/.claude.json (mcpServers), ~/.codex/hooks.json, ~/.cursor/mcp.json + hooks, ~/.config/opencode/plugins/crg-plugin.ts
  • Runtime: watch/daemon mode background process

5. Common operations

Step 1: Install the CLI (why pin the version: 2.3.8 is the verified collection version)

Why: PyPI official direct times out in this environment (probe 2026-08-27), so the Tsinghua mirror prefix is required; pinning 2.3.8 keeps everything consistent with what was verified. Verify with --version after install.

# Source: Trove detailed guide · verified 2026-08-28
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple code-review-graph==2.3.8
code-review-graph --version

Expected output: code-review-graph 2.3.8

After install, confirm:

  • --version prints 2.3.8;
  • inside a git repo, code-review-graph --help shows build/status/watch/install subcommands.

Stuck? How to recover:

  • pip won't install → confirm Python >= 3.10; retry with the Tsinghua mirror prefix;
  • command not found → activate the venv in venv scenarios first.

Step 2: Build the graph + view stats (core usage, run inside the target repo)

Why: build parses the full codebase to generate the graph (first run is slower, normal); status shows node/edge/file stats. After this, AI reviews can use the graph to locate impact surfaces.

# Source: Trove detailed guide · verified 2026-08-28
code-review-graph build

Expected output: parse progress + stats (verified sample: Full build: 5 files, 9 nodes, 16 edges; workspace gets .code-review-graph/graph.db)

# Source: Trove detailed guide · verified 2026-08-28
code-review-graph status

Expected output: node/edge/file stats (verified sample: Nodes: 9 / Edges: 16 / Files: 5 / Languages: javascript, python / Built at commit: …)

After install, confirm:

  • after build, .code-review-graph/ contains graph data;
  • status prints node/edge stats.

Stuck? How to recover:

  • build is slow → first full parse is normal; use watch/update for incremental later;
  • non-git repo → verified build/status do NOT error (2026-08-30) but cross-file references are not resolved (sample: 1 file → 0 edges); impact analysis is meaningless; cd to a git repo root for a full graph.

Step 3: Incremental watching + register MCP (optional)

Why: watch watches file changes for incremental updates (background crg-daemon, Ctrl+C to exit; verified 2026-08-30: ~2s auto update after a file change); detect-changes read-only analyzes the impact of current uncommitted changes (change A → know B, no rebuild needed); install registers an MCP server with detected platforms — this writes multi-platform config, so decide whether you want all-platform registration before installing.

# Source: Trove detailed guide · verified 2026-08-28
code-review-graph watch

Expected output: Watching … for changes… (Ctrl+C to stop) (verified: file change triggers incremental update in ~2s; node/edge counts rise)

# Source: Trove detailed guide · verified 2026-08-28
code-review-graph install

Expected output: registers an MCP server with detected platforms (writes ~/.claude.json, ~/.codex/hooks.json etc.)

After install, confirm:

  • watch mode logs file changes;
  • after install, the corresponding platform config shows a code-review-graph section (~/.claude.json mcpServers etc.).

Stuck? How to recover:

  • platform does not recognize after install → check the corresponding platform config files (~/.claude.json / ~/.codex/hooks.json / ~/.cursor/mcp.json / ~/.config/opencode/plugins/crg-plugin.ts);
  • do not want all-platform registration → skip install, use only build/status/watch (CLI surface).

Startup and entry

Call the CLI inside the target repo; watch mode listens in the background.

Common operations

Operation 1: Build the code graph

# Source: Trove detailed guide · verified 2026-08-28
code-review-graph build

Expected output: parse progress + stats (verified sample: Full build: 5 files, 9 nodes, 16 edges; workspace gets .code-review-graph/graph.db)

Operation 2: View graph stats

# Source: Trove detailed guide · verified 2026-08-28
code-review-graph status

Expected output: node/edge/file stats (verified sample: Nodes: 9 / Edges: 16 / Files: 5 / Languages: javascript, python / Built at commit: …)

Operation 3: Incremental updates (watch file changes)

# Source: Trove detailed guide · verified 2026-08-28
code-review-graph watch

Expected output: Watching … for changes… (Ctrl+C to stop) (verified: file change triggers incremental update in ~2s; node/edge counts rise)

Operation 4: Analyze change impact (read-only, run anytime after edits)

Why: detect-changes does not re-parse; it read-only analyzes which functions/files your current uncommitted changes affect (JSON output: impacted list + risk_score + context savings estimate). Verified on a 5-file sample repo (2026-08-30).

# Source: Trove detailed guide · verified 2026-08-28
code-review-graph detect-changes

Expected output: JSON impact report (affected functions/files + risk_score fields)

Operation 5: Register MCP (multi-platform)

# Source: Trove detailed guide · verified 2026-08-28
code-review-graph install

Expected output: registers an MCP server with detected platforms (writes ~/.claude.json, ~/.codex/hooks.json etc.)

Data and directories

  • Graph data: workspace .code-review-graph/ (SQLite; confirm whether you need a backup before uninstall);
  • Registration surface: ~/.claude.json (mcpServers), ~/.codex/hooks.json, ~/.cursor/mcp.json, ~/.config/opencode/plugins/crg-plugin.ts, workspace .claude/settings.json and .mcp.json.

6. Conflict pairs (summary)

Same source as the tool-page matrix — 19 pairs total (6 measured compatible / 10 inferred possibly compatible / 3 inferred possibly conflicting); full pairs, states and evidence: Conflict pairs (co-install matrix).

7. Quick troubleshooting

  • No standalone handbook yet; for install/uninstall issues first see the agent-executable guide notes

8. Uninstall and residue check

# Source: Trove detailed guide · verified 2026-08-28
code-review-graph uninstall 2>/dev/null || true; pip uninstall -y code-review-graph
note: the official uninstall subcommand cleans up completely (data/config/hooks/skills/MCP registration), then uninstall the pip package; this marketplace one-click uninstall runs it automatically
# Source: Trove detailed guide · verified 2026-08-28
code-review-graph uninstall 2>/dev/null || true
pip uninstall -y code-review-graph
command -v code-review-graph >/dev/null 2>&1 && echo "残留: code-review-graph 仍存在" || echo "code-review-graph removed: OK"

Expected output: code-review-graph removed: OK

Manual checklist (for full cleanup):

  • workspace .code-review-graph/ (graph data, confirm whether you need a backup before uninstall)
  • the code-review-graph mcpServers section in ~/.claude.json (the official uninstall should clear it; delete manually if residue)
  • ~/.codex/hooks.json / ~/.cursor/mcp.json / ~/.config/opencode/plugins/crg-plugin.ts (same)

9. FAQ

  • Runtime precheck (needs Python >= 3.10)
  • Official pip path (measured in this environment); China must use the Tsinghua mirror (official PyPI times out, probe 2026-08-27)
  • Optional pipx install code-review-graph (official recommendation, not measured on this machine); the install subcommand registers MCP/hooks (multi-platform write surfaces, see FAQ)
  • Each operation = one command block + expected output; run inside the target code repository
  • Multi-registration surface: install writes MCP/hooks config for 4 platforms; the official code-review-graph uninstall cleans up completely
  • Q: What does install change in my config? A: registers MCP/hooks with detected platforms: ~/.claude.json (mcpServers), ~/.codex/hooks.json, ~/.cursor/mcp.json, ~/.config/opencode/plugins/crg-plugin.ts, workspace .claude/settings.json and .mcp.json — all cleanable by the official uninstall.
  • Q: Conflicts with ruflo/omc/agt installed together? A: judged possible-conflict — same-file write surface on ~/.claude.json or workspace .claude/settings.json/.mcp.json (different keys/sections), co-install not tested; install one and get it working first.
  • Q: Build is slow? A: the first full build parse is normal; use watch/update for incremental afterwards.
  • Q: Can't pip install domestically? A: use the Tsinghua mirror prefix from the install section (PyPI official times out in this environment).
  • Q: Where to report usage problems? A: install/uninstall issues on this marketplace go through the entry feedback channel (usage-report template); project issues go to the author's repository.
  • Version: [2.3.8, 2.3.8] locked (verified collection version).
  • Environment: Python >= 3.10; graph building depends on repo structure (run inside a git repo).
  • Network: PyPI official times out (probe 2026-08-27), must use the Tsinghua mirror.
  • Write surface (multi): workspace .code-review-graph/ + post-install multi-platform registration sections (~/.claude.json / ~/.codex/hooks.json / ~/.cursor/mcp.json / ~/.config/opencode/plugins/crg-plugin.ts / workspace .claude/settings.json and .mcp.json).
  • Co-install: with ruflo / omc / agt judged possible-conflict (same-file write surface on ~/.claude.json or workspace .claude/settings.json/.mcp.json, different keys/sections, co-install not tested); with deepcode / superpowers / claude-code-router judged possible-compatible.

10. Sources

  • Verified: local repro log (2026-08-28, pip install + version/help smoke).
  • Not tested: install multi-platform registration (needs platform environments; not run here to avoid polluting real registration surfaces); pipx install path (command surface identical to pip).
  • Verified (2026-08-30): local repro log 2026-08-30 — isolated repo full chain: build 5 files → 9 nodes/16 edges, status stats, detect-changes impact, watch incremental 9→10 nodes/16→18 edges; also verified non-git dir does not error but yields 0 edges.

External tutorials (unverified)

Third-party tutorials are not individually verified; check against this page and official docs.

  • 博客园:code-review-graph 完整上手攻略——lsgxeva(转载自某内容平台专栏) [博客园 · lsgxeva(页面署名;原文标注转载自内容平台专栏,原作者未在页面体现) · 2026-05-17]
    本地代码知识图谱 + MCP 接入的完整教学——为什么 AI 需要代码地图(上下文成本)、工作原理(Tree-sitter 解析→节点/边)、安装(pip/pipx、install --platform claude-code 注册 MCP)、核心操作(build 全量构建 / update 增量更新 / watch 监听自动更新 / status 图谱统计 / visualize 交互可视化 + graphml/svg/obsidian/cypher 导出 / detect-changes 变更影响分析 / serve MCP 服务器 / daemon 守护进程)

Merged sources

This page merges multiple source articles — deduplicated by content hash, measured, and rewritten by AI. Sources are not scattered; they all live on this single page.

No merged sources yet: this page distills local verification and community rewrites; provenance details live on the linked solution page.

← Back to code-review-graph solution page | Code Review domain