For AI agents
If an AI agent edits code in a repository that uses trimtest, this page is the contract: when to trust a selection, what the exit codes mean, and how to fall back to the full suite.
Machine-readable access to these docs
Section titled “Machine-readable access to these docs”| URL | What it is |
|---|---|
/llms.txt |
index of the docs with a short description of each page |
/llms-full.txt |
every page concatenated as markdown |
<any page URL>.md |
that page as plain markdown, for example /start/quick-start.md |
/schema/trimtest.schema.json |
JSON Schema for trimtest.toml |
/skill/SKILL.md |
a Claude Code skill that wraps the rules below |
The rules
Section titled “The rules”- Select, then run. After a change,
trimtest runruns only the tests the change can reach. In a pull request or a fresh clone usetrimtest run --base origin/<base-branch>; it needs no recorded map. - Read the exit code (reference):
0passed (or nothing was selected): proceed.1a test failed: fix it, then run again. Failed tests always run first next time.2trimtest itself failed: read the message, runtrimtest check.3selection is uncertain: run the full suite withtrimtest run --full.
- Trust the conservatism, not a green subset alone. trimtest runs everything when it cannot trace a change.
A green subset means the selected tests passed, not that the whole suite would. Before declaring a task done, or
before merging, make sure the project’s scheduled full run (or
trimtest run --full) is green. - Do not skip the nightly full run or remove it from CI to save time.
- Set a timeout so a hung runner cannot stall you:
trimtest run --timeout 600 --total-timeout 1800. - Never edit
.trimtest/by hand. It is a cache; delete it and runtrimtest recordif it looks wrong.
Reading a selection
Section titled “Reading a selection”trimtest select --json # structured: changed files, unobserved changes, selected tests with reasonstrimtest select --paths # just the test paths, one per linetrimtest explain tests/test_core.py # why one test was, or was not, selectedThe JSON shape is stable; new fields may be added. A non-empty unobserved list means a
changed file is not known to reach any test, so consider trimtest run --strict or a full run.
When a test you expected is missing
Section titled “When a test you expected is missing”trimtest explain <test>prints every reason and the evidence tier.- If a dependency is invisible to imports (reflection, string-based access), record coverage:
trimtest record --coverage. - For suites with no import link (end-to-end), add a
[map]entry totrimtest.toml.
Drop-in AGENTS.md snippet
Section titled “Drop-in AGENTS.md snippet”Paste this into the AGENTS.md (or CLAUDE.md) of a repository that uses trimtest:
## Running tests
This repo uses [trimtest](https://trimtest.dev) to run only the tests a change can reach.
- After a change: `trimtest run` (or `trimtest run --base origin/main` on a branch or fresh clone).- Exit codes: 0 pass, 1 test failed (fix and rerun), 2 trimtest error (`trimtest check`), 3 selection uncertain (run `trimtest run --full`).- `trimtest explain <test>` says why a test was or was not selected. `trimtest select --json` is machine-readable.- A green subset is not a green suite: run `trimtest run --full` before you call a task finished or open a PR, and never remove the scheduled full run from CI.- Use `--timeout 600 --total-timeout 1800` for long suites. Do not edit `.trimtest/`.- Docs for agents: https://trimtest.dev/llms.txtClaude Code skill
Section titled “Claude Code skill”Save /skill/SKILL.md as .claude/skills/trimtest/SKILL.md in a repository (or in
~/.claude/skills/trimtest/ for every repository) and Claude Code will use these rules whenever it runs tests.