tirth8205 /code-review-graph
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.
★ 32,779⑂ 2,982👁 92⑃ 769● 400▤ 31
+14
日增长
+198
周增长
+697
月增长
32,779
stars
2,982
forks
92
watchers
769
prs
400
issues
31
releases
README
code-review-graph
本地代码知识图谱,通过 MCP 为 AI 编码工具提供精准的审查上下文。
English |
简体中文 |
日本語 |
한국어 |
हिन्दी
使用说明 ·
命令 ·
常见问题 ·
故障排查 ·
新功能 ·
更新日志 ·
GitHub Action ·
复现基准测试 ·
路线图 ·
全部文档
AI 编码工具为了审查一次改动,常常要重新读取代码库的大部分内容。code-review-graph 用 Tree-sitter 构建代码的结构图,增量保持更新,并通过 MCP 提供紧凑的上下文,让助手只读取改动涉及的文件。
它能做什么
- 为你的代码建图。 函数、类、导入、调用和测试组成一张图谱。
- 指出一次改动可能弄坏什么。 它能波及的调用者、依赖方和测试,并附带风险评分。
- 保持最新。 钩子和 watch 模式只重新解析变更的文件。
- 配合你的 AI 工具。 一次 install 就能配置它找到的每个工具。
- 留在你的机器上。 一个 SQLite 文件,没有云服务;云端嵌入需要主动开启。
---
快速开始
需要 Python 3.10+。
bash
uv tool install code-review-graph or: pipx install / pip install code-review-graph
code-review-graph install set up the AI coding tools found on this machine
code-review-graph build parse the codebase
code-review-graph detect-changes --brief see what your last change touches
重启编辑器或工具,然后打开项目,对助手说:
Review my changes
用 code-review-graph uninstall 可以全部撤销(加 --dry-run 先预览)。如果有问题,运行 code-review-graph doctor:它检查当前设置,不做任何改动。
install 会改动什么,以及如何先预览
install 会查找这台机器上的 AI 编码工具,只配置找到的那些。它为每个工具写入一条 MCP 服务器配置,在工具支持的地方安装钩子和技能,并把图谱说明加入它的规则文件。之后它会列出没有找到的工具;仍想配置某个工具,用 install --platform NAME。
install 会先列出要改动的文件,并在你回答它关于说明文件的问题之后才写入任何内容。没有终端时(例如由 AI 智能体运行),它采用默认答案“是”,并会说明这一点;--no-instructions 可跳过这些文件。install --dry-run 把每处改动显示为 diff,什么都不写。安装后请重启编辑器或工具。
MCP 配置和每个钩子都运行执行 install 的那一份 code-review-graph。在 Poetry 或 uv 项目中,MCP 配置使用 poetry run 或 uv run;当 install 本身由 uvx 或 uv tool install 运行时使用 uvx;否则使用运行 install 的那个 Python。钩子写明这个 Python(或 uvx),它不在了时就运行 PATH 上的 code-review-graph。升级之后请再运行一次 install。
install 写入的文件(例如 .claude/ 和 .mcp.json)对 git 仍然可见,以便你的团队提交它们。在 git 跟踪它们之前,build 和审查都会跳过它们,所以你的第一次审查只显示你自己的改动;install 把它们记在 .code-review-graph/install-manifest.json 中。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 目录和工具清单,
所以请在实际执行任务的那个运行环境中安装和刷新。
所有支持的平台,以及如何只配置其中一个
只配置一个平台时,给 --platform 传入 codex、claude-code、cursor、windsurf、zed、continue、opencode、mimo、antigravity、gemini-cli、qwen、kiro、qoder、copilot、copilot-cli、codebuddy、hermes 或 dsh 之一:
bash
code-review-graph install --platform cursor
code-review-graph install --platform codebuddy
这样指定的平台即使 install 没有找到也会被配置。配置文件的位置列在 docs/USAGE.md 中。
uninstall 的更多用法
uninstall 会从 Git 或 SVN 工作树中移除 CRG 自己写入的文件和配置项,不动其他 MCP 服务器、钩子、技能和 JSONC 注释。在工作树内的任意位置运行即可。共享配置文件采用原子替换,写入失败时原文件保持完整。install 创建的配置文件如果 git 没有跟踪、里面也没有别的内容,会连同 install 创建的空文件夹一起被删除。没有终端时,它采用默认答案“否”,并提示你加上 --yes。
bash
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 everyTop issues
#262Windows 11: MCP-based review is extremely slow while CLI graph operations are fast10 comments · 2026-04-13#1042Promotion gate: testing to main7 comments · 2026-09-18#436[Feature]: Add JSON & YAML for AST parser1 comments · 2026-05-06#63better-sqlite3 ABI mismatch crashes extension on WSL 2 — NODE_MODULE_VERSION 137 vs 1276 comments · 2026-03-25#721[Bug]: Hang at "INFO: Spring event resolver: indexed 0 events and emitted 0 CALLS edges"5 comments · 2026-07-23#620Bug: Codex installer generates Unix-only hooks on Windows4 comments · 2026-07-14#311How to configure code-review-graph for a workspace of sibling repos + worktrees (Claude Code in VS Code)?4 comments · 2026-04-17#209# Code-Review-Graph MCP Issue with Windsurf4 comments · 2026-04-10
Discussions
#1169New release date?0 comments · 2026-11-09#1136Can I use code-review-graph against a sub-repo?1 comments · 2026-10-26#1091Slow build ~40 minutes for 5000 files1 comments · 2026-10-05#965Move from Claude to Codex: will CRG still work?1 comments · 2026-09-09#732Claude Code - better instructions1 comments · 2026-07-24#724Differences from codegraph2 comments · 2026-07-23#719Is it working for team work?1 comments · 2026-07-23#695Proposal: a phased approach to improving JavaScript/TypeScript flow detection1 comments · 2026-07-21
Latest release
v2.4.0 v2.4.0 2026-11-11[2.4.0] - 2026-11-10 Two new platforms, MiMo Code and DeepSeek Harness, so install now supports 18. HTML, XSLT, Liquid, JSON and plain YAML files are indexed, and so are .cjs and .kts files, which every build used to skip. The graph links calls, imports and tests more carefully: a call it could not check no longer looks like a real link, every call edge says how sure it is, calls to inherited methods and imports of workspace packages are followed, and tests_for finds Java, Ruby and PHP tests. The graph schema moves from 13 to 15. Several new settings are off unless you turn them on.