Skip to content

How to Reduce 90% of Claude Code Token Usage with Code Graph

Reduce Claude Code token usage by 90% through deterministic local indexing and MCP, eliminating expensive sequential file exploration in AI sessions.

Tuan Tran Van
2 min read
Updated 08/11/2026
Contents (9 sections)
  1. What is Code Graph for?
  2. Where does Code Graph cut tokens?
  3. How many tokens does Code Graph save?
  4. Is a 90% cut the typical result?
  5. How does Code Graph work?
  6. How does Code Graph differ from the other tools?
  7. When should you use Code Graph?
  8. How do you install Code Graph?
  9. References

CodeGraph builds a local map of your codebase so Claude Code stops burning on grep and reading file after file. Across 7 projects it cut tokens by 57% and cost by 35% on average, reaching 90% of tokens on Excalidraw.

Claude Code queries a prebuilt code map from Code Graph instead of reading files one by one, cutting token usage

What is Code Graph for?

Code Graph · by Colby McHenry
Builds a local map of your codebase, so the agent gets the right context in one tool call instead of grepping and reading file after file.
It removes the “exploration tax”, the tokens burned on finding where code lives. The model stays the same, so the saving comes from skipping that search.
57%
average token cut across 7 projects
71%
fewer tool calls
20+
languages
0
API keys needed
Start with codegraph init -i

Where does Code Graph cut tokens?

  1. Project memoryCLAUDE.md and notes, loaded every sessionCaveman
  2. Exploring codegrep, glob and reading file after fileGraphifyCode Graph
  3. Command outputLogs, tests and git output in the contextRust Token Killer
  4. RepliesThe words Claude writes backCaveman

How many tokens does Code Graph save?

One run, before and after the graph
VS Code, tokens−78%
Before2,800,000
After601,000
Tokio, cost−82%
Before$2.41
After$0.42
Try switching each tool on
Drag the slider to replay the session, then switch tools on to see how the total moves.
Tokens into the session
333,827
Cut 0 (0%)
  1. Load Caveman's instructions0
  2. Ask about a code flow157,800
  3. Ask about project structure123,000
  4. Run git status3,000
  5. Run cargo test25,000
  6. Run git diff21,500
  7. Claude explains a bug1,180
  8. Claude sets up a connection pool2,347
Each row is a published benchmark, but from different projects. Use it to compare sizes, not to forecast a bill.

Is a 90% cut the typical result?

Take a guess first
The best case cuts tokens by 90%. How much does average cost drop across 7 projects?
45%

How does Code Graph work?

How the graph is built and kept fresh
Explored 1/4
  1. Turn code into syntax trees
    The result is deterministic, so the graph knows exactly which function calls which. Vector search only guesses from similarity.
    1. tree-sitterBuilds ASTs for 20+ languages
The first build takes seconds on a normal repo and up to 10 minutes on a monorepo over 100,000 files. Later syncs only update what changed.

How does Code Graph differ from the other tools?

When should you use Code Graph?

Use it when
Large codebases with deep folders
Languages with complex modules, such as Rust
Frequent questions about flow and architecture
Skip it when
Partly supported languages, such as Objective-C
Expecting the graph to replace the model's reasoning

How do you install Code Graph?

bash
curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh
codegraph init -i

On macOS, run xcode-select --install first, or Code Graph falls back to a mode 5–10x slower. On WSL2, keep code on the Linux filesystem rather than /mnt/c/.

References

Check yourself

Three quick questions to see whether the main ideas stuck.

  1. Why does Claude Code burn so many tokens on an unfamiliar codebase?
  2. What does CodeGraph change about how the agent gets structural context?
  3. Which statement about CodeGraph's limits matches the article?

Share this article

AI glossary