Command reference
corpus is the engine’s command line. Ten commands take you from a list of repos to an agent that can search them. The last three, eval, chunks and bench, serve the project’s own measurements, and you do not need them to use Engineering Corpus.
The tables come from the engine’s own argument parser, so a flag or default that changes in the code changes here when the page is generated again. They were generated from corpus 0.1.0.
Options and exit status
Section titled “Options and exit status”corpus --version prints the version. corpus --help and corpus COMMAND --help print the same arguments as these tables.
Most commands take --data-dir. stars does not, because it touches no data folder, and demo has its own default. The configuration reference says how the data folder is chosen.
| Status | Means |
|---|---|
0 |
The command did what it was asked to do. corpus hook always exits with 0. |
1 |
A run failed: a repo failed to index or remove, stars could not read the list, the eval gate failed, a benchmark answer is missing, or the engine refused the data folder (a value or runtime error). |
2 |
The command line is wrong, or the engine refused an input: an unknown flag, a bad slice config, a name that is not registered, a bad eval query file, a serve --http address that is not a loopback address without --allow-remote-bind. |
corpus demo
Section titled “corpus demo”Indexes two small pinned repos (itsdangerous and walkdir), runs two searches and prints the claude mcp add line for that index. It is the quickest way to see a result.
Synopsis
Section titled “Synopsis”usage: corpus demo [-h] [--data-dir DATA_DIR]Arguments
Section titled “Arguments”| Argument | Default | What it does |
|---|---|---|
--data-dir DATA_DIR |
~/.cache/engineering-corpus/demo |
Where the demo keeps its clones, index and registry. The embedding model still comes from the default data folder. |
- The first run downloads the embedding model, about 600 MB, into the default data folder’s
models/. The demo keeps its own index apart, in~/.cache/engineering-corpus/demo. - The demo repos were scanned for secrets when they were pinned, so the demo needs no Betterleaks.
- A demo folder that holds an index another version made is built again instead of refused.
A real run of 18 November 2026, with the folder renamed demo-only and the last line shortened:
$ corpus demo --data-dir demo-onlycorpus: indexing the demo repos; the first run downloads the embedding model (about 600 MB)corpus: the demo repos were scanned for secrets when they were pinned, so this run skips the scanindexing github.com/pallets/itsdangerous (1/2)...github.com/pallets/itsdangerous @ 672971d: 46 files, 85 chunks, 4 skipped (2 licence_text, 1 lockfile, 1 minified), 1 over the token budget, 69 dependency facts, newest tag 2.2.0indexing github.com/burntsushi/walkdir (2/2)...github.com/burntsushi/walkdir @ 6fd031c: 17 files, 87 chunks, 3 skipped (3 licence_text), newest tag 2.5.0
$ corpus search 'verify an HMAC signature'1.000 github.com/pallets/itsdangerous src/itsdangerous/signer.py:1-60 [P]0.959 github.com/pallets/itsdangerous src/itsdangerous/signer.py:51-110 [P]0.946 github.com/pallets/itsdangerous src/itsdangerous/signer.py:201-260 [P]
$ corpus search 'walk a directory tree up to a maximum depth'0.951 github.com/burntsushi/walkdir src/lib.rs:551-610 [P]0.879 github.com/burntsushi/walkdir src/lib.rs:351-410 [P]0.787 github.com/burntsushi/walkdir src/lib.rs:451-510 [P]
Connect your agent. The plugin brings the seven research agents and the tools. They read the index you build with `corpus index`, not this demo's. claude plugin marketplace add ymcbzrgn/engineering-corpus claude plugin install engineering-corpus@engineering-corpusIn Codex: codex plugin marketplace add ymcbzrgn/engineering-corpus codex plugin add engineering-corpus@engineering-corpusTo search this demo's index from Claude Code with the tools alone, and no agents: claude mcp add engineering-corpus -- ...corpus stars
Section titled “corpus stars”Writes a slice config from a GitHub user’s public stars, for corpus index.
Synopsis
Section titled “Synopsis”usage: corpus stars [-h] [--out OUT] [--exclude-owner PREFIX] [--force] loginArguments
Section titled “Arguments”| Argument | Default | What it does |
|---|---|---|
login |
required | The GitHub user whose public stars to list. |
--out OUT |
stars.toml |
Where to write the slice config. The folder must already exist. |
--exclude-owner PREFIX |
none | Leave out repos whose owner name starts with this text, ignoring case. Name every organization you work for. Repeatable. |
--force |
off | Write over an existing file, keeping its exclude_owners. |
- The file is written only from a complete list. When GitHub limits the rate or the read fails, the command says why, writes nothing and exits with status 1.
- An existing file stops the command unless you pass
--force. Itsexclude_ownersstay. - The output names the organizations that own starred repos. Add the ones you work for with
--exclude-ownerand write the file again with--force. GH_TOKEN, elseGITHUB_TOKEN, raises GitHub’s hourly limit. A malformed token is refused, not sent.
A run of this command is on Index your stars.
corpus index
Section titled “corpus index”Registers the repos of a slice config and indexes them: it clones each repo, walks its files, cuts chunks, scans for secrets, embeds the chunks and stores them.
Synopsis
Section titled “Synopsis”usage: corpus index [-h] [--data-dir DATA_DIR] [--allow-unscanned] [--prune] [--list-skipped REASONS] [--rebuild] [config]Arguments
Section titled “Arguments”| Argument | Default | What it does |
|---|---|---|
--data-dir DATA_DIR |
the data folder | Where the clones, index, registry and embedding model live. The configuration reference says how the default is chosen. A leading ~ is expanded. |
config |
./slice.toml |
The slice config to index. |
--allow-unscanned |
off | Skip the Betterleaks secret scan. Only for private experiments, never for an index you share or serve. |
--prune |
off | First remove every registered repo this run does not accept: one the file no longer lists, or lists but intake rejects, such as a repo of an excluded owner. Refused when the file accepts none. |
--list-skipped REASONS |
none | After each repo’s line, lists the files the walk left out for these reasons, one file per line with its reason. The value is all, or some of the reason names separated by commas: excluded_dir, lockfile, excluded_suffix, too_large, lfs_pointer, binary, non_utf8_content, minified, licence_text, translation, translated_doc, generated, symlink, submodule, non_utf8_path. An unknown name stops the command. |
--rebuild |
off | Drop the whole index and embed again, only the repos this file accepts. Other registered repos stay registered and unindexed. It is what a new engine version asks for when it cannot read the index. |
- A chunk whose text did not change keeps its vector, so a second run embeds only what changed.
- At the end of the run it removes index versions older than seven days and, when it removed any, prints
removed N old index versions, freed M MBon standard error (versionwhen N is 1). If the removal fails, it prints a warning and the exit status stays as it was. - A repo that fails, a dropped connection for example, is reported as
failed REPO: ...and the run goes on. The exit status is 1 if any repo failed. - Without
--allow-unscanned, the scan needs Betterleaks 1.x onPATH, or its path inBETTERLEAKS. - After each repo the command asks GitHub for the repo’s trust labels, one request, with
GH_TOKENorGITHUB_TOKENwhen set. When the hourly limit is spent, it skips the labels for the rest of the run and says so. - A file the engine cannot accept, such as a bad slice config or an unknown key, stops the run with status 2.
A run of this command is on Index your stars.
corpus remove
Section titled “corpus remove”Takes repos out of the index and the registry, and deletes their clones.
Synopsis
Section titled “Synopsis”usage: corpus remove [-h] [--data-dir DATA_DIR] CANONICAL_ID [CANONICAL_ID ...]Arguments
Section titled “Arguments”| Argument | Default | What it does |
|---|---|---|
--data-dir DATA_DIR |
the data folder | Where the clones, index, registry and embedding model live. The configuration reference says how the default is chosen. A leading ~ is expanded. |
CANONICAL_ID... |
required | One or more registered repos, as corpus search --repo names them: github.com/owner/name, in lowercase. |
- Every name must be registered. If one is not, the command stops before it removes anything, prints
not registered: NAMEand exits with status 2. The message adds the registered id you probably meant, or the registered ids (up to 8), or a count and thecorpus_repostool, or, with nothing registered, tells you to runcorpus index. - A repo whose removal fails stays registered, so you can remove it again. The exit status is 1.
A real run on a copy of the demo folder:
$ corpus remove github.com/burntsushi/walkdir --data-dir demo-copyremoved github.com/burntsushi/walkdircorpus search
Section titled “corpus search”Searches the index and prints one line per hit: the score, the repo, the file with its lines, and the license class in brackets.
Synopsis
Section titled “Synopsis”usage: corpus search [-h] [--data-dir DATA_DIR] [-k K] [--repo CANONICAL_ID] queryArguments
Section titled “Arguments”| Argument | Default | What it does |
|---|---|---|
--data-dir DATA_DIR |
the data folder | Where the clones, index, registry and embedding model live. The configuration reference says how the default is chosen. A leading ~ is expanded. |
query |
required | What to look for, in English. |
-k K |
8 |
How many hits to print, from 1 to 100. |
--repo CANONICAL_ID |
none | Search only this repo, named github.com/owner/name in lowercase. Repeatable. |
- It prints locations only. The MCP tools return the verdict text, the evidence and the code.
- Invisible Unicode in a path shows as a
<U+XXXX>marker.
A real run on the same copy, after the removal. The walkdir files are gone, so the best matches are weak:
$ corpus search 'walk a directory tree up to a maximum depth' -k 3 --data-dir demo-copy0.820 github.com/pallets/itsdangerous pyproject.toml:101-160 [P]0.776 github.com/pallets/itsdangerous docs/concepts.rst:101-154 [P]0.654 github.com/pallets/itsdangerous docs/make.bat:1-35 [P]corpus serve
Section titled “corpus serve”Serves the index to MCP clients over stdio, or over Streamable HTTP at http://HOST:PORT/mcp with --http.
Synopsis
Section titled “Synopsis”usage: corpus serve [-h] [--data-dir DATA_DIR] [--http] [--host HOST] [--allow-remote-bind] [--port PORT] [--allowed-host NAME[:PORT]] [--agent-files {include,warn,exclude}]Arguments
Section titled “Arguments”| Argument | Default | What it does |
|---|---|---|
--data-dir DATA_DIR |
the data folder | Where the clones, index, registry and embedding model live. The configuration reference says how the default is chosen. A leading ~ is expanded. |
--http |
off | Serve Streamable HTTP at http://HOST:PORT/mcp instead of stdio. |
--host HOST |
127.0.0.1 |
The HTTP address. An address that is not a loopback address needs --allow-remote-bind. |
--allow-remote-bind |
off | Listen on a --host that is not a loopback address, although the HTTP server has no authentication. Use it only behind a proxy that adds authentication, or in a container whose port is published on localhost only (-p 127.0.0.1:8765:8765). |
--port PORT |
8765 |
The HTTP port, from 1 to 65535. |
--allowed-host NAME[:PORT] |
none | A Host name the HTTP server answers besides localhost, 127.0.0.1 and [::1]: the name a reverse proxy sends. Repeat the flag for each name. NAME alone allows any port; NAME:PORT allows that port only. It takes a DNS name, an IPv4 address or an [IPv6] address, with no wildcard, scheme or path, and it needs --http. Repeatable. |
--agent-files AGENT_FILES |
include |
How to treat files written to steer AI agents, such as AGENTS.md and CLAUDE.md: include serves them, warn serves them with a warning, exclude hides them. One of: include, warn, exclude. |
- Over stdio, your client starts the command, so you rarely run it yourself.
- The HTTP server has no authentication. It refuses a
--hostthat is not a loopback address, with status 2, unless you pass--allow-remote-bind, and then it needs a proxy with authentication in front or a port published on localhost only. - Whatever address it listens on, it answers only the Host names
localhost,127.0.0.1and[::1]and each--allowed-host. Any other Host gets status 421 and any other Origin gets 403. A request with no Origin, as from a program, passes the Origin check.
A run of this command is on Connect your agent.
corpus hook
Section titled “corpus hook”The plugin’s hooks. It reads one hook’s JSON on standard input and prints prior art or a provenance note as JSON, or nothing.
Synopsis
Section titled “Synopsis”usage: corpus hook [-h] [--data-dir DATA_DIR] {write,prompt}Arguments
Section titled “Arguments”| Argument | Default | What it does |
|---|---|---|
--data-dir DATA_DIR |
the data folder | Where the clones, index, registry and embedding model live. The configuration reference says how the default is chosen. A leading ~ is expanded. |
event |
required | write runs before Claude Code creates a new code file. prompt runs on a prompt that holds a block of code, fenced or not. One of: write, prompt. |
- It always exits with status 0. Any error, a missing index or bad input prints nothing.
- The
writeevent prints nothing unlessENGINEERING_CORPUS_WRITE_HOOKison. The configuration reference lists the variable. - Claude Code runs it for you. You run it by hand only to test it.
A run of this command is on The agent pack.
corpus eval
Section titled “corpus eval”Runs a file of queries against the index and scores the ranking with Recall@20, nDCG@10 and MRR. With --baseline it is the gate that a ranking change must pass.
Synopsis
Section titled “Synopsis”usage: corpus eval [-h] [--data-dir DATA_DIR] [--queries QUERIES] [--out OUT] [--baseline BASELINE] [--tolerance TOLERANCE] [--deep]Arguments
Section titled “Arguments”| Argument | Default | What it does |
|---|---|---|
--data-dir DATA_DIR |
the data folder | Where the clones, index, registry and embedding model live. The configuration reference says how the default is chosen. A leading ~ is expanded. |
--queries QUERIES |
eval/seed_queries.toml |
The query file, with each query’s relevant files. |
--out OUT |
none | Where to write the JSON report. |
--baseline BASELINE |
none | A previous report. Exit with status 1 if Recall@20 or nDCG@10 falls below it. |
--tolerance TOLERANCE |
0.0 |
How far below the baseline still passes. A number of 0 or more. |
--deep |
off | Score deep search. The reranker adds seconds per query. |
- It prints each metric, the metrics of the proof files alone for information, and a
missline for every query whose first relevant file is beyond rank 10 or missing. - It writes a JSON report, to
<data folder>/eval/latest.jsonunless you give--out. - With
--baseline, the exit status is 1 when Recall@20 or nDCG@10 falls below the baseline by more than--tolerance.
A real run on a copy of a data folder with four small repos indexed. The query file holds two queries, each with the file that answers it:
[[queries]]id = "itsdangerous-max-age"stratum = "how-to"query = "reject a signed value whose timestamp is older than max_age"relevant = ["github.com/pallets/itsdangerous/src/itsdangerous/timed.py"]The first run writes the report. The second run takes that report as the baseline and passes:
$ corpus eval --queries two.toml --data-dir data-copyrecall@20 1.000ndcg@10 1.000mrr 1.000report: data-copy/eval/latest.json$ corpus eval --queries two.toml --data-dir data-copy --baseline data-copy/eval/latest.json --out second.jsonrecall@20 1.000ndcg@10 1.000mrr 1.000report: second.jsoneval gate: recall@20 1.000 (baseline 1.000), ndcg@10 1.000 (baseline 1.000)The report paths are shortened. Each run took about 5 seconds on a 16 GB Apple M2, with the embedding model already downloaded.
corpus chunks
Section titled “corpus chunks”Writes a slice config’s files and chunks as JSONL, without embedding. The bake-off used it so that every arm saw the same chunks.
Synopsis
Section titled “Synopsis”usage: corpus chunks [-h] [--data-dir DATA_DIR] --out OUT [--allow-unscanned] [config]Arguments
Section titled “Arguments”| Argument | Default | What it does |
|---|---|---|
--data-dir DATA_DIR |
the data folder | Where the clones, index, registry and embedding model live. The configuration reference says how the default is chosen. A leading ~ is expanded. |
config |
./slice.toml |
The slice config to chunk. |
--out OUT |
required | The folder for files.jsonl and chunks.jsonl. It is created when missing. |
--allow-unscanned |
off | Skip the Betterleaks secret scan. Only for private experiments. |
- It writes
files.jsonlandchunks.jsonlin the--outfolder. - A repo that fails is reported as
failed REPO: ...and the run goes on. The exit status is 1 if any repo failed.
A real run with the demo’s slice config. Betterleaks was on the PATH, so the scan ran:
$ corpus chunks demo.toml --out chunks-out --data-dir data-copychunking github.com/pallets/itsdangerous (1/2)...github.com/pallets/itsdangerous @ 672971d: 46 files, 85 chunks, 4 skippedchunking github.com/burntsushi/walkdir (2/2)...github.com/burntsushi/walkdir @ 6fd031c: 17 files, 87 chunks, 3 skippedThe folder then held files.jsonl with 63 lines (46 and 17 files) and chunks.jsonl with 172 lines (85 and 87 chunks). A line
of files.jsonl has the keys repo, commit, path, language, licence_class and text. A line of chunks.jsonl
has repo, commit, path, start_line, end_line, text, embed_text and over_budget. The run took about 7 seconds.
corpus bench
Section titled “corpus bench”The head-to-head benchmark: it scores the recorded answers of our server or of a public code search tool. --record asks for the answers the store lacks.
Synopsis
Section titled “Synopsis”usage: corpus bench [-h] [--data-dir DATA_DIR] [--queries QUERIES] [--tool {engineering-corpus,sourcegraph,searchcode,github}] [--form {query,keywords}] [--pins PINS] [--judged JUDGED] --store STORE [--record] [--refresh] [--out OUT]Arguments
Section titled “Arguments”| Argument | Default | What it does |
|---|---|---|
--data-dir DATA_DIR |
the data folder | Where the clones, index, registry and embedding model live. The configuration reference says how the default is chosen. A leading ~ is expanded. |
--queries QUERIES |
none | A query file. A later file replaces queries with the same id. Without it, eval/bakeoff_gate.toml, then eval/bakeoff_turkish_en.toml. Repeatable. |
--tool TOOL |
engineering-corpus |
Our server, or a public code search tool. One of: engineering-corpus, sourcegraph, searchcode, github. |
--form FORM |
query |
The query as written, or as keywords. One of: query, keywords. |
--pins PINS |
bakeoff/corpus.toml |
The pinned commits, used in Sourcegraph’s repo filter. |
--judged JUDGED |
none | The judge’s grades, {query id: {file: 0 to 3}}. Files graded 2 or 3 count as relevant. |
--store STORE |
required | The folder of recorded answers, one JSON file per request. |
--record |
off | Ask for the answers the store lacks, or holds as errors. |
--refresh |
off | Ask again for every answer. |
--out OUT |
none | Write the report as JSON. |
- A missing answer in the store stops the run with
corpus: missing answer KEY; record it with --recordand status 1. A damaged or mismatched one stops it withcorpus: corrupt answer KEYorcorpus: mismatch answer KEY, thendelete that entry from the store, or ask everything again with --refresh, also with status 1. --tool githubneeds a token inGH_TOKENorGITHUB_TOKEN.
A run of this command is on How the benchmark works.