shunt
AGENTS.md226 starsChanged 2 months agoApache-2.0View on GitHub
- Build: cargo build - Release build: cargo build --release - Run: cargo run -- run or ./target/release/shunt run - Validate config: cargo run -- check or ./target/release/shunt check - Token helper: cargo run -- token - Learned prefill router (off by default, absent from release binaries): cargo build --release --features prefill-router (add ,ui for the dashboard). It embeds Python via pyo3, so set PYO3_PYTHON to an interpreter (>= 3.10, shared libpython) whose environment has torch, transformers, numpy, and accelerate;…
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,773 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.
In this repository13 other files it gives its agents.
- src/AGENTS.mdAGENTS.md
- tests/AGENTS.mdAGENTS.md
- wiki/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- src/CLAUDE.mdCLAUDE.md
- tests/CLAUDE.mdCLAUDE.md
- wiki/CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- wiki/llms-full.txtllms.txt
- wiki/llms.txtllms.txt
- run-claude-gateway-refSkill
- run-shuntSkill
- verifySkill
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 7
Run: cargo run -- run or ./target/release/shunt run
- Very specific: line 46
No output means no build input changed, so the result is environmental.
- Very specific: line 78
Write code in English, and documentation in English except for the maintained translations — the root README.<locale>.md files and the …
- Distinctive: line 81
Keep Rust files focused and preferably under 500 lines.
- Very specific: line 83
Keep gateway-owned errors in the Anthropic error shape, except on the inbound Codex endpoint ([server.codex_endpoint]), where gateway-owned …
- Distinctive: line 84
Prefer table-driven config additions over hardcoded provider logic.
- Very specific: line 113
Before adding a cross-page fragment link to a locale file, confirm the target section exists in that locale (they are not all at parity) …
- Distinctive: line 121
Keep PRs focused and link milestone docs when changing implementation behavior.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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
shunt Agent Instructions
Build & Run Commands
- Build:
cargo build - Release build:
cargo build --release - Run:
cargo run -- runor./target/release/shunt run - Validate config:
cargo run -- checkor./target/release/shunt check - Token helper:
cargo run -- token - Learned prefill router (off by default, absent from release binaries):
cargo build --release --features prefill-router(add,uifor the dashboard). It embeds Python via pyo3, so setPYO3_PYTHONto an interpreter (>= 3.10, shared libpython) whose environment hastorch,transformers,numpy, andaccelerate; pyo3 otherwise takes the firstpython3onPATH.
Testing
- Full test suite:
cargo test --all-features --workspace - Format check:
cargo fmt --all --check - Lints:
cargo clippy --all-targets --all-features -- -D warnings - CI runs format, clippy, and tests with
RUSTFLAGS=-D warnings. tests/prefill_router.rsruns in the default-build CI step for the feature-off load error; its feature-on live test skips itself unlessSHUNT_PREFILL_ROUTER_CHECKPOINTnames a checkpoint andpython3 -c "import torch, transformers"succeeds, so CI never depends on Python packages.- Benchmarks:
cargo bench.benches/stage_router.rsadditionally needs--features bench, which exposesshunt::bench_support— the facade that reaches the crate-private stage-router path. Without the feature that target builds and runs but registers no benchmarks, so pass it (CodSpeed does). CodSpeed (
.github/workflows/codspeed.yml) is a required check, and it compares the PR against the stored baseline frommain— not against the merge base. A red CodSpeed on a diff that changes no Rust is therefore expected to be environmental, not a regression you introduced. Before treating one as real: confirm the build inputs actually differ. The base to diff against is the commit CodSpeed names asBASEin its report footer ("Comparing … withmain(b000df6)") — the storedmaintip, notgit merge-base, which on a typical PR is an older commit and would answer a different question:BASE_SHA=b000df6e # replace with the BASE commit from the CodSpeed report git diff "$BASE_SHA" HEAD --name-only | grep -E '\.rs$|Cargo|rust-toolchain|\.github/'No output means no build input changed, so the result is environmental. Then compare the
Record the measurement environmentstep between the PR run and the baseline run onmain. The Rust toolchain is pinned there, andruns-onnames one OS version rather than a movinglatest— but GitHub still revises that image, and the CPU model is not pinnable on hosted runners at all. CodSpeed names both the runner image and differing CPU models among its causes of a false regression, recommending an immutable environment and a consistent CPU type (https://codspeed.io/docs/instruments/cpu/regression-causes); the logged image and CPU lines are what tell you which one moved. Bumping the toolchain pin, or GitHub revising the image, re-seeds the baseline on the nextmainrun.
Project Structure
src/main.rs: CLI entry point.src/server.rs: Axum router and endpoint registration.src/proxy.rs: request buffering, routing, adapter dispatch.src/config.rs: typed config, defaults, TOML/env loading, validation.src/routing.rs: exact route, prefix route, default-provider resolution.src/adapters/: provider protocol adapters.src/model/: Anthropic Messages and OpenAI Responses translation.src/auth/: credential lookup and refresh helpers.ui/: React + Vite source for the admin dashboard bundle;--features uiembedsui/dist(seeui/README.md).tests/: protocol and translation integration tests.README.md: top-level project overview (features, quickstart, supported providers/models).docs/: engineering specs and milestone records (m1–m16, config, running,RELEASING), and captured research (docs/research/).site/: published Nimbus documentation site deployed to Cloudflare Pages; sources undersite/src/content/docs/(getting-started,guides,providers,reference) with custom locale fallback routing.wiki/: generated Astro Starlight wiki (wiki-please — do not hand-edit; regenerate).
Code Style
- Write code in English, and documentation in English except for the maintained
translations — the root
README.<locale>.mdfiles and thesite/locale trees (see Documentation). - Keep Rust files focused and preferably under 500 lines.
- Preserve streaming semantics; do not buffer upstream SSE responses unless the client requested non-streaming output or the entry's router (
escalation,advisor) requires the completed turn before serving it. - Keep gateway-owned errors in the Anthropic error shape, except on the inbound Codex endpoint (
[server.codex_endpoint]), where gateway-owned errors use the OpenAI Responses error shape so its OpenAI-protocol clients parse them through their own error path (issue #127). - Prefer table-driven config additions over hardcoded provider logic.
Documentation
Code and docs must not drift. When a change alters observable behavior, config keys, endpoints, CLI, provider/model support, or defaults, update the docs it affects in the same PR as the code. Update by surface:
README.md— when adding/removing a capability or changing setup, supported providers/models, or the quickstart.docs/— update the relevant milestone/spec when implementation behavior deviates from it (see CONTRIBUTING.md); add a newdocs/note for a substantial new subsystem.site/src/content/docs/— update the affected page when user-facing behavior, config keys, endpoints, or CLI changes (getting-started/for installation/quickstart,guides/for how-tos,providers/for a single provider's setup page,reference/for config/endpoints/CLI/troubleshooting).wiki/— generated by wiki-please; do not hand-edit and do not include it in a routine code PR. Regenerate separately when its source material changes.
A change that genuinely needs no doc update is fine — but confirm each surface
above was considered rather than skipped by default. docs/ and code are
English-only. Two surfaces additionally carry maintained translations, and both
follow the same rule — update the English source and its translations in the
same PR rather than leaving a page current in some languages only:
- the root README:
README.ko.md,README.ja.md, andREADME.zh-CN.mdalongsideREADME.md. - the site:
ko/ja/zh-cncopies undersite/src/content/docs/<locale>/alongside the English page. This covers every docs surface —getting-started/,guides/,providers/,reference/— so a new provider page ships with its three locale copies in the same PR.
Anchors do not survive translation. Astro derives heading ids from the
rendered heading text, so a locale page linking an English fragment is a dead
link: the ko config reference is #serverstatus-선택, not #serverstatus-optional.
Before adding a cross-page fragment link to a locale file, confirm the target
section exists in that locale (they are not all at parity) and take the id from
the built site/dist/<locale>/.../index.html. When the target section has no
locale counterpart, link the English page rather than inventing an anchor.
Git Workflow
- Use conventional commits.
- Keep PRs focused and link milestone docs when changing implementation behavior.
- Third-party GitHub Actions must be pinned to full commit SHAs.
Boundaries
- ✅ Always preserve existing tests and add focused coverage for protocol changes.
- ✅ Always run format, clippy, and tests before reporting code changes as complete.
- ✅ Always update the affected docs (
README.md/docs//site/) in the same PR as a behavior, config, endpoint, CLI, or provider/model change;wiki/is generated — regenerate, never hand-edit. - ⚠️ Ask before changing credential-file writeback behavior.
- ⚠️ Ask before changing public config keys or documented provider semantics.
- 🚫 Never weaken or remove tests to make a change pass.
- 🚫 Never commit secrets, tokens, or generated local config files.
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.

