colbymchenry/codegraph
codegraph
Pre-indexed code knowledge graph for Claude Code, Codex, Gemini, Cursor, OpenCode, AntiGravity, Kiro, and Hermes Agent — fewer tokens, fewer tool calls, 100% local.
Một repo trên github tạo ra một bản đồ code để AI Agent có thể dựa vào đó để có một cái nhìn tổng quan về code base. Truy cập nhanh và chính xác những phần code cần để sử dụng, không tìm kiếm lan man gây tốn token.
Codegraph làm việc với AI Agent thông qua MCP.
Có nhiều trường hợp AI Agent vẫn tự động dò code thay vì sử dụng codegraph. Để khắc phục mình thêm một phần vào guidelines của AI Agent.
Guidelines
## Code exploration
- ALWAYS prefer using the **codegraph** MCP tools (`codegraph_context`, `codegraph_search`, `codegraph_trace`, `codegraph_explore`, `codegraph_node`) to understand, navigate, and trace code whenever codegraph is available for the project (i.e. `.codegraph/` is indexed).
- Reach for raw Read/Grep/Glob exploration only to confirm a specific detail codegraph didn't cover, or when codegraph is not available for the current project.
Ở các phiên bản mới codegraph đã tự động thêm vào guidelines rồi.
Default guidelines
<!-- CODEGRAPH_START -->
## CodeGraph
In repositories indexed by CodeGraph (a `.codegraph/` directory exists at the repo root), reach for it BEFORE grep/find or reading files when you need to understand or locate code:
- **MCP tool** (when available): `codegraph_explore` answers most code questions in one call — the relevant symbols' verbatim source plus the call paths between them, including dynamic-dispatch hops grep can't follow. Name a file or symbol in the query to read its current line-numbered source. If it's listed but deferred, load it by name via tool search.
- **Shell** (always works): `codegraph explore "<symbol names or question>"` prints the same output.
If there is no `.codegraph/` directory, skip CodeGraph entirely — indexing is the user's decision.
<!-- CODEGRAPH_END -->
Cách sử dụng cơ bản.
# 1. Install the CLI (one-time)
**No Node.js required** — one command grabs the right build for your OS:
```bash
# 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
```
# 2. Wire up your agent(s) (one-time)
In a **new terminal**, run the installer to connect CodeGraph to the agents you use:
```bash
codegraph install
```
# 3. Work (each project)
```bash
cd your-project
codegraph init -i
```
```bash
codegraph status
```
# 4. Uninstall
```bash
codegraph uninstall
```
Chú ý khác
Bạn không cần chạy codegraph sync thủ công trong phiên làm việc của agent. Khi AI Agent khởi chạy codegraph serve --mcp, chúng sẽ phối hợp để giữ cho index luôn đồng bộ với code - và không bao giờ đưa ra câu trả lời sai cho AI Agent.