graphify: giving agents a knowledge graph instead of a file search
outcome structure once, query forever
Problem
Agents rediscover a codebase from scratch every session, burning tokens and time scanning files to answer “how does X connect to Y”, and their answers depend on what they happened to read.
What I built
A Python CLI plus companion MCP server that turns any input (code, docs, papers, images, video) into a persistent knowledge graph: extracted and inferred edges, god-node detection, community structure, and a readable graph report. Agents query the graph (neighbours, shortest path, communities) rather than grepping.
The graph rebuilds automatically on every commit, and a pre-tool-use hook intercepts file-search commands to remind the agent the graph exists. The workspace enforces a three-layer retrieval rule: graph first, persistent memory second, raw files last.
Techniques that made it work
- Retrieval architecture as harness engineering: the hook changes agent behaviour without changing any prompt
- Knowledge compounding: the graph persists and grows across sessions instead of resetting
Outcome
Structural questions answered by graph traversal instead of file scanning, cheaper and more consistent agent runs, and a pattern that transfers to any organisation’s codebase or document estate.