Persistent incremental knowledge graph for token-efficient, context-aware code reviews with Claude Code
Project description
code-review-graph
Persistent incremental knowledge graph for token-efficient, context-aware code reviews with Claude Code.
It turns Claude from "smart but forgetful tourist" into "local expert who already knows the map."
Stop re-scanning your entire codebase on every review. code-review-graph builds a structural graph of your code using Tree-sitter, tracks it incrementally, and gives Claude Code the context it needs to review only what changed — and everything affected by those changes.
| Without graph | With graph |
|---|---|
| Full repo scan every review | Only changed + impacted files |
| No blast-radius awareness | Automatic impact analysis |
| Token-heavy (entire codebase) | 5-10x fewer tokens per review |
| Manual "what else does this affect?" | Graph-powered dependency tracing |
Features
- Incremental updates — Only re-parses files that changed since last build. Subsequent updates take <2s.
- 12+ languages — Python, TypeScript, JavaScript, Go, Rust, Java, C#, Ruby, Kotlin, Swift, PHP, C/C++
- Blast-radius analysis — See exactly which functions, classes, and files are impacted by any change
- Token-efficient reviews — Send only changed + impacted code to the model, not your entire repo
- Auto-update hooks — Graph stays current on every file edit and git commit
- Vector embeddings — Optional semantic search across your codebase with sentence-transformers
- Interactive visualization — Collapsible, searchable HTML graph with edge-type toggles
- Watch mode — Real-time graph updates as you code
For the full feature list and changelog, see docs/FEATURES.md.
🚀 Quick Start
Install as a Claude Code Plugin (Recommended)
claude plugin add tirth8205/code-review-graph
That's it. Claude Code will handle installation and MCP server setup automatically. Restart Claude Code to activate.
Install via pip
If you prefer a manual setup or want to use the CLI tools directly:
pip install code-review-graph
code-review-graph init # Set up .mcp.json for Claude Code
Requires Python 3.10+ and uv (the init command generates a uvx-based MCP config). Install uv with pip install uv or brew install uv.
With semantic search (optional):
pip install code-review-graph[embeddings]
CLI
code-review-graph init # Set up .mcp.json for Claude Code
code-review-graph build # Parse your entire codebase
code-review-graph update # Incremental update (only changed files)
code-review-graph watch # Real-time auto-updates as you code
code-review-graph status # Show graph statistics
code-review-graph visualize # Interactive HTML graph visualization
code-review-graph serve # Start MCP server
Use the skills
/code-review-graph:build-graph # Parse your codebase (~10s for 500 files)
/code-review-graph:review-delta # Review only what changed
/code-review-graph:review-pr # Full PR review with blast-radius
Before: Claude reads 200 files, uses ~150k tokens. After: Claude reads 8 changed + 12 impacted files, uses ~25k tokens.
For detailed usage instructions, see docs/USAGE.md.
🛠️ How It Works
┌─────────────────────────────────────────────┐
│ Claude Code │
│ ┌─────────┐ ┌──────────┐ ┌────────────┐ │
│ │ Skills │ │ Hooks │ │ Agent │ │
│ └────┬────┘ └────┬─────┘ └─────┬──────┘ │
│ │ │ │ │
│ └────────────┼───────────────┘ │
│ │ │
│ ┌─────▼─────┐ │
│ │ MCP Server │ │
│ └─────┬─────┘ │
└────────────────────┼────────────────────────┘
│
┌───────────┼───────────┐
│ │ │
┌────▼───┐ ┌───▼────┐ ┌──▼──────────┐
│ Parser │ │ Graph │ │ Incremental │
│(sitter)│ │(SQLite)│ │ (git diff) │
└────────┘ └────────┘ └─────────────┘
| Component | File | Role |
|---|---|---|
| Parser | code_review_graph/parser.py |
Tree-sitter multi-language AST parser. Extracts nodes and relationships. |
| Graph | code_review_graph/graph.py |
SQLite-backed knowledge graph with NetworkX for traversal queries. |
| Incremental | code_review_graph/incremental.py |
Git-aware delta detection. Re-parses only changed files + dependents. |
| MCP Server | code_review_graph/main.py |
Exposes 8 tools to Claude Code via the Model Context Protocol. |
| Visualization | code_review_graph/visualization.py |
D3.js interactive graph visualization generator. |
| Skills | skills/ |
Three review workflows: build-graph, review-delta, review-pr. |
| Hooks | hooks/ |
Auto-updates the graph on file edits and git commits. |
For the full architecture walkthrough, see docs/architecture.md.
📚 Deep Dive
Everything beyond the quick start lives in the docs/ folder. Start with docs/USAGE.md for the full workflow guide.
| Document | What's inside |
|---|---|
| Usage Guide | Installation, workflows, and tips |
| Commands Reference | All MCP tools, skills, and CLI commands |
| Features & Changelog | What's included and what changed |
| Architecture | System design and data flow |
| Schema | Graph node/edge types and SQLite tables |
| Troubleshooting | Common issues and fixes |
| LLM-Optimized Reference | Token-optimized reference used by Claude Code |
| Roadmap | Planned features |
| Legal & Privacy | License and data handling |
Graph Schema
Nodes
| Kind | Properties |
|---|---|
| File | path, language, last_parsed_hash, size |
| Class | name, file, line_start, line_end, modifiers |
| Function | name, file, class (nullable), line_start, line_end, params, return_type, is_test |
| Type | name, file, kind (enum, interface, etc.) |
| Test | name, file, tested_function |
Edges
| Kind | Direction | Meaning |
|---|---|---|
| CALLS | Function -> Function | Function calls another function |
| IMPORTS_FROM | File -> File/Module | File imports from another |
| INHERITS | Class -> Class | Class extends another |
| IMPLEMENTS | Class -> Interface | Class implements an interface |
| CONTAINS | File/Class -> Function/Class | Containment hierarchy |
| TESTED_BY | Function -> Test | Function has a test |
| DEPENDS_ON | Node -> Node | General dependency |
For the full schema documentation, see docs/schema.md.
MCP Tools
| Tool | Description |
|---|---|
build_or_update_graph_tool |
Full or incremental graph build |
get_impact_radius_tool |
Blast radius analysis for changed files |
query_graph_tool |
Predefined relationship queries (callers, callees, tests, imports) |
get_review_context_tool |
Token-optimized review context with source snippets |
semantic_search_nodes_tool |
Search code entities by name/keyword/semantic similarity |
embed_graph_tool |
Compute vector embeddings for semantic search |
list_graph_stats_tool |
Graph statistics and health check |
get_docs_section_tool |
Retrieve specific documentation sections (minimal tokens) |
For usage details and examples, see docs/COMMANDS.md.
Supported Languages
| Language | Extensions | Status |
|---|---|---|
| Python | .py |
Full support |
| TypeScript | .ts, .tsx |
Full support |
| JavaScript | .js, .jsx |
Full support |
| Go | .go |
Full support |
| Rust | .rs |
Full support |
| Java | .java |
Full support |
| C# | .cs |
Full support |
| Ruby | .rb |
Full support |
| Kotlin | .kt |
Full support |
| Swift | .swift |
Full support |
| PHP | .php |
Full support |
| C/C++ | .c, .h, .cpp, .hpp |
Full support |
Configuration
Create a .code-review-graphignore file in your repo root to exclude paths:
# Ignore generated files
generated/**
*.generated.ts
*.pb.go
# Ignore vendor
vendor/**
third_party/**
🧪 Testing
pip install -e ".[dev]"
pytest
ruff check code_review_graph/
47 tests covering parser, graph storage, MCP tools, and multi-language support (Go, Rust, Java).
🤝 Contributing
Adding a new language
- Add the extension mapping in
code_review_graph/parser.py→EXTENSION_TO_LANGUAGE - Add node type mappings in
_CLASS_TYPES,_FUNCTION_TYPES,_IMPORT_TYPES,_CALL_TYPES - Test with a sample file in that language
- Submit a PR
Development setup
git clone https://github.com/tirth8205/code-review-graph.git
cd code-review-graph
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest
Comparison
| Feature | code-review-graph | code-graph-rag | CocoIndex |
|---|---|---|---|
| Review-first design | Yes | No | No |
| Claude Code integration | Native | No | No |
| Incremental updates | Yes | Partial | Yes |
| No external DB needed | Yes (SQLite) | No (Neo4j) | No |
| Auto-update hooks | Yes | No | No |
| Impact/blast radius | Yes | No | No |
| Multi-language | 12+ languages | Python only | Varies |
| Token-efficient reviews | Yes | No | No |
📄 License
MIT — see LICENSE for details.
Built with ❤️ for better code reviews
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code_review_graph-1.6.4.tar.gz.
File metadata
- Download URL: code_review_graph-1.6.4.tar.gz
- Upload date:
- Size: 50.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc96fbace29e99a3680b8dd395d306f059cd2452222d7b32cb1b0c273ee57e54
|
|
| MD5 |
637e53dfb2266bd0ea8bbd1ed7b9dadc
|
|
| BLAKE2b-256 |
456ed8619ca61d5f6c5bd42dd6a56365381923439025e389ab95c7c6f1ad6122
|
File details
Details for the file code_review_graph-1.6.4-py3-none-any.whl.
File metadata
- Download URL: code_review_graph-1.6.4-py3-none-any.whl
- Upload date:
- Size: 42.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b41855caa9f016a9c3fb5a6482c3f31ac2488df2a8ba8df2dbf97a6ee3e57ca
|
|
| MD5 |
dd1e456a56106d9631895c3ef553b20c
|
|
| BLAKE2b-256 |
fa5eb7597e340e2c33cd62ffb8df403c3dea669ee026cbcdb412f68e8b5172ab
|