CodeGraph — 预索引代码知识图谱工具。为 Claude Code、Cursor、Codex、Gemini、OpenCode、Hermes、Antigravity 等提供语义代码智能。
Local-first code intelligence tool. tree-sitter parsing → SQLite (FTS5) storage → MCP exposes knowledge graph.
Use when users need to install CodeGraph, initialize code graph, index projects, understand code structure, trace call chains, evaluate change impact.
bash
npx @colbymchenry/codegraph # Recommended: one-click install + auto-configure Agent
curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh # No Node required
npm i -g @colbymchenry/codegraph # npm
Non-interactive: codegraph install --yes [--target=claude,cursor] [--location=local]
bash
cd your-project
codegraph init -i # Create .codegraph/ + build index
codegraph index # Full index (or rebuild: --force)
codegraph sync # Incremental sync (changed files only)
codegraph status # Check status
Tool selection guide is automatically sent to Agent in MCP
initializeresponse.
IntentToolKey ParametersAlmost any question — architecture, flow, bug, investigationcodegraph_explore ⭐query (natural language or symbol names)Locate symbol by namecodegraph_search``query, kind, limitCall chaincodegraph_callers / codegraph_callees``symbol, limitChange impactcodegraph_impact``symbol, depthSingle symbol full source / overload disambiguationcodegraph_node``symbol, includeCode, file, lineFile structurecodegraph_files—Index healthcodegraph_status—
codegraph_explore is the PRIMARY tool — call it first, usually the only call needed. Returns relevant symbol source code (grouped by file), with line numbers.explore > search + node chained calls.❌ Don't use grep to verify codegraph results (AST is more accurate than grep)
❌ Don't chain search + node to understand an area (one explore does it)
❌ Don't loop node over multiple symbols (one explore returns all)
⚠️ Check staleness banner after edits — pending files need direct Read
Three-layer protection: ① Native FS events + 2s debounce auto-sync ② Per-file staleness banner (pending files prefixed with ⚠️) ③ Auto-reconciliation on MCP reconnect.
Manual sync only needed in sandbox ( CODEGRAPH_NO_DAEMON=1) or CI pre-flight.
bash
codegraph query <symbol> [--kind class] [--limit 10] [--json]
codegraph callers <symbol> [--limit 20] [--json]
codegraph callees <symbol> [--limit 20] [--json]
codegraph impact <symbol> [--depth 2] [--json]
codegraph context "<task>" [--max-nodes 20]
codegraph affected <files...> [--stdin] [--depth 5] [--filter "e2e/*"] [--quiet]
Zero-config — no config files. Auto-excludes node_modules/ vendor/ dist/ build/ target/ .venv/ Pods/ .next + .gitignore entries + >1MB files. Exclude more: add to .gitignore; bring back: !vendor/.
Environment variables: CODEGRAPH_WATCH_DEBOUNCE_MS(2000) CODEGRAPH_NO_DAEMON CODEGRAPH_EXPLORE_LINENUMS(1) CODEGRAPH_ADAPTIVE_EXPLORE(1)
TS/JS/Python/Go/Rust/Java/C#/PHP/Ruby/C/C++/Swift/Kotlin/Scala/Dart/Svelte/Vue/Liquid/Pascal-Delphi/Lua/Luau
Django/Flask/FastAPI/Express/NestJS/Laravel/Drupal/Rails/Spring/Gin-chi-gorilla-mux/Axum-actix-Rocket/ASP.NET/Vapor/ReactRouter-SvelteKit — auto-recognize route files and generate route nodes.
Swift↔ObjC / RN legacy bridge / TurboModules / RN events / Expo Modules / Fabric-Paper views. Synthesized edges marked provenance:'heuristic'.
bash
codegraph uninstall # Remove MCP config
codegraph uninit # Delete .codegraph/