codegraph by colbymchenry is a local pre-indexed code knowledge graph for AI coding agents. The upstream README lists support for Claude Code, Codex, Gemini, Cursor, OpenCode, AntiGravity, Kiro, and Hermes Agent; check the README for the current list before installing. Instead of letting an agent spend most of a taskβs time running grep, glob, and Read to discover code structure, codegraph pre-parses source with tree-sitter into a local SQLite graph (nodes = symbols, edges = calls / imports / inheritance / framework URL routes), then exposes MCP query tools that return relationships instantly. The current READMEβs 2026-07 revalidation reports 89% fewer tool calls, 60% lower cost, and 69% fewer tokens on average across seven benchmark repos β useful directional vendor claims, not an independent formal benchmark.
Source: github.com/colbymchenry/codegraph (MIT). Benchmark and agent-support claims in this entry are upstream README claims unless explicitly labeled as Qβs local test. Discovery note: Weibo post by η±ε―ε―-η±ηζ΄», May 2026 β link not preserved.
The problem it actually solves
Run any non-trivial Claude Code task on a 1k-file project and watch the trace. A large fraction of the agentβs runtime β often more than half β is just discovery: grep for a symbol, glob for matching files, Read to scan one. Each tool call burns tokens, time, and the context budget. Worse, when an agent gives up on discovery because the context is filling, it may proceed with an incomplete picture and produce a confidently wrong answer.
codegraphβs bet: that discovery work is repetitive and fundamentally cacheable. Parse the code once, store the structural facts in a tiny local SQLite DB, expose them via MCP, and the agent stops thrashing.
Architecture in one diagram
ββββββββββββββββββββββββ
β Your source code β
ββββββββββββ¬ββββββββββββ
β
ββββββββββββΌββββββββββββ
β tree-sitter parsers β (multi-language β
β β ASTs β with custom extraction
β β for Svelte / Vue / Liquid)
ββββββββββββ¬ββββββββββββ
β
ββββββββββββΌββββββββββββ
β Node + edge extract β
β β’ functions/classes β
β β’ call / import β
β β’ inherits β
β β’ framework routes β
ββββββββββββ¬ββββββββββββ
β
ββββββββββββΌββββββββββββ
β .codegraph/ β
β codegraph.db β
β (SQLite + FTS5) β
ββββββββββββ¬ββββββββββββ
β
ββββββββββββΌββββββββββββ
β MCP server β
β 9 query tools (see β
β table below) β
ββββββββββββ¬ββββββββββββ
β
ββββββββββββΌββββββββββββ
β AI coding agent β
β (uses graph instead β
β of grep/glob/Read) β
ββββββββββββββββββββββββ
File watcher (FSEvents / inotify / ReadDirectoryChangesW)
β auto-debounced re-index on save, started by the
MCP/watch server after `codegraph init`
The 9 MCP tools codegraph exposes
Per the source (src/mcp/tools.ts), codegraph exposes nine query tools β not one. Most users wonβt invoke them by name; the agent picks whichever fits the question. They split into two tiers:
| Tier | Tool | What it returns |
|---|---|---|
| Heavy | explore |
A deep multi-hop exploration around a symbol or path. The βspend the budget hereβ call. |
| Light | search |
Full-text + symbol search via SQLite FTS5 |
| Light | context |
Surrounding symbols + call-site context for a target |
| Light | callers |
Who calls this symbol |
| Light | callees |
What this symbol calls |
| Light | impact |
Forward and backward blast radius for a symbol or file |
| Light | node |
Detailed metadata for a specific graph node |
| Light | status |
Index status / freshness |
| Light | files |
List indexed files (with filters) |
The agentβs typical pattern is: one or two search / node / callers calls to triangulate, then one explore if it needs depth. The current benchmark numbers come from this composition replacing many grep + Read cycles.
Whatβs distinctive about codegraph
| Feature | Why it matters |
|---|---|
| Tiered MCP tool design | One heavy explore tool plus eight lightweight query tools. The agent answers most factual questions with light tools (cheap, fast); only escalates to explore for genuine deep dives |
| Framework-aware URL routing | Recognizes web frameworks (per src/resolution/frameworks/) β Django, FastAPI, Flask, Express, Laravel, Rails, Spring, Gin (incl. chi / gorilla / mux), Axum, actix, Rocket, ASP.NET, Vapor, React (+ React Router), Svelte (+ SvelteKit), SwiftUI/UIKit, and more. URL patterns link to their handler functions/classes. Huge win for βwhat handles /api/users/:id?β queries |
| File watcher auto-sync | Native OS events (FSEvents / inotify / ReadDirectoryChangesW). After codegraph init does the initial index, the MCP/watch server keeps the graph fresh on subsequent edits with debouncing to avoid thrash |
| Local index, no CodeGraph API key | Parsing and graph storage happen locally in SQLite. Normal agent use can still send returned code snippets to Claude, Codex, or whichever model provider your agent calls |
| Multi-agent install support | Installer supports multiple agent configs. Inspect the generated config before writing it, especially because install can add MCP entries and steering text that tells agents to prefer graph queries over raw file reads |
Performance β what the README claims
The current README reports a 2026-07 revalidation across seven open-source repos, using headless Claude Code with and without CodeGraph. The headline average is 89% fewer tool calls, 60% lower cost, and 69% fewer tokens. Wall-clock time was noisier: the README reports an average speedup, but small repos sometimes finished faster with raw grep while spending far more tokens and money.
| Codebase | What the README highlights |
|---|---|
| VS Code | Large TypeScript codebase; CodeGraph reduces discovery-heavy file reading |
| Excalidraw | Small-repo floor effect: raw grep can be faster wall-clock, but CodeGraph uses fewer tokens/cost |
| Django | Python ORM architecture query |
| Tokio | Rust async-runtime architecture query |
| OkHttp | Java interceptor-chain query |
| Gin | Small Go routing/middleware query |
| Alamofire | Swift request-building query |
Benchmark methodology caveat: the benchmark is still vendor-run, task-specific, and not a peer-reviewed evaluation. The methodology is better documented than the original May snapshot, but the right adoption move is unchanged: measure on your own codebase before rolling it out team-wide.
Install
npm i -g @colbymchenry/codegraph
codegraph install --print-config claude
codegraph install --print-config codex
codegraph install
The interactive installer:
- Detects supported agent configs
- Adds the codegraph MCP server entry
- May add steering instructions so the agent uses graph queries before raw file reads
- Can add Claude Code permissions for lightweight query tools, depending on the current installer flags
Per-project bootstrap:
cd your-project
codegraph init
codegraph init builds the initial index. The file watcher / auto-sync kicks in when the MCP/watch server starts. Large projects (~25k files in the README benchmark) finish the initial indexing in <4 min on a modern laptop. Older notes in this wiki used codegraph init -i; check the current README before copying install commands into a course handout.
Qβs May 23 local check
This section folds in the useful part of the older βCodeGraph: Local Code Knowledge Graph that Cuts Token Usageβ entry, which is now archived.
Install safety check: Q inspected the npm package path on May 23, 2026. The checked package was a small shim, had no npm lifecycle scripts, and downloaded the release binary from GitHub. That historical check was for @colbymchenry/codegraph@0.9.3; do not treat it as a current supply-chain audit for later releases.
Config inspection: codegraph install --print-config showed the MCP entries before writing them. The important lesson was that install touches more than one layer: the agent MCP config plus steering text in project/user instruction files. Diff your config after install.
Indexing measurements from Qβs local tests:
| Codebase | Files | Nodes | Edges | Index time | Disk |
|---|---|---|---|---|---|
| Excalidraw shallow clone | 603 TS files | 9,286 | 8,622 | 11.4s | 19MB |
| learnai-3d-studio | 14 TS files | 109 | 95 | 561ms | 0.32MB |
codegraph sync on a no-change run took about 0.54s in that local test.
One illustrative context-query result: a codegraph context query for βhow does the scene render and what files are involvedβ on learnai-3d-studio returned about 5,824 chars, versus about 89,025 chars for naively reading all 14 .ts / .tsx files in src/. That is roughly a 93% reduction for one query, but it is not a reproduction of the upstream headless-agent benchmark.
Why Q did not run the full benchmark: clean headless Claude Code benchmarking was blocked by session contamination unless using --bare, and --bare required a separate ANTHROPIC_API_KEY rather than subscription OAuth. Treat upstream benchmark numbers as vendor claims until independently reproduced on your own rig.
How it differs from the sibling tool
If youβve seen Code Review Graph by tirth8205, youβve seen a cousin β same underlying idea, different design choices and a substantially broader tool surface:
| Dimension | codegraph (this entry) | code-review-graph (sibling) |
|---|---|---|
| Primary headline | 89% fewer tool calls, 60% lower cost, 69% fewer tokens in the READMEβs 2026-07 benchmark | 8.2x token reduction, up to 49x on monorepos |
| Optimization target | Eliminate discovery thrash during any Claude Code task | Originally framed around code review; now also advertises daily coding, architecture/debug/onboarding prompts, wiki generation, refactoring, and multi-repo search |
| MCP surface | 9 tools (1 heavy explore + 8 light queries) |
28 tools (search, refactor, dead code, wiki gen, communitiesβ¦) |
| Framework awareness | URL β handler routing built in across many web frameworks | Framework-aware features and resolvers; richer overall toolkit |
| Update strategy | OS file-watcher + debounce | Incremental SHA-256 hash diff |
| Install | install.sh, install.ps1, npm, or npx @colbymchenry/codegraph |
pip install code-review-graph |
| License | MIT | MIT |
Which to pick? code-review-graph is broader (28 tools, more output modes including auto-wiki generation and community detection); codegraph is narrower (9 tools, framework routing, file watcher). For projects where you mostly want Claude to stop spelunking, codegraphβs smaller footprint is appealing. For monorepo refactoring + auto-doc workflows, code-review-graphβs richer toolkit wins. They can coexist as MCP servers if you want both.
Limitations and honest caveats
- Files >1MB are skipped by default (README-stated; configurable). Large generated files / minified bundles wonβt be in the graph.
- Initial indexing time scales with the codebase (README-stated). Most projects finish quickly; very large repos still need real indexing time even if incremental syncs are fast.
- Static models donβt capture dynamic dispatch / reflection /
eval()/ string-built imports. (My inference, not directly stated in the README.) The agent will sometimes still need to fall back toReadfor these patterns.
How LearnAI Team Could Use This
- Default-install candidate for LearnAIβs Claude Code / Codex setup β pilot it on one team project first, measure your own tool-call/time numbers, then roll out if the win holds on your codebases. The index is local, but returned snippets still enter the cloud model context when your agent uses them.
- Pair with CS-310 (Advanced OO Programming & Design) β codegraphβs graph view is a pedagogically useful way to show students what an LLM is actually looking for when it reads code. The URL β handler routing is a tangible βframework awarenessβ lesson.
- CS-336 (Program Analysis for Security) β codegraph is a working tree-sitter + AST + graph pipeline. Students can extend it (e.g., add a taint-flow edge type, or an information-flow analysis) as a 2-3 week project; the codebase is the right size for that scope.
- Research workflow β when youβre skimming an unfamiliar repo for paper-reproduction work, codegraph lets Claude answer βwhere does this paperβs algorithm actually live in the code?β much faster than
grep-driven discovery. Run a quick before/after measurement on your own repo to confirm the numbers translate.
Real-World Use Cases
| Scenario | How to use |
|---|---|
| βWhere is X used?β questions in a large repo | Use callers on the symbol; get the list directly |
| βWhat does X depend on?β | Use callees for the outgoing call graph |
| Refactor impact preview | Use impact for the forward/backward blast radius before renaming or removing |
| API endpoint debugging | Ask Claude βwhat code handles POST /users/:id/auth?β β codegraphβs framework-aware routing finds the handler |
| Onboarding a new contributor | Run codegraph; ask Claude βsummarize the architectureβ with the graph available; result is structurally informed instead of file-list-shallow |
Important things to know
- codegraph is one MCP server in a growing space. Knowledge-graph approaches to agent codebase exploration are a clear pattern now (Code Review Graph is the most-starred sibling). Treat codegraph as one good implementation β easy to swap if a better one appears for your stack.
- The benchmark methodology is still not independent. Seven codebases, task-specific architecture questions, vendor-run. Headline numbers are directionally useful but not a formal benchmark β measure your own before adopting team-wide.
- The framework registry is updated frequently in source. Check
src/resolution/frameworks/for the live list; the framework names in this entry are a snapshot, not exhaustive. - Indexing is local; agent context is still agent context. CodeGraph does not require a CodeGraph API key for local indexing, but any snippets returned to Claude, Codex, or another cloud model may still be sent to that model provider as normal tool-result context.
- Installer behavior can change. Inspect
codegraph install --print-config, run it on a disposable repo first if needed, and diff agent instruction/config files after install. - Companion deep-dives in this wiki:
- Code Review Graph β 8.2x Token Reduction β sibling tool, broader scope
- Claude Code Context Management & CLAUDE.md β the complementary βwhat lives in conversation contextβ
- Claude Code Β· context: fork β isolation pattern for heavy explorations
- Harness Engineering β The Real Bottleneck Isnβt the Model β why this kind of tooling is high-leverage
- GBrain β Garry Tanβs Persistent Agent Memory System β the broader pattern of graph-shaped memory for agents