repocode
AGENTS.md9 starsChanged 3 months agoMITView on GitHub
Working notes for AI agents contributing to RepoCode. Human contributors: see CONTRIBUTING.md. RepoCode packs a repository into a token-budgeted context bundle for an LLM. The interesting part is not concatenating files — it is deciding which files, and at what fidelity, when the budget cannot hold everything. Most of the difficulty in this codebase lives in ranking and budget fitting. The pack pipeline is packages/core/src/pipeline.ts, and reading it top to bottom is the fastest way to understand the system: discover…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,691 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 45
ESM throughout: All packages are "type": "module".
- Distinctive: line 49
Write the test first: Every behavioural claim in this repo is expected to have a test that fails without the change.
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Working notes for AI agents contributing to RepoCode. Human contributors: see CONTRIBUTING.md.
What this is
RepoCode packs a repository into a token-budgeted context bundle for an LLM. The interesting part is not concatenating files — it is deciding which files, and at what fidelity, when the budget cannot hold everything. Most of the difficulty in this codebase lives in ranking and budget fitting.
Layout
| Package | Published as | What it is |
packages/core | @repocode/core | Discovery, ranking, compression, budget fitting, output. The engine. |
packages/cli | repocode | Commander-based CLI. bin: repocode. |
packages/mcp | @repocode/mcp | MCP server. bin: repocode-mcp. |
packages/github-action | not on npm — consumed as uses: owner/repo@tag via the root action.yml | GitHub Action that fails a PR's check when the diff plus its import context doesn't fit a budget. Plain ESM, zero dependencies, shells out to the published CLI. |
packages/bench | gitignored | SWE-bench Lite harness. Not tracked in git — exists locally, methodology stays private. |
packages/stats | gitignored | Raw benchmark result CSVs. Data, not code — local only, never committed. |
The pack pipeline is packages/core/src/pipeline.ts, and reading it top to bottom is the
fastest way to understand the system: discover files → build the import graph (its centrality
map is an input to ranking, so it comes first) → rank pass 1 → rank pass 2 → fit to budget →
apply stable ordering → scan for secrets → assemble.
Commands
pnpm install
pnpm audit --audit-level=high # dependency vulnerability gate
pnpm -r build # tsc, per package
pnpm -r typecheck # tsc --noEmit
pnpm -r test # vitest run — 841 passing, 1 skipped (plus bench's 32 if it exists locally)
pnpm --filter @repocode/core test:perf # synthetic 10k-file pack, wall-clock regression gate —
# CI-only, not part of `pnpm -r test`CI runs exactly these six plus node packages/cli/dist/cli.js --version. There is no linter
and no formatter; match the style of the file you are editing.
Conventions
- ESM throughout. All packages are
"type": "module". Relative imports in TypeScript carry a.jsextension (from './ranking/pass1Ranker.js') even though the source is.ts. Omitting it compiles and then fails at runtime. - Tests are
vitest, inpackages/*/tests/, mirroring thesrc/layout. - Write the test first. Every behavioural claim in this repo is expected to have a test that fails without the change.
- Node >= 20, pnpm 10.
Things that will burn you
Ranking changes regress. pass2Ranker.ts scores density as score / max(1, size / 4),
which over-rewards near-empty files. Three separate fixes were attempted — removing the size
division, flooring the divisor, excluding empty files outright — each looked correct in
isolation, each made benchmark results worse, and all three were reverted. The pathology is
still there, deliberately. The signals interact more than they look like they do; if you
change ranking, measure before and after on the benchmark rather than shipping on reasoning.
Output ordering is load-bearing. --stable-order exists so that repacking an unchanged
repository produces byte-identical output and preserves an LLM's prompt cache. Anything that
varies between runs — a timestamp, a token total, a file count in the preamble — sits ahead of
the file bodies and breaks the cached prefix at byte 1. omitVolatileMetadata exists for this
reason. Verify cache stability on rendered bytes, never on the file list; checking the list
is exactly what hid a header timestamp once already.
Discovery must be deterministic. fileDiscovery.ts sorts its results explicitly. Filesystem
enumeration order is not stable across machines, and non-determinism here silently changes
rankings and defeats caching.
docs/ is gitignored on purpose. Specs, plans and scratch analysis stay local. Do not
commit them, and do not "helpfully" un-ignore the directory.
Benchmarking
packages/bench (gitignored, local only — see Layout) measures file recall on
SWE-bench Lite against oracle and random-selection controls. It is not published: the
methodology and the numbers it produces stay off GitHub by design, so this file does not
duplicate them. If you're changing ranking, run the harness locally before and after and
compare against the prior local results — do not ship a ranking change on reasoning alone.
scripts/benchmark-chart.js (also gitignored) regenerates a results table from the local CSVs.
Dogfooding
RepoCode is used to pack RepoCode. To hand this codebase to an agent:
repocode . --budget 50k --stable-order--stable-order keeps the prefix byte-identical across repacks, so an agent re-reading the
bundle between edits keeps its prompt cache.
To inspect ranking instead of packing:
repocode . --budget 50k --explain--explain implies --dry-run — it prints the ranking decision for every file and exits
without writing a pack. It is the fastest way to see whether a ranking change did what you
intended. Add --format json for a machine-readable report.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

