---
name: trimtest
description: Run only the tests a code change can reach with trimtest, and know when to fall back to the full suite. Use when running or selecting tests in a repository that has a trimtest.toml or a .trimtest directory, or when the user mentions trimtest.
---

# Running tests with trimtest

trimtest selects and runs only the tests a change can reach, using each project's own runner. It is conservative:
when it cannot trace a change it runs everything. Docs for agents: https://trimtest.dev/llms.txt

## Do this

1. After editing code, run `trimtest run`. On a branch or fresh clone use `trimtest run --base origin/<base-branch>`
   (no recorded map needed).
2. Handle the exit code:
   - `0` passed or nothing selected: continue.
   - `1` a test failed: fix it and run again (failed tests run first next time).
   - `2` trimtest itself failed: read the message and run `trimtest check`.
   - `3` selection is uncertain: run `trimtest run --full`.
3. Use timeouts on long suites: `trimtest run --timeout 600 --total-timeout 1800`.
4. To understand a selection: `trimtest select --json`, `trimtest select --paths`, `trimtest explain <test>`.

## Do not

- Treat a green subset as a green suite. Before you call a task finished or open a PR, make sure the full suite is
  green (`trimtest run --full`, or the project's scheduled full run).
- Remove or skip the scheduled full run in CI.
- Edit `.trimtest/`; it is a cache. If it looks wrong, delete it and run `trimtest record`.

## If an expected test is not selected

Run `trimtest explain <test>`. If a dependency is invisible to imports (reflection, string-based access), run
`trimtest record --coverage`. For suites with no import link (end-to-end), add a `[map]` entry in `trimtest.toml`.
