xerj-code
What it does
Finds working reference implementations in open-source code, indexes them locally, and retrieves the exact passage before new code is written. It is for developers working with an unfamiliar library or porting an algorithm.
When to use it
- βWhen you start a task in an API you do not know well.
- βWhen you are porting an algorithm and need the reference version.
- βWhen you have already tried the same fix twice and it keeps failing.
Skill link
https://github.com/xerj-org/xerj/blob/main/tools/xerj-code/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βI keep getting errors using this library's seal function. Find a working reference implementation and use its exact approach.β
5 new skills a week. 1 minute to read.
How it works
The skill clones the repositories that already contain a correct implementation, indexes them, and retrieves the passage the task needs. Reading the reference uses input tokens rather than repeated attempts at writing the code.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
XERJ.code β reference coding
An agent that does not know an API guesses, runs, fails, and guesses again. Each lap costs output tokens, which are the expensive kind. This skill replaces laps with a lookup: clone the repositories that already contain a correct implementation, index them with XERJ, and retrieve the passage before writing.
The trade is deliberate. Retrieval spends input tokens, which are cheaper per
token and cacheable; loops spend output tokens. See COSTS.md for
the arithmetic and for the conditions under which this trade loses.
Status, stated plainly: measured, and the value is real but narrow. (Full case study with real tokens and dollars:
docs/case-studies/reference-coding/CASE_STUDY.md, 2026-08-05.)The comparison that matters is against native Claude Code β the same agent with tools that would grep the source itself β not a bare model. Measured across three regimes, same agent, one objective verdict (compiles + passes hidden tests):
- Unfamiliar code with a contract the model can't recall (a seal, a generational handle, a lazy refill, a specific hash scheme β measured across seven purpose-built libraries, 21 runs): native and xerj both solve 21/21; xerj uses 1.5Γ fewer output tokens and costs 1.3Γ less than native, because retrieval replaces the grep. Pure memory fails 1/21 and burns 6.5Γ the cost flailing. This is the win, and it is decisive. The compiler can leak an API name across a retry loop, but never a contract.
- Memorised code (any popular public crate β even a 256-value table, or a protobuf-style varint): retrieval is overhead. Pure memory is cheapest; injecting a big reference can be the worst arm, because the model re-emits what it was handed.
So: use this when the reference is code the model has not memorised β your own private/proprietary code, an internal API, a post-cutoff or niche library. On public library references the model already knows, it costs more than it saves. The native-vs-xerj gap grows with corpus size (grep pulls the whole tree into context; retrieval pulls one passage).
Since #977 the whole loop is
inside the xerj binary β xerj corpus add / xerj corpus index /
xerj code β plus the xerj_code_search MCP tool for agents without a shell.
The old wrapper scripts (xc-corpus.sh, xc-index.sh, xc.py) are gone; your
existing ~/.xerj-code corpora and indexes work unchanged (see
Migration below).
Standing corpora for this repository (MANDATORY since 2026-08-06)
In the xerj repo, retrieval-before-writing is required for non-trivial
engine work, not optional. Each corpus below has a pinned, licence-reviewed
definition in hub/ β xerj corpus add --from hub/<name>.json rebuilds
it at the same commits anyone else is using:
| corpus | projects | use it for |
|---|---|---|
xerj-search |
lucene, tantivy, meilisearch, quickwit, sonic, elasticsearch | FTS, BM25, postings, merge policy, typo tolerance, segment layout, ES wire semantics |
xerj-vector |
qdrant, usearch, instant-distance, hnswlib | HNSW build, neighbour heuristics, quantisation, filtered kNN |
xerj-storage |
sled, fjall, redb | WAL, flush epochs, crash recovery, compaction, page allocation |
xerj-columnar |
clickhouse | columnar storage, aggregation execution, compression codecs, vectorised scans |
Approach-only sources: elasticsearch (AGPL-3.0 / SSPL-1.0 / Elastic-2.0)
and sonic (MPL-2.0). Never copy their code into Apache-2.0 XERJ; for ES,
pasting source would also falsify the project's public "shares no code with
Elasticsearch" claim. meilisearch is MIT at the core but BUSL-1.1 for its
Enterprise Edition parts β check the header/path first. Read the design,
write our own implementation. Each manifest's review.use field says which
bucket a repo is in; hub/README.md explains the three.
Hub corpus or local corpus
Two kinds of corpus sit on the same local node. Each answers a different kind of question:
| hub corpus | local corpus | |
|---|---|---|
| what it holds | public material at a pinned commit: a library's source, a standard, a regulation, an advisory feed | files only this machine has: the project y |
FAQ
Is it always cheaper?
No. The case study notes conditions under which the approach loses, so the benefit is real but narrow.
What is it compared against?
It is measured against the same coding agent with its own search tools, not against a bare model.
Does it write the code for me?
The agent writes the code, but it bases the implementation on the retrieved reference passage.
Details
Original description by the author
Reference-coding with XERJ. Clone the libraries that already solved your problem, index them locally, and retrieve the exact implementation before writing code β so the agent reads passages instead of re-deriving algorithms across retry loops. Use when starting a task in an unfamiliar API, porting an algorithm, or when you have already looped twice on the same error.
repo: xerj-org/xerj
Popularity
- GitHub stars
- 19k
- Ranking position
- #10506
- License
- Apache-2.0
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
xerj-security-audit
19kHelps your agent run a whitebox security audit of a codebase, finding every risky call and recording evidence that the review covered them.
xerj
19kHelps your agent find current XERJ documentation and contracts before it indexes folders, searches data or sets up agent memory.
xerj-knowledge
19kHelps your agent search your own local documents, notes, PDFs, spreadsheets and mail, and cite the file and page each answer came from.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.