OpenSource-Hub

codegraph

CLI Tool

colbymchenry/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 (4)

feature_inquiry
Does 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.

GitHub Issue #393
Troubleshooting
Why 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.

GitHub Issue #629
Troubleshooting
Why 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.

GitHub Issue #612
How-to
How to change the default CodeGraph index directory from .codegraph to a custom path?

Use the --data-dir flag when running CodeGraph to specify a custom index directory. Example: codegraph --data-dir /path/to/custom/dir. This functionality is being added via PR #568.

GitHub Issue #672