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.
60
72%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./.agents/skills/code-review-graph/SKILL.mdCut 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.
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.
When invoked during /plan or standard usage on a mid-to-large project, check whether graph analysis is available before relying on it:
Get-Command code-review-graph (Windows) or which code-review-graph (macOS/Linux)..code-review-graph/ directory exists in the workspace.code-review-graph build (it scans the whole project).pip install code-review-graph and build a local map to cut token usage for this project?" Never install or run build without confirmation.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 assistantsPython, TypeScript, JavaScript, Go, Rust, Java, C#, Ruby, Kotlin, Swift, PHP, C/C++, Vue SFC, Solidity, Dart, R, Perl, Lua, Jupyter/Databricks notebooks.
python3 --version)# 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# 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 windsurfRestart your editor after this step. The MCP server activates on restart.
cd /your/project
code-review-graph build| Codebase Size | Expected Build Time |
|---|---|
| 500 files | 10–30 seconds |
| 5,000 files | 2–5 minutes |
| 27,000 files | 5–10 minutes |
# Keep graph current as you work
code-review-graph watchIncremental updates complete in under 2 seconds. If you prefer manual updates:
code-review-graph updateOpen your AI client and check MCP connection. For Claude Code: run /mcp and confirm code-review-graph appears.
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.
For microservice architectures:
# Register additional repos
code-review-graph register /path/to/other/repo
# List all registered repos
code-review-graph reposThe MCP server serves context across all registered repositories.
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 tokenscode-review-graph detect-changesScores each uncommitted change by risk level:
The graph finds nodes with no incoming edges — no callers, no importers, no test coverage:
# Surfaces functions/classes that are candidates for removal
# Useful on mature codebases to reduce cruftcode-review-graph rename preview --from OldClassName --to NewClassNameShows every file affected by a rename, and flags edge cases (dynamic string references that static analysis can't catch).
code-review-graph visualizeGenerates interactive visualization showing module clusters using community detection (Leiden algorithm). Useful for:
code-review-graph wikiGenerates markdown wiki of codebase structure — every module, its public API, dependencies, and test coverage.
| Limitation | Impact | Mitigation |
|---|---|---|
Dynamic imports (require(variable), import(buildPath())) | Dependencies invisible to parser | Manually note in .code-review-graphignore or accept over-prediction |
Reflection-based calls (Django signals, getattr(), Java reflection) | Missed edges in graph | Serena (LSP-based) is better for these codebases |
Runtime-generated code (eval, template engines) | Not parseable at static time | Accept limitation or exclude from graph |
| Cross-language boundaries (Python calling TypeScript API) | No edges between language runtimes | Use multi-repo registration as partial workaround |
| Stale graph (without watch mode) | Claude queries outdated relationships | Always run code-review-graph update before tasks, or use watch mode |
TypeScript path aliases (@/components/...) | May require tsconfig resolution config | Check tsconfig_resolver.py handles your setup |
| Tool | Approach | Pros | Cons | Best For |
|---|---|---|---|---|
| code-review-graph | Tree-sitter + SQLite | Fast, 19 languages, local, no deps | Static analysis only | General use, large codebases |
| Claudette | Go rewrite | Single binary, no Python | Fewer languages, simpler | Python-averse teams |
| Serena | LSP-based | Deep semantic precision, type resolution | Heavy setup, slower | Polymorphism-heavy codebases |
| code-graph-rag | RAG + vector search | Natural language queries | Complex setup | Codebase exploration |
| Native IDE context | Editor built-in | Zero setup | No explicit blast radius | Simple projects |
| AG Kit Skill | How It Complements |
|---|---|
context-compression | Graph reduces input context; compression reduces output verbosity |
coordinator-mode | Graph-aware workers can be dispatched with precise file lists |
verify-changes | After graph-informed review, verify changes via execution |
batch-operations | Graph's blast radius informs which files need batch updates |
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.code-review-graphignore for build artifacts, node_modules, dist/04514f0
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.