C
ChaoBro

codegraph: Pre-Indexed Code Knowledge Graph for Coding Agents

codegraph: Pre-Indexed Code Knowledge Graph for Coding Agents

When using Claude Code, every time you ask "how is feature X implemented in this project," it first runs a bunch of grep, read, and ls to familiarize itself with the code structure. Each tool call burns tokens.

codegraph's idea is direct: pre-index the code structure into a knowledge graph. When the agent asks questions, it queries the graph directly instead of scanning files on the fly.

After launch, the project gained 4600+ stars in a week on GitHub, now at 6.9k. The latest commit was 43 minutes ago — the author practically lives in the repo.

Why This Matters

The biggest overhead for coding agents on unfamiliar projects isn't "reasoning" — it's "exploration." The agent doesn't know which file contains what, so it reads them one by one. On a medium-sized project, an agent's first conversation might read dozens of files, easily burning through 10k+ tokens.

codegraph front-loads this process. It pre-scans the entire codebase and builds a dependency graph of files, classes, and functions. When the agent asks questions, it queries the graph for structured info instead of reading raw code.

Compatibility

This is the smartest part. It doesn't lock into any single agent platform: Claude Code, OpenAI Codex, Cursor, OpenCode. Through MCP (Model Context Protocol), any MCP-supporting agent can connect.

Architecture

TypeScript, 275 commits, latest 0.7.12. Insane update frequency.

Two-step process: (1) Index phase — scan the project, extract file structure, function signatures, dependency relations, store in local graph database. (2) Query phase — agent queries the graph via MCP for structured information.

Limitations

Not every project needs this. If your project has only dozens of files, Claude Code's built-in exploration is fine. codegraph's value shows on larger projects — hundreds of files, multi-layer directories, complex dependencies.


Main sources: