XERJ Explained: The Rust Search Engine That Lets Your Agent Reuse Open-Source Code
XERJ is a local-first AI search engine and MCP server in one Rust binary that indexes code, docs, logs and PDFs for BM25, vector and hybrid search. Coding agents use it to find and reuse open-source solutions before writing code, with an Elasticsearch-compatible API and no JVM required.

Key facts
- Project: XERJ — “AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.”
- Stars: 21,411 stars and 1,330 forks, with 4,655 commits.
- Star velocity: +1,069 stars in the 24 Nov window, #6 on GhTrends daily for 25 Nov 2026.
- Licence: Apache-2.0 for the engine source.
- Created: 2026-06-30, with 734 releases and 734 tags,
mainas default branch. - Core idea: Index code, docs, logs, JSONL/CSV and PDFs in one binary, then search with BM25, vector or hybrid queries.
- Works with: Claude Code, Cursor and any MCP client, local-first by default.
- API: Elasticsearch-compatible, so existing clients keep working.
What is XERJ and how does it work?
XERJ is a search engine built for bots and agents first, not for a website search box. One Rust binary indexes your code, documents, logs and data files, then answers full-text, vector and hybrid queries. Because it speaks the Elasticsearch API, existing tools can talk to it directly.
The local-first design matters. The index lives on your machine, there is no JVM and no external service, and Corpus Hub can serve hundreds of reference memory corpora. If you follow agent tooling on the KongoTech homepage, the pattern is familiar: better context, better code, fewer tokens.
Three modes cover most needs. BM25 handles exact words, vector search handles meaning, and hybrid search combines both. For code, the agent receives ranked passages with file and line numbers instead of whole files grepped into context, so it reads only what matters.
What is reference coding and how much does it save?
Reference coding is the main use case: point an agent at a task, let it download the open-source repositories closest to it, index them with XERJ, and reuse how those projects solved the problem before writing its own code. The agent still writes the final code, but starts from proven implementations.
The savings are measured. In a controlled study across 8 tasks and 4 languages, with 16 runs per arm and real token counts from code the model had not memorised, memory alone used 260,916 output tokens and $11.18 while solving 11 of 16 tasks. A grep-driven agent used 26,477 tokens and $3.27 while solving 16 of 16. With XERJ, the agent used 9,982 tokens and $1.58 while also solving 16 of 16. That is 2.7 times fewer output tokens than grep and 26 times fewer than memory alone, with up to 278 times fewer on a single Java task. Users report roughly 5 times fewer tokens end to end, and a companion run solved 9 of 9 tasks with retrieval against 0 of 9 from memory on an unseen Rust library.
The honest limit: reference coding wins on private, internal, niche and post-cutoff code, and is neutral to harmful on popular public libraries the model knows. Grep also pulls whole files into context, up to 1.06 million input tokens on one corpus, while XERJ returns only relevant passages.

What does autoindex do?
autoindex turns a messy folder into searchable data, with no schema or pipeline to configure. Run xerj autoindex <folder> and it sniffs every file, infers a type per dataset, and builds one typed, queryable index per dataset. Code is parsed with tree-sitter, preserving symbols and line numbers for go-to-definition lookups.
In one example run, phase A inferred 593 datasets and skipped 1,955 junk files, then phase B indexed 25,329 files with 8 workers in 158.1 seconds, leaving 593 datasets and 83,103 records live. Indexing a whole project feels like a build step, not data engineering.
Coverage is broad: CSV, JSON, JSONL, XML, YAML, SQLite, PDF, DOCX, PPTX (one record per slide), XLSX (one dataset per sheet), EPUB (per chapter), Jupyter (per heading section), man pages, HTML, mail (.eml/mbox including Google Takeout), common log formats, and Unity projects (one record per GameObject or Component). For a map, xerj autoindex map --prefix myproject --html xerj-map.html --redact-paths exports HTML, or use --md for Markdown.
How do you search with XERJ?
You search through three doors to the same index. The Elasticsearch API listens on localhost:9200, where _cat/indices lists indices and _search accepts q=, range queries and aggregations. Vector and hybrid search use the same knn and semantic syntax, so any Elasticsearch client works.
The command line is faster for everyday questions. xerj search "how do we rotate the WAL segment" returns ranked passages with file and line references, xerj def "euler_to_rotationmatrix" jumps to a definition, xerj gain counts savings, and xerj batch-search --input queries.json runs many queries at once, mirrored in MCP as xerj_batch_search. xerj init wires XERJ into Claude Code or Cursor with MCP and a skill in one command.
This agent-first wiring matches other tools here: AG-UI lets an agent and an interface talk through a shared protocol, and Stitch Skills for Google Stitch teaches an agent to use a design tool. XERJ does the same for search: the agent asks, and the index answers with evidence.

How do you install XERJ?
Installation is one command per platform, because XERJ is a single static binary with no JVM and no dependencies. On Linux or macOS, run curl -fsSL https://xerj.org/get | sh. On Windows PowerShell, run irm https://xerj.org/get.ps1 | iex. With Nix, run nix run github:xerj-org/xerj -- --version. Builds cover Linux, macOS and Windows on x86-64 and arm64; x86-64 builds target x86-64-v2 with AVX2 and FMA when present.
Starting takes two steps: xerj --insecure --data-dir ~/xerj-data &, then xerj autoindex ~/my-project. Keep the data directory outside indexed folders. A one-prompt install text also exists, beginning “Install XERJ (docs: https://xerj.org/llms.txt), index this project’s sources…”, which lets an agent do the setup.
For Query-1, install with curl -fsSL https://xerj.org/get | sh -s -- --with-model. It stays off unless you point XERJ at it.
What is XERJ Query-1?
Query-1, new in rc.101, answers over stored facts instead of passages. The model turns your question into a small program, runs it over the facts, and returns an answer pointing at the stored fact and its quoted span. Counts return a program hash, the engine answers UNKNOWN when data cannot support an answer, and CONFLICT when facts disagree. It runs offline on 4 CPU cores with no embeddings and no GPU.
Measured results are strong. Across 160 questions on rc.101 with 4 threads on a laptop CPU, Query-1 answered in 220 ms at p50 against 1.5 to 2.3 seconds for RAG with Opus 5.5, with 1 wrong answer out of 160 (124 right, 35 declined) against 9 to 15 wrong for RAG. Cost was $42 per million questions on CPU against $13,400 to $694,000, and correcting a fact took 2.3 ms.
Limits are clear. Sums and totals are not supported yet, and a sum can come back as a member count. Large fact sets decline: on a 95,000-fact namespace the median was 0.82 seconds and all 20 test questions were declined. Query-1 declines more than an LLM would guess, which is safer but less complete. The engine is open source; the model ships as a binary bundle in release builds only, with proprietary model crates not in the public source build, off by default via --facts-model-dir, and training and evaluation data not public yet.

What else can XERJ do?
Agent memory is the second major use. The /_memory/{namespace} endpoint stores what an agent learns and recalls it by meaning next session. The same index powers codebase Q&A and RAG, security audits for sink patterns, secrets and dangerous calls, and log analysis with Elasticsearch-style aggregations.
Two optional features need a caveat. Jev rerank reorders results but sends result text to TypeSafe servers, staying off until you set a key, so data leaves the machine when enabled. The local /_decide endpoint classifies text on your hardware, reaching 92% on AG News with 120,000 labelled examples. What Is Univer covers a similar local-first SDK idea.
The community ask is small: run XERJ, then send one short field report as a commit or pull request. Field-report pull requests are CLA-exempt.
What should you watch out for before you start?
The security boundary matters most. The --insecure flag turns off TLS and API-key authentication, and every caller becomes a superuser who can read and delete every index, including /_memory. It is meant for one user on a development machine, and a fresh node binds to 127.0.0.1 only. Without --insecure, authentication is default: a key is minted on first boot, and you pass --api-key or set XERJ_API_KEY, or requests receive 401. Treat --insecure as a local convenience, never a network setting.
Fit matters too. Reference coding helps most on private, internal, niche and post-cutoff code, and can hurt on popular public libraries the model knows. Query-1 declines large fact sets and cannot sum yet, so keep RAG for those questions. Pin a release, since the project already has 734 releases, and re-run autoindex after big changes.
Start small and measure. Index one project, run xerj gain after a few tasks, and compare token counts against grep. If the numbers hold, expand; if not, you have lost an afternoon.
Frequently asked questions
What is XERJ?
XERJ is a local-first AI search engine and MCP server in one Rust binary that indexes code, docs, logs, JSONL/CSV and PDFs for BM25, vector and hybrid search, with an Elasticsearch-compatible API, agent memory and RAG. It works with Claude Code, Cursor and any MCP client.
How much does reference coding save?
In the controlled study, XERJ used 9,982 output tokens and $1.58 to solve 16 of 16 tasks, against 26,477 tokens and $3.27 for grep and 260,916 tokens and $11.18 from memory alone. That is 2.7 times fewer tokens than grep and 26 times fewer than memory, with users reporting roughly 5 times fewer end to end.
How do I install XERJ?
On Linux or macOS, run curl -fsSL https://xerj.org/get | sh. On Windows PowerShell, run irm https://xerj.org/get.ps1 | iex. With Nix, run nix run github:xerj-org/xerj -- --version. Then start with xerj --insecure --data-dir ~/xerj-data & and index with xerj autoindex ~/my-project.
Is XERJ free and open source?
Yes, the engine source is Apache-2.0. The Query-1 model is the exception: it ships as a binary bundle in release builds only, with proprietary model crates not in the public source build, off by default until enabled with --facts-model-dir.
Is the –insecure mode safe?
Only for one user on a development machine. The --insecure flag turns off TLS and API-key authentication, so every caller is a superuser who can read and delete every index. A fresh node binds to 127.0.0.1 only, and without the flag authentication is on by default.