Optimize Claude Code with code-review-graph

Stop letting Claude Code read files that have nothing to do with your task! Every time you ask Claude Code to review a change, it scans your entire codebase. Most of those files are irrelevant. You are paying for tokens that add no value. code-review-graph fixes this by building a persistent knowledge graph of your codebase using Tree-sitter. It maps every function, class, import, and dependency, then at review time computes the exact set of files Claude actually needs to read. Here's how it works: • Parses your codebase into an AST and stores it as a graph of nodes and edges in SQLite • On every file save or git commit, a hook fires and re-parses only what changed • At review time it traces the blast radius of your change: every caller, dependent, and test that could be affected • Claude reads only those files instead of scanning the whole project Real results across 6 open-source repositories: 6.8x fewer tokens on code reviews, up to 49x on daily coding tasks. Supports 23 languages including Python, TypeScript, Rust, Go, Java, Vue, Solidity, and Jupyter notebooks. Works with Claude Code, Cursor, Windsurf, and any MCP-compatible agent. It's 100% open source. Link to the GitHub repo in the comments!

  • diagram

Reducing context is just as important as improving prompts. By narrowing the code the agent reads to only what's relevant, teams can cut token costs, speed up reviews, and reduce noise without sacrificing quality.

The token reduction is compelling, but the harder problem is keeping the graph trustworthy as a codebase changes. I would watch two metrics separately: context precision, meaning how often the selected files are actually needed, and review recall, meaning how often a change still surfaces every affected caller and test. A small benchmark across refactors, schema changes, and cross-package edits would make the 6.8x result even more useful for teams evaluating this in production.

Ideally AI assisted code reviews works on PR level using git diff. But I saw one of the gap where if your PR is small and don't have much context then reviewing the entire codebase would be costly. But if it works in that way, it can be a good choice.

This shifts code review from context stuffing to context engineering. The less irrelevant code an agent sees, the better the signal-to-noise ratio and the lower the cost.

The blast radius tracing from the AST graph looks like the key differentiator here. How well does it handle incremental updates when a single function signature change ripples across many indirect callers?

Like
Reply

tree-sitter as the parse layer is the right call - incremental reparsing on save means the graph stays live without a full rebuild cost. the 6.8x token reduction on claude code reviews makes sense once you're feeding blast-radius subgraphs instead of whole-repo context: precision of retrieval, not model quality, is what drives that number down.

Like
Reply

Couldn't you get close to this just by scoping a review to the PR diff via a Skill/Plugin, no graph overhead? The catch is tight coupling a diff shows what changed, not what depends on it and surfacing those affected callers is the whole point of the blast radius graph. Though I'd bet the token savings shrink fast in a repo where the blast radius is half the codebase.

Like
Reply

The "blast radius" framing is what makes this worth installing. Most token-reduction tools compress what you send. code-review-graph changes *what you send* — tracing callers, dependents, and affected tests from the changed files only. That's a different intervention: routing, not compression. The honest benchmarking helps too: median 82x, range 38x–528x, and they flag the circular metric issue in their own docs. Projects that benchmark themselves adversarially are worth trusting. One practical note: the overhead flips negative for small single-file changes (they acknowledge this). Worth keeping a lightweight fallback for trivial edits; code-review-graph pays for itself on the ones where context sprawl is the actual cost.

Like
Reply

The test coverage edges are the part worth stress testing. Static call graphs catch unit tests that directly reference the changed function, but real regression coverage often comes from integration or end to end tests that hit an HTTP endpoint or a queue and never statically call the code they exercise. A report of no relevant tests is easy to read as coverage is thin, when it might just mean coverage is invisible to a static graph. False negatives on test relevance matter more than the token savings. How does it handle coverage that only shows up at runtime?

Like
Reply
See more comments

To view or add a comment, sign in

Explore content categories