CodeGraph: 94% Fewer Tool Calls for Claude Code — Pre-Indexed Code Knowledge Graph

Published 2026-05-17 · 7 min read · Claude Code, AI Coding, Knowledge Graph, Developer Tools, GitHub Trending
Quick Summary:
  • What: CodeGraph — a pre-indexed code knowledge graph that accelerates Claude Code's Explore agents
  • Stats: 397 stars/day on GitHub Trending, 2,383 total stars, 203 forks
  • Key result: 94% fewer tool calls, 77% faster code exploration, 100% local processing
  • How it works: Pre-indexes symbol relationships, call graphs, and code structure into a knowledge graph that agents query instantly
  • Benchmarks: Tested on VS Code, Excalidraw, Swift Compiler, and more — from 52 calls down to 3
  • Install: npx @colbymchenry/codegraph — interactive setup configures Claude Code automatically

The Problem: Claude Code Burns Tokens Exploring Your Codebase

If you've used Claude Code on anything larger than a toy project, you've seen it: the Explore agent spawns, runs grep, glob, and Read across dozens of files, burns through tool calls, and racks up tokens — just to understand how your code is structured.

On a codebase like VS Code (4,000+ TypeScript files), a single exploration question used 52 tool calls and took nearly two minutes. That's expensive, slow, and frustrating.

CodeGraph by Colby Chenry solves this by building a local knowledge graph of your codebase before Claude Code ever touches it. Instead of scanning files, agents query the graph and get answers in 1–3 calls.

How CodeGraph Works

CodeGraph uses tree-sitter to parse your codebase into an AST (Abstract Syntax Tree), then builds a knowledge graph containing:

When Claude Code's Explore agent needs to understand a codebase, instead of spawning grep/glob scans, it calls codegraph_explore and gets structured answers from the pre-built graph. Zero file reads. Zero redundant scans.

Benchmark Results: Real Codebases, Real Savings

CodeGraph was tested across six production codebases using Claude Opus 4.6 (1M context) with Claude Code v2.1.91. Each test spawned a single Explore agent with the same question — with and without CodeGraph:

Codebase Without CodeGraph With CodeGraph Improvement
VS Code (TypeScript) 52 calls, 1m 37s 3 calls, 17s 94% fewer, 82% faster
Excalidraw (TypeScript) 47 calls, 1m 45s 3 calls, 29s 94% fewer, 72% faster
Claude Code (Python+Rust) 40 calls, 1m 8s 3 calls, 39s 93% fewer, 43% faster
Claude Code (Java) 26 calls, 1m 22s 1 call, 19s 96% fewer, 77% faster
Alamofire (Swift) 32 calls, 1m 39s 3 calls, 22s 91% fewer, 78% faster
Swift Compiler (Swift/C++) 37 calls, 2m 8s 6 calls, 35s 84% fewer, 73% faster

The Swift Compiler result is especially impressive — 25,874 files and 272,898 graph nodes, and CodeGraph still brought it down from 37 calls to 6.

Getting Started

Installation is a single command with an interactive setup:

npx @colbymchenry/codegraph

Or initialize in your project directory:

cd your-project
codegraph init -i

The interactive installer automatically configures Claude Code to use CodeGraph as a tool. No manual config editing required.

What Happens Under the Hood

  1. Parse: tree-sitter parses every source file into an AST
  2. Index: Symbols, types, and call relationships are extracted and stored in a local graph database
  3. Register: The codegraph_explore tool is registered with Claude Code's tool system
  4. Query: When Claude Code spawns an Explore agent, it calls codegraph_explore instead of grep/glob

When Should You Use CodeGraph?

CodeGraph shines when:

For small projects (under 50 files), the overhead of building the graph probably isn't worth it — Claude Code's native exploration is fast enough.

Comparison with Alternatives

Limitations

The Bigger Picture: AI Coding Tools Are Getting Smarter About Context

CodeGraph is part of a growing trend: instead of throwing more tokens at AI coding problems, developers are building infrastructure that gives AI agents structured access to code knowledge.

This mirrors what happened with databases — raw file scanning (full table scans) gave way to indexed queries. CodeGraph does the same for AI code exploration.

As AI coding agents become more capable, expect to see more tools like this: pre-computed knowledge structures that let agents reason about code without brute-force scanning.

Resources


Found this useful? Check out our other developer tool guides and Claude Code best practices for large codebases.