Model Router  ·  Documentation  ·  Previous: Changelog  ·  Next: Releasing

# Contributing ## Set up You need Python 3.9 or later, Node 22.6 or later and Claude Code 2.1.329 or later. The type check also needs `curl`, `npm` and the network, and installs `tsc` in a temporary folder. Branch from `main`. To try a change in a session, run `claude --plugin-dir ./plugins/model-router`. [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) explains the design. ## Checks Every change passes these before it is merged: ```bash python3 -m unittest discover -s tests node --experimental-strip-types --test "tests/mod/*.test.ts" sh tests/mod/typecheck.sh claude plugin validate --strict . claude plugin validate --strict plugins/model-router python3 tools/plugin_version.py origin/main python3 tools/docs_assets.py --check python3 bench/analyze.py "bench/results/*.jsonl" --out docs/BENCHMARKS.md --check python3 tools/live_probe.py python3 tools/live_check.py --scripted ``` CI runs all of them, the version check on pull requests only. The unit tests include the docs and benchmarks-page checks. The last two each run one session against a local endpoint that plays the model, so they need `claude` on `PATH` and spend nothing. [docs/TESTING.md](docs/TESTING.md) says what each checks. - A change to routing also runs the paid live evals: `claude plugin eval plugins/model-router --trust-plugin --scaffold --allow-tools Write Edit Bash`. Run them by hand before a release. CI has no job for them. - The unit tests check each eval case offline (`RoutingEvals`): the session note pairs the model and effort its `expected_outcome` names, a call naming them runs on them, a grader checks each, and each grader that reads an answer or the order of runs fails a known wrong one. A change to the note's table updates the cases and their graders in the same commit. - A case pins itself to `strict` with `EVAL_MODEL_ROUTER_DELEGATION: strict` in the `env` block of its `prompt.md` front matter, whatever the default is, since `claude plugin eval` passes a case only `EVAL_*` variables. The other seven cases run on the default, which is `strict`. The plugin reads this variable ahead of the `delegation` option, and no other option has one. It reads it only when its own files run from outside a plugin cache, so run the eval on a path to the checkout (`claude plugin eval plugins/model-router`): an installed plugin ignores the variable, and the eleven cases then run on the option's value. A checkout under a folder named `cache` counts as installed too, so the variable is ignored there and the `Options` tests that set the variable fail. Eleven cases set it, those about delegation behaviour (`RoutingEvals.test_exactly_the_delegation_eval_cases_set_strict_delegation`). - A daily workflow compares upstream Claude Code with `compat/baseline.json` and opens or updates one issue when something changed. Review it with `/refresh` in this repository, then run `python3 tools/upstream_check.py --baseline compat/baseline.json --write` in the same pull request. The same workflow's `newest` job runs each day too: it installs the newest Claude Code, runs both `claude plugin validate --strict` commands and type-checks the mod against the newest published types. It opens no issue, so a failed run is the signal. ## What a change must include - Its tests, and an update to every page it makes wrong, in the same commit. - A term in [docs/GLOSSARY.md](docs/GLOSSARY.md) for a new module or concept. - A new version in `plugin.json` when it touches `plugins/model-router/` (its `README.md` aside). Installs keep their cached copy until the version changes, and CI's `version` job fails a reused one. - A new `schema` version for any shape it breaks: `config/models.json` or a `model-router.json` override, a state file, or a `--json` output. The old shape stays readable. [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) says what breaks a shape. ## Rules - The runtime is Python 3.9 or later on the standard library only. No dependencies. - The mod forwards events to the runtime, which picks the model and effort. With no answer from it, the mod only holds a named model to `max_tier` and `min_tier`. - Every hook fails open: a bug may cost routing, never a tool call, a spawn or a session. - A claim about Claude Code or a model cites the newest official docs (`code.claude.com/docs`, `platform.claude.com/docs`) or the installed binary. Behavior with no primary source is marked as observed, with the Claude Code version it was seen on. - `tools/docs_assets.py` writes the diagrams, badges, page heads, the docs index cards, the Claude Code floor in the READMEs, FAQ and guide, and the site's generated parts, so hand edits there are lost. Change the script or `PAGES` in `tools/docs_pages.py` (a new docs page needs a row), run it, and keep `--check` passing. - A code comment gives a reason the code can't show, in one line, with no ticket number and no history. ## Commits - One problem per commit. The subject is a plain sentence naming the change, with no type prefix. The body says what was wrong, why, and what the change does about it. - No AI or tool attribution in commits, pull requests or files. - Never force-push `main`. Contributions are licensed under Apache-2.0, as the project is (section 5 of the [license](LICENSE)), with no CLA or sign-off. [docs/RELEASING.md](docs/RELEASING.md) has the release steps.