The cost this index tracks has one cause and one cure. The cause: an AI agent that needs one function or one paragraph finds it by reading, opening whole files into a paid context window until it stumbles on the passage. The cure: an index on the agent's own machine that answers "where is it" first, so the agent reads only the passage. The word for the second habit is retrieval-first.
| Step | Reading whole files | Retrieval-first |
|---|---|---|
| Find | grep the tree, open candidates, read them | ask the index; get file, line and symbol back in milliseconds |
| Read | the whole files, 103–244 KB behind one answer in our measurement | the passage, 5–6 KB |
| Pay | for every byte loaded, every time | for the passage; the index is built once and updated incrementally |
| Privacy | files travel to wherever the model runs | the index lives on the machine; with a local model, nothing leaves it |
Three ordinary questions on one production Next.js codebase, September 2026: 103,023, 243,640 and 241,859 bytes of whole files behind the answers against 6,405, 6,389 and 5,101 bytes read through the index, a 16×, 38× and 47× difference (Table 2 of the national release). On published coding tasks, retrieval-first reduced output tokens 2.7× end to end at the same solve rate (reference-coding case study). The index uses the conservative 63 % as its avoidable share.
XERJ is an open-source local search engine for AI agents: one static Rust binary, Elasticsearch-compatible on port 9200, that indexes any folder with one command, returns passages and pointers, keeps agent memory across sessions, and speaks the Model Context Protocol so any agent can call it. Apache-2.0. Source and releases: github.com/xerj-org/xerj. Instructions for an agent: xerj.org/llms.txt.
curl -fsSL https://xerj.org/get | sh xerj --insecure --data-dir ./.xerj-data & xerj autoindex . xerj search "the question you were about to grep"
Four commands, one folder, no cloud key. The installer verifies a SHA-256 checksum before it installs anything.
The xerj-memory plugin for Claude Code adds XERJ as local memory, teaches the agent to retrieve before it reads, and prints a score card at the end of every session: bytes read through the index against the whole files behind them, and an image you can post. Counts only; nothing leaves the machine.
/plugin marketplace add nikolaichuk7/xerj-plugins /plugin install xerj-memory@xerj-plugins
The offline agent goes one step further: XERJ as memory, an open model served locally as the brain, and a 120-line loop between them. It answers questions about your code with file and line, with the network cable unplugged. That is the configuration a ship, an embassy, a hospital and a classified network need.
A pilot fits on one laptop and needs no procurement: install, index a folder of non-sensitive material, ask questions for a week, read the score card. Nothing is sent anywhere. State and agency offices can request a one-page memo with their figures at [email protected].
XERJ on GitHubxerj.orgClaude Code pluginNational release