跳到正文
Skillpedia
通用编程8.2k · #12528

code-review-graph

它能做什么

这项技能建立项目中文件之间连接关系的地图。它帮助你的 AI 聚焦于某项改动涉及的文件,而不是读取整个项目。适合代码库庞大的团队。

适用场景

  • ✓当你评审大型项目中包含许多文件的改动时。
  • ✓当代码库太大无法全部读取,导致 AI 的上下文空间不足时。
  • ✓当你希望把评审范围限制在某项改动周围的文件时。

技能链接

https://github.com/vudovn/ag-kit/blob/main/.agents/skills/code-review-graph/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/vudovn/ag-kit/blob/main/.agents/skills/code-review-graph/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“在你评审之前,请使用代码图谱告诉我我最新的改动会影响哪些文件。”

每周 5 个新技能,1 分钟读完。

工作原理

这项技能使用一个 MCP 服务器,把代码解析为结构图谱,并存储在本地数据库中。AI 通过查询该图谱,找出某项改动可能影响的文件。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Code Review Graph — Token-Efficient Codebase Context via MCP

Cut AI token usage substantially on large codebases by giving the AI a structural map instead of letting it read everything. Savings scale with codebase size — marginal on small projects, large on monorepos.

Overview

code-review-graph is an MCP server that uses Tree-sitter to parse your codebase into an AST graph stored in SQLite. When your AI assistant needs context for a task, it queries the graph first — getting only the files in the blast radius of your change — instead of reading every file in the directory.

Token Impact (illustrative — varies by codebase):

Codebase Type Pattern
Large monorepo (10K+ files) Biggest savings — graph reads a small fraction of files
Mid-size app (1-5K files) Meaningful reduction on multi-file changes
Small project (<200 files) Little benefit — graph overhead can exceed savings

Quality angle: scoping the AI to the blast radius reduces noise, which tends to improve review focus. Measure on your own repo rather than relying on a fixed multiplier.

Bootstrap Protocol (opt-in)

When invoked during /plan or standard usage on a mid-to-large project, check whether graph analysis is available before relying on it:

  1. Step 1: Check if the tool is installed: Get-Command code-review-graph (Windows) or which code-review-graph (macOS/Linux).
  2. Step 2: Check if a .code-review-graph/ directory exists in the workspace.
  3. Step 3: If installed but the index is missing, ask the user before running code-review-graph build (it scans the whole project).
  4. Step 4: If not installed and the project is large, ask the user: "Would you like to pip install code-review-graph and build a local map to cut token usage for this project?" Never install or run build without confirmation.

When to Use vs When to Skip

✅ Install it if:

  • Codebase is 500+ files
  • You make multi-file changes with cross-module dependencies
  • You spend $20+/month on AI assistant tokens
  • You work with monorepos, microservices, or cross-package TypeScript
  • You want better review quality in addition to cost savings

❌ Skip it if:

  • Codebase is under ~200 files with isolated single-file changes
  • Heavy use of dynamic patterns (reflection, runtime code gen, dynamic imports)
  • You want zero-maintenance — the graph needs to stay in sync
  • Team hasn't standardized on an AI coding tool yet

⚠️ Evaluate first if:

  • Codebase is 200–500 files — benchmark before committing
  • Mix of static and dynamic patterns — test on representative commits

How It Works (4 Layers)

Layer 1: PARSE    → Tree-sitter builds ASTs from 19 languages
Layer 2: STORE    → Nodes + edges saved in SQLite graph
Layer 3: TRACE    → BFS computes blast radius of changes
Layer 4: SERVE    → MCP exposes graph to AI assistants

What the Graph Contains

  • Nodes: Files, functions, methods, classes, imports, tests
  • Edges: "A calls B", "X imports Y", "TestZ covers FunctionW", "ClassA extends ClassB"
  • Metadata: Name, type, file path, line range per node
  • Privacy: Structural metadata only — NO source code content in the graph

Supported Languages (19)

Python, TypeScript, JavaScript, Go, Rust, Java, C#, Ruby, Kotlin, Swift, PHP, C/C++, Vue SFC, Solidity, Dart, R, Perl, Lua, Jupyter/Databricks notebooks.


Installation

Prerequisites

  • Python 3.9+ (python3 --version)
  • pip or pipx installed
  • An MCP-compatible AI client (AG Kit, Claude Code, Cursor, Windsurf, Zed)
  • Git-tracked codebase (for incremental updates)

Step 1: Install the Package

# Recommended: isolated environment
pipx install code-review-graph

# Alternative: fastest, no permanent install
uvx code-review-graph install

# Alternative: global pip
pip install code-review-graph

Step 2: Configure MCP Client

# Auto-detect all supported tools
code-review-graph install

# Or target a specific platform
code-review-graph install --platform claude-code
code-review-graph install --platform cursor
code-review-graph install --platform windsurf

Restart your editor after this step. The MCP server activates on restart.

Step 3: Build the Initial Graph

cd /your/project
code-review-graph build
Codebase Size Expected Build Time
500 files 10–30 seconds
常见问题

它对小项目有用吗?

这项技能说明,在小项目中收益不大,因为设置成本可能超过节省的部分。

图谱存储什么?

它将代码结构存储在使用 Tree-sitter 解析构建的 SQLite 数据库中。

它能替代阅读代码吗?

它能缩小 AI 需要读取的文件范围,但评审仍取决于它所查看的代码。

详情

作者的原始描述

Token-efficient code review using Tree-sitter AST graphs and MCP. Cuts AI token usage on large codebases by computing the blast radius of changes instead of reading entire codebases. Uses a SQLite graph database for structural analysis.

repo: vudovn/ag-kit

热度

GitHub 星标
8.2k
排名
#12528
许可证
MIT
更新时间
2026/10/18

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能