TIL: Knowledge Graph Retrieval – Stop Codebase Re-Reads with Graphify & CodeGraph
Every time an AI coding agent starts a new session, it performs costly file searches and full-file reads («grep-and-read archaeology») to understand your codebase architecture. This process wastes thousands of context tokens on structure discovery alone.
The Solution: Local Codebase Indexing & Retrieval
Instead of forcing the model to re-read files from scratch, pre-index your repository locally using knowledge graph tools. This allows the agent to query structural relationships (functions, classes, schemas, imports) directly via scoped queries.
Two High-Impact Open-Source Tools
1. Graphify (by Safi Shamsi)
Parses source code into a queryable knowledge graph using tree-sitter (supporting 30+ languages). Check out the Graphify repository on GitHub.
- Key Feature: Integrates documentation and PDFs via local LLM extraction. Connects natively with 24+ harnesses via MCP for team sharing.
- Impact: Up to 71.5x fewer tokens consumed per codebase architectural query.
- Quick Start:
uv tool install graphifyy && graphify install
2. CodeGraph (by Colby McHenry)
A zero-maintenance, background code indexing tool stored in a local SQLite database with full-text search. Explore the CodeGraph repository on GitHub or find the npm package.
- Key Feature: Automatically watches file changes and re-syncs continuously in the background—no API keys required.
- Impact: Delivers 23–64% token savings and 58% fewer tool calls during repo navigation.
- Quick Start:
npm i -g @colbymchenry/codegraph
Rule of Thumb: Use Graphify if you need multimodal context, deep architectural relationships, or team MCP sharing. Use CodeGraph for set-it-and-forget-it local navigation that stays auto-synced.