Someone on r/vibecoding ran a clever experiment. They used Git's built-in content hashing to cache facts about a codebase, and it cut AI agent token costs by 51%.
The approach is simple. Spend roughly one cent on Claude Haiku to scan your repo and write short facts like "HTTP calls are only in src/api/". Pin those facts to specific Git blob OIDs using a Merkle root. When a file changes, its blob OID changes, the Merkle root breaks, and the claim gets marked as stale. The agent never sees outdated information.
The experiment, documented in the h5i-dev/h5i GitHub repository, tested this on a 28-file Python codebase. The task was adding structured logging. Five trials with Claude Opus 4.7 showed consistent results. Total cost dropped from roughly $4.35 to $2.13 per session. Cache-write tokens fell 61%. Output tokens fell 52%. Wall time improved 16%. All five trials completed successfully with no missed edits or wrong files.
The real token sink in agent sessions is the exploration phase. That's where the model burns tokens running Grep and Read tools just to figure out where things are. Pre-loading verified facts into the cached prefix lets the agent skip that orientation step and go straight to work.
A commenter named aleksiy described a similar approach called "recursive summarization," where the agent builds a tree of summaries at each folder level. Different goal though. They were fixing hyper-focused agents, not cutting token costs.
Scaling it to real production repos with thousands of files is where things get messy. Managed agent platforms aim to handle this complexity, but this caching method offers a lightweight alternative.
But for the specific problem of agents re-learning the same codebase every session, this is a practical fix with real numbers behind it.