Code Review Graph 标志

Code Review Graph

社区热门
vudovn
code-review-graph

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.

概览

发布者vudovn
代码仓库ag-kit
技能名称code-review-graph
星标数
8.2K
复刻数
1.5K
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 vudovn 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Code Review Graph AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/vudovn/ag-kit/tree/main/.agents/skills/code-review-graph
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/vudovn/ag-kit.git /tmp/ag-kit
mkdir -p .claude/skills
cp -r /tmp/ag-kit/.agents/skills/code-review-graph .claude/skills/code-review-graph
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Code Review Graph,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Code Review Graph。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Code Review Graph 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

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 TypePattern
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

bash
# 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

bash
# 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

bash
cd /your/project
code-review-graph build
Codebase SizeExpected Build Time
500 files10–30 seconds
5,000 files2–5 minutes
27,000 files5–10 minutes

Step 4: Enable Watch Mode (Recommended)

bash
# Keep graph current as you work
code-review-graph watch

Incremental updates complete in under 2 seconds. If you prefer manual updates:

bash
code-review-graph update

Step 5: Verify Integration

Open your AI client and check MCP connection. For Claude Code: run /mcp and confirm code-review-graph appears.


Configuration

Ignore File

Create .code-review-graphignore at project root (uses .gitignore syntax):

# Build artifacts
dist/**
.next/**
build/**

# Dependencies
node_modules/**
vendor/**

# Generated files
generated/**
*.generated.ts
*.min.js

# Test fixtures (if large)
__fixtures__/**

Excluding generated files and build artifacts is critical — they inflate the graph with meaningless nodes.

Multi-Repo Setup

For microservice architectures:

bash
# Register additional repos
code-review-graph register /path/to/other/repo

# List all registered repos
code-review-graph repos

The MCP server serves context across all registered repositories.


Core Workflows

1. Blast Radius Analysis (Primary Use)

This is automatic when the MCP server is active. Your AI assistant queries the graph before reading files, getting only the impacted files instead of everything.

Without graph:  Changed auth/middleware.py → AI reads 200+ files → 8,200 tokens
With graph:     Changed auth/middleware.py → Graph returns 12 impacted files → 1,000 tokens

2. Risk-Scored Change Analysis

bash
code-review-graph detect-changes

Scores each uncommitted change by risk level:

  • Number of dependents
  • Test coverage gaps
  • Whether changed functions are on critical paths
  • High-risk changes flagged before you ask for review

3. Dead Code Detection

The graph finds nodes with no incoming edges — no callers, no importers, no test coverage:

bash
# Surfaces functions/classes that are candidates for removal
# Useful on mature codebases to reduce cruft

4. Refactoring Preview

bash
code-review-graph rename preview --from OldClassName --to NewClassName

Shows every file affected by a rename, and flags edge cases (dynamic string references that static analysis can't catch).

5. Architecture Visualization

bash
code-review-graph visualize

Generates interactive visualization showing module clusters using community detection (Leiden algorithm). Useful for:

  • Onboarding new contributors
  • Identifying architectural drift
  • Spotting overly-coupled modules

6. Wiki Generation

bash
code-review-graph wiki

Generates markdown wiki of codebase structure — every module, its public API, dependencies, and test coverage.


Known Limitations

LimitationImpactMitigation
Dynamic imports (require(variable), import(buildPath()))Dependencies invisible to parserManually note in .code-review-graphignore or accept over-prediction
Reflection-based calls (Django signals, getattr(), Java reflection)Missed edges in graphSerena (LSP-based) is better for these codebases
Runtime-generated code (eval, template engines)Not parseable at static timeAccept limitation or exclude from graph
Cross-language boundaries (Python calling TypeScript API)No edges between language runtimesUse multi-repo registration as partial workaround
Stale graph (without watch mode)Claude queries outdated relationshipsAlways run code-review-graph update before tasks, or use watch mode
TypeScript path aliases (@/components/...)May require tsconfig resolution configCheck tsconfig_resolver.py handles your setup

Alternatives Comparison

ToolApproachProsConsBest For
code-review-graphTree-sitter + SQLiteFast, 19 languages, local, no depsStatic analysis onlyGeneral use, large codebases
ClaudetteGo rewriteSingle binary, no PythonFewer languages, simplerPython-averse teams
SerenaLSP-basedDeep semantic precision, type resolutionHeavy setup, slowerPolymorphism-heavy codebases
code-graph-ragRAG + vector searchNatural language queriesComplex setupCodebase exploration
Native IDE contextEditor built-inZero setupNo explicit blast radiusSimple projects

Integration with AG Kit

Complementary Skills

AG Kit SkillHow It Complements
context-compressionGraph reduces input context; compression reduces output verbosity
coordinator-modeGraph-aware workers can be dispatched with precise file lists
verify-changesAfter graph-informed review, verify changes via execution
batch-operationsGraph's blast radius informs which files need batch updates

Recommended Session Architecture

1. Start fresh session for each distinct task
2. Graph pre-filters context → AI reads only blast radius
3. Context compression summarizes completed phases
4. Memory system saves key decisions for next session
5. Result: minimum tokens, maximum quality

Best Practices

  1. Always run watch mode in development — stale graphs produce stale context
  2. Exclude generated files — they inflate the graph with noise
  3. Benchmark first — measure token usage for 1 week without, 1 week with
  4. Combine with output constraints — graph reduces input, prompt engineering reduces output
  5. Use .code-review-graphignore for build artifacts, node_modules, dist/
  6. Keep sessions short — fresh sessions + graph = optimal token efficiency
  7. Multi-repo registration for microservice architectures

常见问题

Code Review Graph 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.

为什么在 TypingMind 中使用 Code Review Graph?

因为您只需安装一次,就能搭配任何模型使用。Code Review Graph 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Code Review Graph?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/vudovn/ag-kit/tree/main/.agents/skills/code-review-graph。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Code Review Graph?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Code Review Graph 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Code Review Graph 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Code Review Graph AI 技能免费吗?

是的。vudovn 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇