Index your stars
You turn your public GitHub stars into a local index. You write a list of repos from your stars, trim it to the ones you want, and index it. Your agent can then search them.
The examples use the corpus command. If you run the package with uvx, write uvx engineering-corpus in its place.
Before you start
Section titled “Before you start”giton yourPATH. The engine makes shallow clones with it.- Betterleaks 1.x on your
PATH, for the secret scan. On macOS,brew install betterleaks. If Betterleaks lives somewhere else, setBETTERLEAKSto its path. - The embedding model, about 600 MB. The first
corpus indexorcorpus searchdownloads it into themodels/folder of your data folder. The demo keeps its own copy in its own folder, so your data folder downloads it once more. - A GitHub account with public stars. You need no token, but a token lifts a rate limit (see “Tokens and rate limits”).
Write your stars file
Section titled “Write your stars file”corpus stars YOUR_LOGIN --exclude-owner YOUR_EMPLOYERThe output shown here is from the account ymcbzrgn, with microsoft as the excluded owner:
wrote stars.toml: 906 repos from ymcbzrgn's 917 stars; skipped: excluded owner 11organisations: anthropics (11), HKUDS (7), openai (7), google (6), cloudflare (4), CopilotKit (4), huggingface (4), ...next: corpus index stars.tomlThe organization list is trimmed here. The command prints every organization that owns a repo among your stars.
stars.toml is a slice config: a TOML file that lists repos for corpus index. It lists your stars newest first, and
each repo carries a comment with its stars, size, language and the day you starred it, so you can decide what to keep.
--exclude-owner takes a name prefix, matches it without regard to case, and you can repeat it. Name every organization
you work for. The engine never calls an organization API, so it cannot know where you work. The command lists the
organizations among your stars to remind you. Add the ones you work for and write the file again with --force. The
file keeps your exclusions as exclude_owners, and corpus index drops those owners again even if a repo from one of
them gets back into the list.
An owner prefix may hold only ASCII letters, digits and hyphens, up to 39 characters, the same as a GitHub name. Anything else is an error, never a filter that silently matches nothing:
$ corpus stars ymcbzrgn --exclude-owner İstanbulcorpus: exclude_owners entry 'İstanbul': GitHub names use only ASCII letters, digits and hyphens, at most 39; write the owner as it appears in github.com/<owner>, or the start of itThree more things to know about this command:
-
It never writes a private repo.
-
It writes the whole list or nothing. If GitHub refuses a page, no file is written.
-
It does not overwrite a file you may have edited. Without
--force, it stops:$ corpus stars ymcbzrgncorpus: stars.toml exists, and may hold your edits; pass --force to write it again (its exclude_owners stay)--outwrites to another file name.
Trim the file
Section titled “Trim the file”Open stars.toml. Each [[repos]] block is one repo. Delete the blocks you do not want. Every repo you keep is cloned
and embedded, and a large repo takes a long time. How long does the first index take?
has the timed repos.
A trimmed file with two repos (the header comments are left out here):
# Owners left out, by name prefix and case-insensitive: add the organisations you work for.exclude_owners = []
[[repos]]# 884 stars, 99 KB, JavaScript, starred 2026-10-01url = "https://github.com/danielstjules/buddy.js"default_branch = "master"licence = "MIT"
[[repos]]# 901 stars, 85 KB, Python, starred 2026-08-26url = "https://github.com/iphelix/pack"default_branch = "master"licence = "BSD-3-Clause"The keys of a [[repos]] block are in the configuration reference. The key that holds a repo’s
license is spelled licence. The engine rejects a key it does not know, so license is an error:
$ corpus index unknown-key.tomlcorpus: unknown-key.toml: repos[1]: unknown keys ['license']corpus index stars.tomlcorpus index reads ./slice.toml when you give it no file, so name the file.
indexing github.com/danielstjules/buddy.js (1/2)...github.com/danielstjules/buddy.js @ 57d8cf1: 35 files, 53 chunks, 1 skipped, newest tag 0.9.3indexing github.com/iphelix/pack (2/2)...github.com/iphelix/pack @ 622dd92: 5 files, 60 chunks, 1 skipped, 37 secrets maskedEach result line is repo @ commit and then what the engine found. A field shows only when it applies.
| Field | What it means |
|---|---|
files |
Files the engine indexed from the repo at that commit. |
chunks |
The pieces of those files that search ranks. |
skipped |
Files left out of search: lockfiles, vendored, binary, minified and generated files, license texts, documentation in another language, files over the size limit and others. |
over the token budget |
Chunks that hold one line too long for the embedding model to read whole. |
secrets masked |
Secrets the scan found. The index holds the masked text, and the engine masks before it embeds. |
unchanged (vectors reused) |
Chunks whose text did not change since the last index. |
dependency facts |
Packages and versions that the repo’s lockfiles and requirements files name. |
newest tag |
The newest version tag on the repo’s origin. |
The engine keeps a file up to 2,000,000 bytes when it is in a programming language or is a Markdown (.md, .markdown) or reStructuredText (.rst) file, so a long module or a long specification stays searchable. Every other file keeps a limit of 300,000 bytes: .mdx and .txt pages, configuration files and data files such as YAML, JSON and SQL, and files with an extension the engine does not know. A file in a folder named test, tests, __tests__, testdata, spec or fixtures keeps the 300,000-byte limit whatever it is. A file over its limit is left out as too_large, and so is a Markdown or reStructuredText file over 300,000 bytes with more than 40,000 lines. A minified or generated file is left out at any size. A file named llms-full or llms-txt (extension .md, .mdx, .markdown or .txt) is left out at any size too, as generated: a documentation tool writes it by joining the pages of a whole site. A short llms.txt stays. corpus_read opens a file up to 2,000,000 bytes and refuses a larger one; its permalink still opens it on GitHub.
Betterleaks scans every repo before anything is embedded. A secret it finds becomes ‹secret masked: <rule>› in the
stored text, so the server returns the marker and never the secret. The security model page
explains what that covers.
Indexing also asks GitHub once per repo whether the repo is archived and when it was last pushed. The tokens and rate limits section says what happens when GitHub’s hourly limit runs out.
Search it
Section titled “Search it”corpus search "detect magic numbers in JavaScript source" -k 30.917 github.com/danielstjules/buddy.js README.md:1-60 [P]0.850 github.com/danielstjules/buddy.js lib/detector.js:151-210 [P]0.848 github.com/danielstjules/buddy.js lib/detector.js:101-160 [P]A line is the score, the repo, the file and its lines, and the license class in brackets. P means permissive: the engine
returns the code and you keep the notice. The license policy page explains every class and why
some hits give only the location. Your agent gets the same hits, with a pinned permalink and a license verdict on each,
through the tools in the tools reference. To connect an agent, follow
Connect your agent.
-k sets how many hits you get, from 1 to 100. --repo github.com/owner/name limits the search to one repo, written in lowercase, and you can repeat it.
Index again later
Section titled “Index again later”Run the same command again. The engine embeds only chunks whose text changed. The second run on the two repos took 9 seconds:
$ corpus index stars.tomlindexing github.com/danielstjules/buddy.js (1/2)...github.com/danielstjules/buddy.js @ 57d8cf1: 35 files, 53 chunks, 1 skipped, 53 unchanged (vectors reused), newest tag 0.9.3indexing github.com/iphelix/pack (2/2)...github.com/iphelix/pack @ 622dd92: 5 files, 60 chunks, 1 skipped, 37 secrets masked, 60 unchanged (vectors reused)At the end of a run the engine removes index versions older than seven days, so the index no longer grows by a full copy of a
repo each time it is indexed again. The newest version always stays. When it removes any, it prints
removed N old index versions, freed M MB on standard error, with version when N is 1.
To pick up stars you added since, write the list again:
corpus stars YOUR_LOGIN --force--force keeps your exclude_owners and rewrites the repo list from your current stars. That replaces your trims, so the
file lists every star again. With the account used here that was 906 repos after the microsoft exclusion, the same as
the first run. To keep your trimmed file, write the new list to another file with --out and copy the new blocks over by
hand.
What the engine leaves out
Section titled “What the engine leaves out”-
corpus starsnever writes a private repo. If you addprivate = trueto an entry by hand,corpus indexskips it. -
The engine does not check on GitHub whether a repo is private. A private repo that you add by hand without
private = trueis cloned with your own git credentials, if they can read it, and indexed. List public repos only. -
A name prefix in
exclude_ownersremoves every repo of those owners, even one you add back by hand. -
corpus indexstops with an error that names the entry when an address is not anhttps://github.com/<owner>/<name>address:$ corpus index bad-url.tomlcorpus: bad-url.toml: repos[1]: not a public GitHub repo URL: 'https://gitlab.com/example/tool'
A config that holds only entries the engine refuses shows both messages and indexes nothing:
$ corpus index never.tomlskipped github.com/ymcbzrgn/example-private: privateskipped github.com/acme/internal-tools: excluded ownerThe engine does not skip a repo because of its license. It indexes public repos under every license and returns code only where the license allows it. See the license policy.
Tokens and rate limits
Section titled “Tokens and rate limits”The engine talks to GitHub’s API in two places. corpus stars asks for your stars, 100 to a page. corpus index asks
once per repo for its trust labels. GitHub allows 60 requests an hour without a token and 5,000 with one.
Set GH_TOKEN, or GITHUB_TOKEN if it is not set, to send a token. The engine reads GH_TOKEN first, as the gh tool
does. It never prints the token and sends it only to api.github.com. A token that holds characters a token cannot have
is refused before any request:
$ GH_TOKEN='not a token' corpus stars ymcbzrgncorpus: GH_TOKEN holds characters a token cannot have; fix it, or run `unset GH_TOKEN` to ask GitHub without a token (it allows fewer requests an hour)You do not need to give the token any scope. GitHub’s page on managing personal access tokens says that a token with no assigned scopes can only access public information, and your stars and the repos you index are public.
When the hourly limit runs out, the two commands behave differently:
corpus starsstops, says the request was rate limited, and writes no file.corpus indexkeeps indexing. It skips the trust labels for the rest of the run and says so.
Reading a list costs one request for every 100 stars, so 917 stars need 10 requests. A list of more than 10,000 stars is refused, never cut short. With no token, indexing more than 60 repos in one hour runs into the limit.
Where your data lives
Section titled “Where your data lives”The engine keeps everything in one data folder per user. It picks the folder in this order:
--data-diron the command.- The
ENGINEERING_CORPUS_DATAenvironment variable. $XDG_DATA_HOME/engineering-corpus, whenXDG_DATA_HOMEis set to an absolute path.~/.local/share/engineering-corpus.
The folder is the same for every command, so corpus serve started in any project folder finds the index you built.
Inside it:
| Entry | Holds | Size with four small repos indexed (the demo’s two and these two) |
|---|---|---|
index/ |
The search index. | 3.9 MB |
models/ |
The embedding model. | 572 MB |
repos/ |
A shallow bare clone of each indexed repo. | 584 KB |
registry.sqlite |
The list of repos, each repo’s license verdict and its secret-scan state. | 12 KB |
The configuration reference lists every setting.
Remove repos
Section titled “Remove repos”A repo you take out of the file stays in the index until you remove it. Two commands remove repos:
corpus remove github.com/OWNER/NAME ...corpus index stars.toml --prunecorpus remove takes the canonical ids that corpus search --repo takes, in lowercase. It drops each repo from the index and
the registry and deletes its clone. A name the registry does not hold stops the command before it removes anything.
These runs used a copy of the demo data folder, demo-copy, which holds itsdangerous and walkdir. Before the removal, the best
match for a search about walking a directory tree was a walkdir file at 0.951. After it:
$ corpus remove github.com/burntsushi/walkdir --data-dir demo-copyremoved github.com/burntsushi/walkdir$ 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]--prune first removes every registered repo that this run does not accept: a repo the file no longer lists, and one the
file lists but intake now rejects, such as a repo of an owner you added to exclude_owners. It refuses to run when the file
accepts no repo, so a wrong file cannot empty your index.
On a second copy of the demo folder, with a file that lists only itsdangerous:
$ corpus index only-itsdangerous.toml --prune --data-dir demo-copy2removed github.com/burntsushi/walkdirindexing github.com/pallets/itsdangerous (1/1)...github.com/pallets/itsdangerous @ 672971d: 46 files, 85 chunks, 4 skipped, 1 over the token budget, 85 unchanged (vectors reused), 69 dependency facts, newest tag 2.2.0--prune removed walkdir first, then indexed the one repo in the file. Its 85 chunks were already in the index, so no vector was
computed again.