colbymchenry / codegraph

CodeGraph: Supercharge Claude Code with Semantic Code Intelligence

CodeGraph: 利用语义代码智能为 Claude Code 提速增效

94% fewer tool calls · 77% faster exploration · 100% local 工具调用减少 94% · 探索速度提升 77% · 100% 本地运行

Get Started

快速开始

npx @colbymchenry/codegraph Interactive installer configures Claude Code automatically. 交互式安装程序可自动配置 Claude Code。

Initialize Projects 初始化项目 cd your-project codegraph init -i


Why CodeGraph?

为什么选择 CodeGraph?

When Claude Code explores a codebase, it spawns Explore agents that scan files with grep, glob, and Read — consuming tokens on every tool call. 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.

当 Claude Code 探索代码库时,它会生成探索代理(Explore agents),通过 grep、glob 和 Read 命令扫描文件——这会在每次工具调用时消耗大量 Token。CodeGraph 为这些代理提供了一个预先索引的知识图谱,包含符号关系、调用图和代码结构。代理可以直接查询图谱,而无需扫描文件。


Benchmark Results

基准测试结果

Tested across 6 real-world codebases comparing Claude Code’s Explore agent with and without CodeGraph: 在 6 个真实代码库中对比了使用与不使用 CodeGraph 的 Claude Code 探索代理:

Average: 92% fewer tool calls · 71% faster 平均:工具调用减少 92% · 速度提升 71%

CodebaseWith CGWithout CGImprovement
VS Code · TypeScript3 calls, 17s52 calls, 1m 37s94% fewer · 82% faster
Excalidraw · TypeScript3 calls, 29s47 calls, 1m 45s94% fewer · 72% faster
Claude Code · Python + Rust3 calls, 39s40 calls, 1m 8s93% fewer · 43% faster
Claude Code · Java1 call, 19s26 calls, 1m 22s96% fewer · 77% faster
Alamofire · Swift3 calls, 22s32 calls, 1m 39s91% fewer · 78% faster
Swift Compiler · Swift/C++6 calls, 35s37 calls, 2m 8s84% fewer · 73% faster

Full benchmark details: All 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. 完整基准测试详情:所有测试均使用 Claude Opus 4.6 (1M 上下文) 和 Claude Code v2.1.91。每个测试均生成单个探索代理,并使用相同的问题。


Key observations:

关键观察:

  • With CodeGraph: The agent never fell back to reading files — it trusted the codegraph_explore results completely. 使用 CodeGraph: 代理无需回退到读取文件,它完全信任 codegraph_explore 的结果。
  • Without CodeGraph: Agents spent most of their time on discovery (find, ls, grep) before they could even start reading relevant code. 不使用 CodeGraph: 代理在开始读取相关代码之前,大部分时间都花在发现(find, ls, grep)上。
  • Cross-language queries (Python+Rust): Worked seamlessly — CodeGraph’s graph traversal found connections across language boundaries. 跨语言查询(Python+Rust): 运行顺畅——CodeGraph 的图遍历发现了跨语言边界的连接。
  • Swift Compiler benchmark: The largest codebase tested (25,874 files, 272,898 nodes) — CodeGraph indexed it in under 4 minutes and the agent answered a complex cross-cutting question with 6 explore calls and zero file reads in 35 seconds. Swift 编译器基准测试: 这是测试中最大的代码库(25,874 个文件,272,898 个节点)——CodeGraph 在 4 分钟内完成了索引,代理在 35 秒内通过 6 次探索调用且零文件读取,回答了一个复杂的跨领域问题。

Key Features

核心功能

  • Smart Context Building: One tool call returns entry points, related symbols, and code snippets — no expensive exploration agents. 智能上下文构建: 一次工具调用即可返回入口点、相关符号和代码片段——无需昂贵的探索代理。
  • Full-Text Search: Find code by name instantly across your entire codebase, powered by FTS5. 全文搜索: 基于 FTS5,在整个代码库中即时按名称查找代码。
  • Impact Analysis: Trace callers, callees, and the full impact radius of any symbol before making changes. 影响分析: 在进行更改之前,追踪任何符号的调用者、被调用者以及完整的影响范围。
  • Always Fresh: File watcher uses native OS events with debounced auto-sync — the graph stays current as you code, zero config. 实时更新: 文件监视器使用原生操作系统事件并配合防抖自动同步——图谱随你的编码实时更新,无需配置。
  • 19+ Languages: TypeScript, JavaScript, Python, Go, Rust, Java, C#, PHP, Ruby, C, C++, Swift, Kotlin, Dart, Svelte, Liquid, Pascal/Delphi. 支持 19+ 种语言: TypeScript, JavaScript, Python, Go, Rust, Java, C#, PHP, Ruby, C, C++, Swift, Kotlin, Dart, Svelte, Liquid, Pascal/Delphi。
  • 100% Local: No data leaves your machine. No API keys. No external services. SQLite database only. 100% 本地运行: 数据不出本地。无需 API 密钥。无需外部服务。仅使用 SQLite 数据库。

Framework-aware Routes

框架感知路由

CodeGraph detects web-framework routing files and emits route nodes linked by references edges to their handler classes or functions. Querying callers of a view/controller now surfaces the URL pattern that binds it. CodeGraph 可以检测 Web 框架的路由文件,并生成通过引用边连接到处理程序类或函数的路由节点。现在,查询视图/控制器的调用者时,会显示绑定它的 URL 模式。

Supported Frameworks: Django, Flask, FastAPI, Express, Laravel, Rails, Spring, Gin/chi/gorilla/mux, Axum/actix/Rocket, ASP.NET, Vapor, React Router / SvelteKit. 支持的框架:Django, Flask, FastAPI, Express, Laravel, Rails, Spring, Gin/chi/gorilla/mux, Axum/actix/Rocket, ASP.NET, Vapor, React Router / SvelteKit。


Quick Start

快速开始

  1. Run the Installer: npx @colbymchenry/codegraph 运行安装程序: npx @colbymchenry/codegraph The installer will: Prompt to install codegraph globally, configure the MCP server, set up permissions, and add global instructions. 安装程序将:提示全局安装 codegraph,配置 MCP 服务器,设置权限,并添加全局指令。
  2. Restart Claude Code: Restart Claude Code for the MCP server to load. 重启 Claude Code: 重启 Claude Code 以加载 MCP 服务器。
  3. Initialize Projects: cd your-project then codegraph init -i 初始化项目: 进入项目目录并运行 codegraph init -i

That’s it! Claude Code will use CodeGraph tools automatically when a .codegraph/ directory exists. 就是这样!当存在 .codegraph/ 目录时,Claude Code 将自动使用 CodeGraph 工具。