codegraph README

The project's README from github.com/colbymchenry/codegraph. As one markdown file: README.md.

CodeGraph

Already installed? Run codegraph upgrade

Follow @getcodegraph on X for updates.

Supercharge Claude Code, Cursor, Codex, OpenCode, Hermes Agent, Gemini, Antigravity, Kiro, and GitHub Copilot with Semantic Code Intelligence

The fastest complete code graph · surgical context · built for how agents actually work · 100% local

Rust   **Kernel powered by Rust**

Documentation & Website →

npm version License: MIT Self-contained npm provenance Attested builds

Windows macOS Linux

Claude Code Cursor Codex opencode Hermes Agent Gemini Antigravity Kiro GitHub Copilot


The CodeGraph platform is coming — for every PR, know exactly what to test, what could break, which flows are affected, and whether business logic is compromised.

Join the waitlist for early beta access

Get early beta access to the hosted product · getcodegraph.com

Contents

Get Started

1. Install the CLI

No Node.js required — one command grabs the right build for your OS:

# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh

# Windows (PowerShell)
irm https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.ps1 | iex
Already have Node? Use npm instead (works on any version)
npm i -g @colbymchenry/codegraph

CodeGraph bundles its own runtime — nothing to compile, no native build, works the same everywhere. The installer puts codegraph on your PATH but doesn't change your current shell — open a new terminal before the next step so the command resolves.

Upgrade any time with codegraph upgrade — it detects how you installed (bundle, npm, or npx) and updates in place. Add --check to see if an update is available, or codegraph upgrade <version> to pin one.

2. Wire up your agent(s)

In a new terminal, run the installer to connect CodeGraph to the agents you use:

codegraph install

Detects and auto-configures Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity IDE, Kiro, and GitHub Copilot (VS Code, Copilot CLI, JetBrains IDEs) — wiring the CodeGraph MCP server into each. This is the step that connects CodeGraph to your agent; installing the CLI in step 1 does not do it on its own. It only wires up your agent — it does not index any code; building each project's graph is the separate codegraph init in step 3. (Shortcut: npx @colbymchenry/codegraph downloads and runs this in one go.)

3. Initialize each project

cd your-project
codegraph init

codegraph init creates the local .codegraph/ directory and builds the full graph in the same step — one command, done.

1_C_VYnhpys0UHrOuOgpgoyw

4. No more syncing!

Auto-sync is enabled by default. CodeGraph watches the project and updates the graph on every file change — while your agent edits code, or you add, modify, or delete files. The index is never stale, and there is nothing to re-run.

5. See what your agent sees

codegraph ui

Opens the graph in your browser at http://127.0.0.1:4747 — callers on the left, the symbol's source in the middle, what it calls on the right. See Read your graph in the browser.

Uninstall

Changed your mind? One command removes CodeGraph from every agent it configured and the CLI itself — every install it finds (standalone bundle, npm global package, launcher link), shown to you before anything is deleted:

codegraph uninstall

Pass --keep-cli to remove only the agent configurations and keep the CLI installed.

Reverses the installer — strips CodeGraph's MCP server config, instructions, and permissions from each configured agent. Your project indexes (.codegraph/) are left untouched; remove those per-project with codegraph uninit. Use --target to remove from specific agents, or --yes to run non-interactively.


Language Support

Every language below gets the same treatment — full structural extraction and cross-file resolution into one graph, no per-language setup:

TypeScript JavaScript ArkTS Python Go Rust Java C# PHP Ruby C C++ Objective-C Metal CUDA Swift Kotlin Scala Dart Svelte Vue Astro Liquid Pascal / Delphi Lua R Luau CFML COBOL Visual Basic .NET Erlang Solidity Terraform / OpenTofu Nix

Per-language details — extensions, frameworks, and what exactly gets extracted — in Supported Languages.


Why CodeGraph?

When an AI agent needs to understand code — to answer a question or make a change — it discovers structure the slow way: grep, glob, and Read, one file at a time, rebuilding call paths and dependencies by hand. That's a pile of tool calls and round-trips before it even starts the real work.

CodeGraph hands the agent the exact code it needs in one call. It's a pre-built knowledge graph of every symbol, call edge, and dependency in your codebase — so instead of crawling files, the agent asks one question and gets back the relevant source, the call paths between those symbols (including dynamic-dispatch hops grep can't follow), and the blast radius of a change. Surgical context, not a file-by-file search — which means fewer tool calls and faster answers on every codebase, large or small.

token-cost-savings-scale

A note on cost: CodeGraph's win on every codebase is precision — the agent stops crawling files and answers from the graph. On current models that precision is also a large direct saving: the 2026-08 re-measurement, on a harness that blocks the CLI in both arms, put it at 44% lower cost and 62% fewer tokens on average across the seven benchmark repos, because a strong model without the graph burns its budget re-deriving structure. Cost tracks how much discovery a question demands more than raw repo size: 57–78% on questions the file-reading agent needed 28–43 tool calls to answer, near-even where it got there in 7.

A note on context: the numbers above measure throughput — tokens processed, tools called, dollars spent to reach one answer. They don't measure what is still sitting in your context window afterward, and on that axis CodeGraph costs more, not less. Across the same seven repos in multi-turn sessions, CodeGraph's responses leave about 80% more retrieval context resident at the end of a session than a file-reading agent's do — on VS Code, 67k tokens against 18k. The mechanism is the same one that makes it fast: CodeGraph returns one dense, verbatim payload that answers the question and then stays in the window, where a grep-and-read agent churns through many small results that get evicted. Fewer tokens processed and a larger persistent footprint are both real at once. If you run long sessions in a small window, budget for it. Measured per-repo: docs/benchmarks/residual-context-occupancy.md.

Benchmark Results

Tested across 7 real-world open-source codebases spanning 7 languages, comparing an agent (Claude Code, headless) answering one architecture question with and without CodeGraph, at the median of 4 runs per arm. Re-measured 2026-08-05 on Claude Opus 4.8 against the current build, on a harness that blocks the codegraph CLI in both arms — contamination row: 0 of 28 without-arm runs.

The universal win — every repo, every size: 88% fewer tool calls · 53% faster · 62% fewer tokens · 44% cheaper · file reads cut to zero on all seven repos.

With the index available, the agent answers from one to four codegraph_explore calls and stops. Without it, the agent burns its budget on discovery — up to 43 tool calls and 19 file reads re-deriving what the graph already knew. Every repo was faster with CodeGraph in this measurement — by 35% on the narrowest question, by 3.6× on the widest.

Codebase Language Tool calls Time File reads Tokens Cost
VS Code TypeScript · ~11k files 2 vs 28 2.2× faster (58s vs 2m 10s) 0 vs 12 77% fewer 71% cheaper
Excalidraw TypeScript · ~640 2 vs 43 3.6× faster (45s vs 2m 42s) 0 vs 18 84% fewer 78% cheaper
Django Python · ~3k 3 vs 14 35% faster (54s vs 1m 23s) 0 vs 8.5 41% fewer 13% cheaper¹
Tokio Rust · ~790 3 vs 29 2.6× faster (1m 3s vs 2m 43s) 0 vs 19 65% fewer 64% cheaper
OkHttp Java · ~645 1 vs 6 43% faster (33s vs 58s) 0 vs 2 54% fewer 21% cheaper
Gin Go · ~110 1 vs 7 39% faster (28s vs 46s) 0 vs 4 52% fewer ~even¹
Alamofire Swift · ~110 4 vs 33 2.6× faster (54s vs 2m 22s) 0 vs 16.5 59% fewer 57% cheaper

¹ Cost tracks how much discovery the question demanded, which is why it varies far more than the other columns: 57–78% on repos where the file-reading arm needed 28–43 tool calls, but only 13% on Django and even on Gin, where it got there in 14 and 7. The with-arm still answered in 3 and 1 calls with zero file reads. File reads = median files opened — the surgical-context win in one column: the agent never reads a file on any of the seven repos when CodeGraph is present.

Per-repo breakdown — WITH vs WITHOUT (median of 4)
Codebase Metric WITH cg WITHOUT cg
VS Code Time / Tools / Tokens / Cost 58s / 2 / 155k / $0.53 2m 10s / 28 / 670k / $1.80
Excalidraw Time / Tools / Tokens / Cost 45s / 2 / 156k / $0.54 2m 42s / 43 / 991k / $2.43
Django Time / Tools / Tokens / Cost 54s / 3 / 183k / $0.55 1m 23s / 14 / 309k / $0.63
Tokio Time / Tools / Tokens / Cost 1m 3s / 3 / 201k / $0.66 2m 43s / 29 / 573k / $1.83
OkHttp Time / Tools / Tokens / Cost 33s / 1 / 107k / $0.39 58s / 6 / 230k / $0.50
Gin Time / Tools / Tokens / Cost 28s / 1 / 87k / $0.31 46s / 7 / 180k / $0.31
Alamofire Time / Tools / Tokens / Cost 54s / 4 / 209k / $0.54 2m 22s / 33 / 505k / $1.27
Full benchmark details

Methodology. Each arm is claude -p (Claude Opus 4.8, claude-opus-4-8) run headlessly against the repo with --strict-mcp-config: WITH = CodeGraph's MCP server enabled, WITHOUT = an empty MCP config. Built-in Read/Grep/Bash stay available to both. Same question per repo, 4 runs per arm, median reported. Cost = the run's total_cost_usd; Tokens = total tokens processed, summed per assistant turn (input incl. cache reads + cache creation + output); Time = wall-clock; Tool calls = every tool invocation, including those inside any sub-agents the model spawns. Repos cloned at --depth 1 and indexed by the same CodeGraph build that served them. Re-measured 2026-08-05 on the current build.

The codegraph CLI is blocked in both arms. A sanitized PATH plus a PreToolUse hook denies any Bash invocation of the CLI, in the WITHOUT arm as well as the WITH arm. This matters: without that block the control arm is not a control. On an unblocked harness we measured the WITHOUT agent finding the CLI on PATH and reaching CodeGraph through Bash in 26 of 28 runs — which distorts the comparison in both directions, since a CLI call is not counted as a tool call and its output still enters the window. Earlier published figures were produced without this block. In the run reported above, all 28 WITHOUT runs attempted the CLI and all 28 were blocked — 0 contaminated.

Queries:

| Codebase | Query | |----------

codegraph (colbymchenry/codegraph)

Searching Database…

74.3K ·GitHub
这是干什么的?CodeGraph 会把你的代码库预先索引成一张知识图谱,涵盖每个符号、每次调用关系和每条依赖,AI 编程助手只需一次调用就能拿到恰好需要的代码,而不用一层层翻文件。
它是一个独立的应用,还是装在我的编程助手里面的东西?它是一个命令行工具加一个 MCP 服务器:codegraph 命令负责构建并提供这张图谱,你的助手则通过 MCP 工具调用从里面拉取上下文。
把它接进我的助手需要做什么?三步:安装 CLI(一条命令,或者用 npm),运行 agent 安装器把你用的那些助手连上,然后在每个项目里执行 codegraph init 生成完整图谱。
我需要先装 Node 或者其他东西吗?主安装不需要:一键安装器会下载一个自带运行时的独立版本,不用编译任何东西。如果你已经装了 Node,也可以改用 npm。
它号称省 token —— 那上下文窗口也会更小吗?奇怪的是并不会:处理的 token 数确实下降了(平均少 62%),但这些密集的答案会让会话结束时约多出 80% 的检索上下文常驻内存,所以小窗口下的长会话需要规划好预算。
在我的 Mac 上能跑吗,还是只有 Linux 能用?macOS、Windows 和 Linux 都有独立版本——安装器会根据你的操作系统自动选对,npm 则覆盖任何已经装了 Node 的机器。
我的代码会被上传到什么地方吗?不会——索引和查询完全在你自己的电脑上运行,README 自己的宣传语就是 100% 本地。
它能接进哪些编程助手?安装器会自动配置 Claude Code、Cursor、Codex CLI、opencode、Hermes Agent、Gemini CLI、Antigravity IDE、Kiro 和 GitHub Copilot(VS Code、Copilot CLI、JetBrains IDE)。
我的助手每次改完代码,都要重新建一次索引吗?不用——自动同步默认开启:CodeGraph 会监视项目,文件一有变动就更新图谱,索引永远不过期,也不需要手动重跑什么。
我自己能浏览这张图谱吗,还是只能给助手用?你可以在浏览器里打开:左边是这个符号的调用方,中间是它的源码,右边是它调用的东西。
实际用起来到底有多大提升?在七个真实仓库(VS Code、Excalidraw、Django、Tokio 等)的基准测试中,助手的工具调用减少了 88%,速度快了 53%,文件读取降到了零。
Size
37.7 MB
Stars
74.3K
Age
8mo
Commits · 90 Days