Skip to content

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.

  • git on your PATH. 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, set BETTERLEAKS to its path.
  • The embedding model, about 600 MB. The first corpus index or corpus search downloads it into the models/ 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”).
Terminal window
corpus stars YOUR_LOGIN --exclude-owner YOUR_EMPLOYER

The 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 11
organisations: anthropics (11), HKUDS (7), openai (7), google (6), cloudflare (4), CopilotKit (4), huggingface (4), ...
next: corpus index stars.toml

The 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 İstanbul
corpus: 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 it

Three 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 ymcbzrgn
    corpus: stars.toml exists, and may hold your edits; pass --force to write it again (its exclude_owners stay)

    --out writes to another file name.

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-01
url = "https://github.com/danielstjules/buddy.js"
default_branch = "master"
licence = "MIT"
[[repos]]
# 901 stars, 85 KB, Python, starred 2026-08-26
url = "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.toml
corpus: unknown-key.toml: repos[1]: unknown keys ['license']
Terminal window
corpus index stars.toml

corpus 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.3
indexing github.com/iphelix/pack (2/2)...
github.com/iphelix/pack @ 622dd92: 5 files, 60 chunks, 1 skipped, 37 secrets masked

Each 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.

Terminal window
corpus search "detect magic numbers in JavaScript source" -k 3
0.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.

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.toml
indexing 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.3
indexing 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:

Terminal window
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.

  • corpus stars never writes a private repo. If you add private = true to an entry by hand, corpus index skips it.

  • The engine does not check on GitHub whether a repo is private. A private repo that you add by hand without private = true is cloned with your own git credentials, if they can read it, and indexed. List public repos only.

  • A name prefix in exclude_owners removes every repo of those owners, even one you add back by hand.

  • corpus index stops with an error that names the entry when an address is not an https://github.com/<owner>/<name> address:

    $ corpus index bad-url.toml
    corpus: 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.toml
skipped github.com/ymcbzrgn/example-private: private
skipped github.com/acme/internal-tools: excluded owner

The 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.

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 ymcbzrgn
corpus: 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 stars stops, says the request was rate limited, and writes no file.
  • corpus index keeps 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.

The engine keeps everything in one data folder per user. It picks the folder in this order:

  1. --data-dir on the command.
  2. The ENGINEERING_CORPUS_DATA environment variable.
  3. $XDG_DATA_HOME/engineering-corpus, when XDG_DATA_HOME is set to an absolute path.
  4. ~/.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.

A repo you take out of the file stays in the index until you remove it. Two commands remove repos:

Terminal window
corpus remove github.com/OWNER/NAME ...
corpus index stars.toml --prune

corpus 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:

Terminal window
$ corpus remove github.com/burntsushi/walkdir --data-dir demo-copy
removed github.com/burntsushi/walkdir
$ corpus search 'walk a directory tree up to a maximum depth' -k 3 --data-dir demo-copy
0.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:

Terminal window
$ corpus index only-itsdangerous.toml --prune --data-dir demo-copy2
removed github.com/burntsushi/walkdir
indexing 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.