codegraph
CLI Toolcolbymchenry/codegraph
Pre-indexed code knowledge graph to boost Claude Code performance with fewer tokens and tool calls.
Overview
CodeGraph creates a pre-indexed knowledge graph of codebases, allowing Claude Code's explore agents to query symbol relationships instantly instead of scanning files. It supports 19+ languages, framework-aware routing, and runs fully locally, reducing tool calls by up to 96% and speeding exploration by over 70%.
README Preview
\n\n# CodeGraph\n\n### Supercharge Claude Code with Semantic Code Intelligence\n\n**94% fewer tool calls · 77% faster exploration · 100% local**\n\n[](https://www.npmjs.com/package/@colbymchenry/codegraph)\n[](https://opensource.org/licenses/MIT)\n[](https://nodejs.org/)\n\n[](#)\n[](#)\n[](#)\n\n\n\n### Get Started\n\n```bash\nnpx @colbymchenry/codegraph\n```\n\nInteractive installer configures Claude Code automatically\n\n#### Initialize Projects\n\n```bash\ncd your-project\ncodegraph init -i\n```\n\n\n\n\n\n---\n\n## Why CodeGraph?\n\nWhen Claude Code explores a codebase, it spawns **Explore agents** that scan files with grep, glob, and Read — consuming tokens on every tool call.\n\n**CodeGraph gives those agents a pre-indexed knowledge graph** — symbol relationships, call graphs, and code structure. Agents query the graph instantly instead of scanning files.\n\n### Benchmark Results\n\nTested across 6 real-world codebases comparing Claude Code's Explore agent **with** and **without** CodeGraph:\n\n> **Average: 92% fewer tool calls · 71% faster**\n\n| Codebase | With CG | Without CG | Improvement |\n|----------|---------|------------|-------------|\n| **VS Code** · TypeScript | 3 calls, 17s | 52 calls, 1m 37s | **94% fewer · 82% faster** |\n| **Excalidraw** · TypeScript | 3 calls, 29s | 47 calls, 1m 45s | **94% fewer · 72% faster** |\n| **Claude Code** · Python + Rust | 3 calls, 39s | 40 calls, 1m 8s | **93% fewer · 43% faster** |\n| **Claude Code** · Java | 1 call, 19s | 26 calls, 1m 22s | **96% fewer · 77% faster** |\n| **Alamofire** · Swift | 3 calls, 22s | 32 calls, 1m 39s | **91% fewer · 78% faster** |\n| **Swift Compiler** · Swift/C++ | 6 calls, 35s | 37 calls, 2m 8s | **84% fewer · 73% faster** |\n\n\nFull benchmark details\n\nAll tests used Claude Opus 4.6 (1M context) with Claude Code v2.1.91. Each test spawned a single Explore agent with the same question.\n\n**Queries used:**\n| Codebase | Query |\n|----------|-------|\n| VS Code | "How does the extens
FAQ (5)
feature_inquiryDoes Codegraph automatically sync after code changes?
Yes, Codegraph automatically syncs on every file change starting from version 0.9.4, when the MCP server is running. It uses a built-in FileWatcher that incrementally re-indexes symbols and edges within ~3 seconds, with no manual codegraph sync or codegraph index commands required. In earlier versions, you needed to manually run codegraph index to update after code changes.
TroubleshootingWhy does codegraph show 0 callers for components imported through barrel re-exports?
This is a known bug in codegraph v0.9.8 and earlier where certain barrel forms are not resolved, causing missing edges and false 0 callers/impact for live components. Affected forms: export { default as X } from './X.svelte', bare import from './' or from '.', and workspace package-subpath imports (@scope/pkg/sub). The fix (PRs #657, #659) is already merged and ships in the next release after v0.9.8. Upgrade to the latest version (v0.9.9+) to resolve. As a temporary check, use codegraph callees <file> to see if the import appears as a raw/unresolved node.
TroubleshootingWhy do console windows flash when starting codegraph daemon or switching branches on Windows?
Upgrade to codegraph v0.9.7 or later. This bug in v0.9.6 caused git.exe spawns (e.g., git ls-files, git rev-parse) to run without windowsHide: true, making cmd windows visible. The fix in v0.9.7 added windowsHide to all git/npm child processes, eliminating flashes.
TroubleshootingWhy does a console window flash every second when running codegraph MCP server on Windows?
In codegraph v1.6.1 on Windows, the default file watcher runs git ls-files about once per second. When the MCP host is started by a GUI process with CREATE_NO_WINDOW, Node.js spawns git.exe without windowsHide: true, causing Windows to create a visible conhost window each time. As a workaround, disable the watcher:
codegraph serve --mcp --no-watch
Then refresh the index manually when needed:
codegraph sync
The permanent fix is for the watcher/git spawn calls to pass windowsHide: true to Node.js spawn/exec; upgrade to a release containing that fix if available.
TroubleshootingWhy does codegraph miss callers and callees for chained method calls in Delphi/Object Pascal?
This is a known bug in codegraph 1.6.2: the Delphi extractor only records the outer method of a chained call like MD5FileSized(TMeta.ExtendedPath(APath)).IsSame(AKey), dropping the receiver call (MD5FileSized) and calls inside its arguments (ExtendedPath). Fixed by PR #2787 (merged to main), which indexes the receiver call and its argument calls for both expression and paren-less statement forms, plus typecast receivers like TButton(Sender).Caption. Upgrade to the release after 1.6.2. As a temporary workaround, patch lib/dist/extraction/tree-sitter.js: in extractPascalCall add this.extractPascalCall(innerCall); after the receiver-name handling (~line 7317), and in extractPascalParenlessCall add if (receiver.type === 'exprCall') this.extractPascalCall(receiver); in the non-class receiver branch (~line 7411).