Give Claude Code a Code Map: 88% Fewer Tool Calls, at the Cost of a Fuller Context Window
CodeGraph pre-builds the codebase into a knowledge graph, so an agent can get the source code, call chain, and impact scope in a single query. In tests across 7 repositories, it saved 44% of cost and reduced tool calls by 88%. The official team itself admits that by the end of multi-turn sessions, 80% more context remains.
When Claude Code answers questions like 'how does this request get to the database?' in an unfamiliar repository, the path usually involves alternating between grep, glob, and Read. It flips through a dozen-plus files and makes dozens of tool calls before it can piece together the call chain. Most of the money and time goes into finding code; the part that actually changes code is small.
CodeGraph does this step ahead of time. It builds a knowledge graph for the project, putting functions, classes, call edges, imports, and inheritance relationships into a local SQLite database with FTS5 full-text search. The agent sends one codegraph_explore request via MCP and gets back the source text of relevant symbols, the call paths between symbols, and the impact scope of a change. No more reading files one by one.

The data comes from the official team. Seven open-source repositories, seven languages, Claude Code headless running Claude Opus 4.8, with 4 runs per group and the median taken. On average, 88% fewer tool calls, 62% fewer tokens, 44% lower cost, and 53% faster. File reads were 0 across all 7 repositories.

In the VS Code repository, 2 tool calls versus 28, and 58 seconds versus 2 minutes 10 seconds. For Excalidraw, 2 versus 43, and 45 seconds versus 2 minutes 42 seconds. Django's gap is smaller: 3 versus 14, with cost only 13% lower. The official explanation is that cost depends on how much exploration a question requires, not proportionally on repository size.
There is one number that is easy to overlook. The official documentation itself says: what it saves is throughput; window usage is actually higher. At the end of multi-turn sessions, the retrieval content CodeGraph leaves in the context is about 80% more than that of an agent reading file by file—67k tokens versus 18k on VS Code. The mechanism is not complicated: it returns one large, dense block of source text at once, and that block stays in the window after the answer is done; the grep approach produces many small results, which get pushed out gradually. People running long sessions with tight context windows need to factor this in.
Someone in the replies to the source material put it more directly: the most expensive overhead for a coding agent is a wrong edit, and wrong edits often come from reading too little code. The map lets the agent read fewer files, but read them accurately. That value is more worth looking at than the 44% savings.
Using it takes three steps:
npm i -g @colbymchenry/codegraph
codegraph install
cd your-project && codegraph init
install is responsible for writing the MCP server into the configurations of a long list of agents such as Claude Code, Cursor, Codex, and Gemini CLI; init builds the index for a single project. After that, file changes are automatically synchronized via the system's file events, with a default 2-second debounce, so there is no need to run sync manually.
Coverage: 20 languages are parsed by the native Rust core, while the remaining languages go through a portable engine using the same extraction logic; the official team says the graphs produced by the two are byte-for-byte identical. Framework routing and cross-language bridging for iOS and React Native are also handled. Everything runs locally, with no API key, under the MIT license.
Project link: github.com/colbymchenry/codegraph
Whether a tool can actually save money ultimately depends on how much your questions rely on exploration. If the agent could already answer in three calls, this indexing layer is extra overhead—and the official team doesn't hide that either.
发布时间: 2026-11-19 22:31