# codegraph

> A local code knowledge graph that lets AI coding agents look up code in one call

- Repository: https://github.com/colbymchenry/codegraph
- Category: Token & cost savings
- Stars: 74,838 · Forks: 4,855 · Language: C · License: MIT
- Experience: Some experience
- Page: https://ir.adyog.com/repos/colbymchenry/codegraph/

AI coding agents usually learn a codebase the slow way. They grep, glob and read files one at a time, then piece together who calls what. That takes many tool calls and uses a lot of tokens before the real work starts.

CodeGraph indexes your project ahead of time into a knowledge graph of symbols, call edges and dependencies. The graph lives in a local .codegraph/ folder and is served to the agent as an MCP server. The agent asks one question and gets back the relevant source, the call paths between symbols, and what a change could affect. A file watcher keeps the graph current as files change.

The README reports its own benchmarks on seven repos: 44% lower cost and 62% fewer tokens on average, with the biggest gains on questions that needed many tool calls. These are the author's numbers, so check them on your own code. Everything runs locally.

## What it does

- **Pre-built code graph**: Indexes every symbol, call edge and dependency in the project, so the agent doesn't have to crawl files with grep and Read.
- **Works with many agents**: `codegraph install` detects and configures Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity, Kiro and GitHub Copilot by wiring in an MCP server.
- **Auto-sync on changes**: It watches the project and updates the graph when files are added, edited or deleted, so there is nothing to re-run.
- **Broad language support**: It extracts structure and resolves cross-file links for over 30 languages, including TypeScript, Python, Go, Rust, Java, C#, Swift and Kotlin.
- **Local, with a clean uninstall**: The index stays in your project's .codegraph/ folder. `codegraph uninstall` removes the agent configs and the CLI, and `codegraph uninit` removes a project's index.

## What you could build

- Ask your coding agent who calls a function and get the answer from the graph instead of a long file search.
- Check what a planned change could break before editing, using the dependency and call paths.
- Cut token use and tool calls when working with an agent on a large codebase.
- Give several agents, such as Claude Code and Cursor, the same code index on one project.
- Explore an unfamiliar repo by asking an agent to trace how its parts connect.

## Who it's for

Developers who use AI coding agents on real codebases and are comfortable with a terminal and with MCP-based tool setup.

## Get started

Install the CLI (the README also gives a Windows PowerShell command and an npm option), then open a new terminal and run `codegraph install` to connect your agents. Then go into each project and run `codegraph init` to build its graph.

```
curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh
```
```
codegraph install
```
```
codegraph init
```

Tags: mcp, code-graph, coding-agents, token-savings, local
