# Command line

Every command and option of `vendor/bin/mutation-gate`. `mutation-gate <command> --help` prints one command's arguments and options in your terminal. The *Decided in* column links
the design decision behind each option.

## Commands

| Command                                                                                                                                                                                                                                            | What it does                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mutation-gate` or `mutation-gate run`                                                                                                                                                                                                             | Plan, run and judge in one process: what changed since the last commit that passed, or everything where none passed yet or `run.full` asks for it. With `--changed-since=<ref>`, only what the change since `<ref>` reaches; with `--full`, everything. With `--budget=<duration>`, the riskiest code first, within that time.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `coverage [--into=<dir>] [--from=<dir>]`                                                                                                                                                                                                           | Run the suite under coverage and write the gate's own map, `<dir>/map.json.gz` (`.mutation-gate/coverage` by default), for a later `plan --coverage=<dir>`. With `--from`, run nothing and read the reports this job's own coverage run left in that directory instead: `coverage.php` from `--coverage-php` for Pest and PHPUnit; `coverage-xml/`, `junit.xml` and `clover.xml` for Infection                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `plan`                                                                                                                                                                                                                                             | Work out the reach, drop proved units, cut shards and print the plan for a CI, saying first why it reaches what it does, what reaches every unit before the rest (`--ci=github\|gitlab\|buildkite\|circleci\|azure\|bitbucket\|jenkins\|json`, or `--shards=<n>` for a fixed count; `--coverage=<dir>` reads the map `coverage` wrote instead of running the suite)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `run --plan=<file> [--shard=<id>] [--results=<dir>] [--leftover=<k>]`                                                                                                                                                                              | Mutate one shard: the one `--shard` names, or the one the CI's environment names, and leave its result in `--results`; with `--leftover=<k>` and `--shard`, judge share k of the mutants that shard left at its deadline, as `leftovers` cut them, in its units that hold them, making only them, and leave the share's result as `<dir>/<shard>.leftover-<k>.json` ([ADR-0190](/docs/decisions/a-shard-hands-what-it-left-to-a-second-wave))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `verdict --plan=<file> --results=<dir>`                                                                                                                                                                                                            | Merge every shard's results, judge the floors, write reports and the ledger                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `deliver [--from=<dir>]`                                                                                                                                                                                                                           | Send what a run left in `<dir>` (`.mutation-gate/delivery` by default), with credentials that run never held: write the ledger to the store, post the comment on GitHub, GitLab or Bitbucket, as the CI it runs in says, post the alerts, and export OTLP. It runs from the gate's own installation and loads none of the project's code. Exits 2 where it cannot start or read the delivery, or where a trusted run's ledger is not written to the store `MUTATION_GATE_STORE` names                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `fetch [--to=<dir>]`                                                                                                                                                                                                                               | Read the default branch's ledger from the store with a key that only reads, and write it into `.mutation-gate/fetched`, where a run reads it beside the copy its own store keeps, as `proofs.copies` says. Written into another `<dir>`, a run reads it only where `<dir>` is the `directory` store's path, and then as the copy it keeps. It runs from the gate's own installation and loads none of the project's code. Exits 0 where `MUTATION_GATE_STORE` names no store, the ledger cannot be read or the job holds no key, saying why, and 2 where it cannot start, locate the store it names, name the default branch or write the ledger                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `baseline [--write]`                                                                                                                                                                                                                               | Show, or write, floors raised to what was measured                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `survivors [--plan=<file>]`, with the planning options of `plan`                                                                                                                                                                                   | On a branch's run, run the last run's survivors again before the shards: those the comment lists, on the change's lines first, at most `survivorsFirst.max`, file by file within `survivorsFirst.budget`, each found again by its id, reported gone, or not re-checked where its file had no time left. It writes the comment over its planned state and the step summary, and says how many still survive. It re-checks what the plan reaches, or plans first without one; `--jobs`, `--share` and `--from` share it among jobs. It writes no ledger and judges nothing, so it exits 0, or 2 where it cannot re-check                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `leftovers --plan=<file> --results=<dir> [--coverage=<dir>]`                                                                                                                                                                                       | After the shards, cut the mutants each one left at its deadline into shares for a second wave of jobs, each share's mutants grouped by source file and priced at the wall seconds a job's split streams take over them, each test file once and each mutant's second pass at every covering test, by the factor recent second-wave jobs measured, and each mutant no stream judged at the wall seconds its shard's own runs took each, to fill a job that stops where `shards.margin` says less the time its shard took to start judging, or to come to its own runs where it came to any, every capacity growing until the matrix holds 256 jobs or fewer; write them to `<dir>/leftovers.json` and print the jobs' matrix, a JSON list of each share's `shard` and `share`, `[]` where no shard left any; and `[]`, saying why on the error output, where the shards' results alone decide the verdict: a shard left no result or one that cannot be judged, or a shard stopped once the run could not pass ([ADR-0190](/docs/decisions/a-shard-hands-what-it-left-to-a-second-wave), [ADR-0196](/docs/decisions/a-job-stops-at-its-target-less-what-it-measured), [ADR-0301](/docs/decisions/no-second-wave-once-the-shards-decide-the-verdict), [ADR-0336](/docs/decisions/a-mutant-no-stream-judged-is-priced-at-its-own-run)) |
| `reproduce <id>`                                                                                                                                                                                                                                   | Run one recorded mutant again, alone, and show why it survives, with the runner's own output; the id may be a unique prefix of 6 or more. Exits 1 where the run finds other than what was recorded, and 2 where no ledger holds it or the run no longer makes it                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `explain <id> [--format=text\|json]`                                                                                                                                                                                                               | Show one mutant's diff, hint, covering tests and their outcomes, for a kill by static analysis the analyser and its finding's file, code and message, how the last run took its unit, and its history, from the ledgers and the last run, running nothing; the id may be a unique prefix of 6 or more, or a cluster's id. `--format=json` is described by [`resources/explain.schema.json`](https://github.com/nightworksio/php-mutation-gate/blob/HEAD/resources/explain.schema.json). Exits 2 where no record holds it                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `digest [--detail=<file\|id\|legend>] [--survivors=<n\|all>] [--tests=<n>]`                                                                                                                                                                        | Say the last run's verdict one fact a line, for an agent or a terminal, from the JSON report every verdict keeps at `.mutation-gate/report.json`, running nothing: the verdict, why, what to do, the counts each with its grade, each set, where the verdict comes from, the warnings, and the first 25 survivors, or as many as `--survivors` asks for, each with what test would catch it. With `--detail`, one target in depth instead: a file, a mutant by its id or a unique prefix of 6 or more, naming as many of its covering tests as `--tests` or `digest.tests` says, 5 by default, a cluster, or `legend` for what each word means ([reading the report](/docs/using/reading-the-report#the-digest-for-agents)). Exits 2 where no run left a report, it cannot be read, a count is no whole number, or the target names nothing the run holds                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `affected [--changed-since=<ref>] [--coverage=<dir>] [--format=files\|files0\|ids\|json]`                                                                                                                                                          | List the tests the change since the coverage map was measured can make fail, and with `--changed-since` the change since `<ref>` besides, running nothing: each test file a line (`files`, for PHPUnit 13's `--test-files-file`), each ended by a NUL byte (`files0`, for `xargs -0 vendor/bin/pest`, or `vendor/bin/phpunit` on PHPUnit 12), each test id a line (`ids`, for PHPUnit 13.2's `--test-id-filter-file`), or the JSON answer. The reasons go to standard error but in JSON. A map that is missing, does not say where it was measured or was measured in a dirty tree lists every test. Exits 0 whenever it answered, and 2 where git cannot tell what changed or `ids` cannot select the tests                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `tests`                                                                                                                                                                                                                                            | Print the tests report of the last run, judged again from the ledgers and the coverage map it left, running nothing: the useless, redundant and weakly asserting tests. Exits 0 whatever it finds, and 2 where no run has left one                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `mutators [--format=text\|json] [--ledger=<file>]`                                                                                                                                                                                                 | Print what each mutator costs and finds, from the tally the default branch's ledger keeps, or the `ledger.json.gz` `--ledger` names: one row for each mutator of each runner, the costliest first, with its mutants, kill rate, survivors, runner time, time per kill and share of every mutator's time, running and writing nothing. Each run that writes a ledger and judges every mutant adds to the tally. `--format=json` is described by [`resources/mutators.schema.json`](https://github.com/nightworksio/php-mutation-gate/blob/HEAD/resources/mutators.schema.json) ([ADR-0076](/docs/decisions/a-ledger-tallies-what-each-mutator-costs-and-finds-and-config-suggest-proposes-changes)). Exits 0 once printed, and 2 where the ledger cannot be read                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `machine [-- <program>…]`                                                                                                                                                                                                                          | Print this machine as one JSON object: its processor's `cpu` where Linux names it, and its `cores`. Given a program, it runs it once untimed and then 5 times, each round timed from the program's start to its exit, and adds `rounds` and their median `seconds`; the program's output goes to standard error. CI scales the local budgets by it ([ADR-0159](/docs/decisions/a-quick-round-judges-its-change-and-local-runs-are-held-to-tight-budgets)). It reads no config. Exits 0, and 2 where a round of the program did not end with 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `triage <path> [--repeat=<n>] [--order=runner\|killers-first]`                                                                                                                                                                                     | Run a unit, a file of a tree or a held path, n times (5 by default, 2 or more) and list every mutant whose result varied, with the runs that gave each result, each mutant's tests in the order `--order` names (`tests.order` by default). Exits 1 where a mutant varied, 0 where none did, and 2 where the unit cannot be run                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `watch`                                                                                                                                                                                                                                            | Re-judge what each save reaches; in the daemon that serves the project, started where none runs and `local.serveStart` is `watch`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `lsp [--severity=error\|warning\|information\|hint] [-- <watch option>…]`                                                                                                                                                                          | Serve an editor as a language server on standard input and output: run `watch --output=events` in the workspace's root, with every other option given and those after `--`, and show each survivor as a diagnostic over the line its site starts on, coded with its id, a warning by default, with code actions that run `explain`, `stub` and `stub --write` for it ([ADR-0133](/docs/decisions/outbreak-serve-holds-the-map-the-ledgers-and-the-coverage-in-memory)). `--stdio`, which editors pass, is the only transport. Exits 2 where no Outbreak binary is in use                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `serve [--stop] [--detached]`                                                                                                                                                                                                                      | Keep the gate loaded for the project, listening on `.mutation-gate/serve.sock`, and run `watch`, `pre-commit` and `pre-push` there, each in a child of its own, until no request comes for `local.serveIdle`, a request finds the gate's version, `composer.lock` or the config changed since it started, or `serve --stop` stops it. `pre-commit` and `pre-push` use a daemon only where one runs, and each of the three runs on its own where no daemon serves it. `--detached` leaves the session of the command that started it, as `watch` starts it                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `pre-push [<remote> [<url>]] [--stdin=<lines>]`                                                                                                                                                                                                    | Judge the commits being pushed, as CI will, after printing each reached tree's score change. The refs come from git's lines on standard input, from `--stdin` where a hook manager read them, as CaptainHook does, or, where neither holds a line, from the variables the pre-commit framework sets. Each line must be a local ref, its commit, a remote ref and its commit, each commit a full object name in hex                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `pre-commit`                                                                                                                                                                                                                                       | Print each reached tree's score change from the local ledger; runs nothing and always exits 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `hook install [--pre-commit]` / `hook uninstall`                                                                                                                                                                                                   | Add or remove the pre-push hook, and with `--pre-commit` the pre-commit hook too                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `init [--format=php\|json\|yaml\|neon] [--ci[=github\|gitlab\|buildkite\|circleci\|azure\|bitbucket\|jenkins]] [--editor=vscode] [--hook[=git\|captainhook\|grumphp\|pre-commit]] [--no-hook] [--native=allow\|refuse] [--dry-run] [--no-measure]` | Detect the runner, preset, trees, CI and an Infection config; where no config is here, ask in turn what detection leaves open: the runner where both are installed, the CI where the files show none or several, whether to import the Infection config found, what to do with the runner's own ignore markers found, where to set the pre-push hook up, and whether to add `composer mutate` to the scripts in `composer.json`, each defaulting to what detection found, and asking nothing with `--no-interaction`, with no terminal, or in CI; write a config holding the runner and the preset it found (PHP by default, or the file `--config` names, in the format of its extension), listing the trees the tree source finds in a comment, or for JSON in what it says, and add `.mutation-gate/` to `.gitignore`; with `--ci`, a pinned CI definition (`--ci` alone takes the detected CI), with `--editor`, VS Code's watch task, and with `--hook`, the hook, each only where none exists, and otherwise what to add to it; run the suite once under coverage and say what a full run takes, cut into shards as the config asks, with the hot paths nothing holds; then say what to run next: `doctor`, the first run, and `git add` of the files it wrote                                                                    |
| `init --from[=<file>]` or `import [<file>] [--format=php\|json\|yaml\|neon] [--no-measure]`                                                                                                                                                        | Write a config from an Infection config, the file named or the one Infection itself would read, over what zero-config found; say of each of its keys whether it was imported, stays in that file or was dropped, and which keys to delete; then say what a full run takes, as `init` does                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `doctor [--measure] [--online] [--format=text\|json] [--fix [--yes]]`                                                                                                                                                                              | Report what would fail, run slowly or deserves attention, each with its fix, reading only files and earlier runs; exits 1 when something would fail. `--fix` shows the diff of every file it can fix and what it cannot fix, then asks once whether to write them; `--yes` answers yes, and with no terminal to ask and no `--yes` it writes nothing. It turns opcache off and loads pcov in the php.ini the runner's PHP loads, where it can write it, and names `pecl install pcov` rather than running it; lowers the PHPUnit config's `memory_limit` to `runner.memory`; adds the trees to its `<source>`; adds `.mutation-gate/` to `.gitignore`; applies `pest:patch` and `infection:patch`; and pins the installed release in each CI definition. Once it wrote, it looks again and exits as `doctor` does ([ADR-0083](/docs/decisions/doctor-fixes-what-it-found-after-a-diff)). `--fix` writes text, so it refuses `--format=json`                                                                                                                                                                                                                                                                                                                                                                                            |
| `stub <id> [--style=pest\|phpunit\|phpspec] [--write]`                                                                                                                                                                                             | Print a failing Pest or PHPUnit test or PhpSpec example for a survivor or an uncovered mutant, or one for a cluster, in the style of its nearest covering test, found as `explain` finds the mutant, with `Try: …` and its scaffold calling the function with the values rules found to kill the survivor where they found any ([ADR-0101](/docs/decisions/rules-find-a-concrete-way-to-kill-each-survivor)); with `--write`, add it to that file, or create one, never overwriting. Exits 2 where there is nothing to stub, with the next step where there is one, and under the Codeception and Testo runners, whose tests are in no style it writes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `dashboard --org=<org> --out=<dir> [--include-private]`                                                                                                                                                                                            | Build an organisation's dashboard into `<dir>`: `index.html`, one page with no script or style it loads, and `dashboard.json`, from each repository's `summary.json` on its `mutation-gate` branch, read through GitHub's API with `GITHUB_TOKEN`, for the repositories with `dashboard.topic` or those `dashboard.repositories` names. Private and internal repositories are left out unless `--include-private` is given, which it accepts only where GitHub says the Pages site of `GITHUB_REPOSITORY` is private ([ADR-0024](/docs/decisions/the-gate-runs-and-comments-beyond-github-and-aggregates-an-organisation)). Exits 2 where it was not given both options, the config cannot be read, GitHub cannot list the repositories, private ones may not be shown, or it cannot write                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `config:show [--format=…] [--resolved]` / `config:schema`                                                                                                                                                                                          | Print the effective config (JSON by default), each context block as written, or with `--resolved` as a run in its contexts reads it; or the JSON Schema                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `config:suggest [--ledger=<file>]`                                                                                                                                                                                                                 | Print the config changes the ledger gives evidence for, each with its evidence: of the runner the config chooses, an idle mutator, which costs time and finds nothing, and a noisy one, whose mutants are mostly ignored or equivalent, turned off by `mutators.except`, and a `paths` entry doubling the timeout of a directory whose mutants run out of time, by the `suggest.*` thresholds; then the config file with them laid over it, as a unified diff in its own format. A change the config cannot say is named with why, and left out of the diff. It writes nothing ([ADR-0076](/docs/decisions/a-ledger-tallies-what-each-mutator-costs-and-finds-and-config-suggest-proposes-changes)). Exits 0 whatever it suggests, and 2 where the config or the ledger cannot be read                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `migrate [--write]`                                                                                                                                                                                                                                | Show the diff that moves the config and the baseline to the current release, and with `--write`, write it. A PHP config keeps its comments and layout, and only the builder calls a release retired change. A JSON config and the baseline change key by key. A YAML or NEON config is written again, and its comments are not kept. The baseline is the one the config names, or `mutation-gate.baseline.json` while the config does not read. A change migrate cannot make is listed for a hand edit. Exits 0 where every file is current or written, 1 where a change is pending without `--write` or left for a hand edit, and 2 where a file cannot be read                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `pest:patch`                                                                                                                                                                                                                                       | Apply the optional Pest patches ([ADR-0004](/docs/decisions/pest-and-infection-behind-one-runner-port)). Exits 0 once they are applied, and 2 where one cannot be                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `infection:patch`                                                                                                                                                                                                                                  | Give Infection the gate's mutant limit ([ADR-0004](/docs/decisions/pest-and-infection-behind-one-runner-port)). Exits 0 once it is applied, 1 where the installed Infection is not a release of 0.35.0 to 0.35.15, and 2 where Composer's `installed.json` cannot be read, lists no Infection, or a change cannot be applied. In `post-install-cmd`, a non-zero exit fails `composer install`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

## Options

| Option                                                                                            | Accepted by                                                      | What it does                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Decided in                                                                                                                                                                                      |
| ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--config=<path>`                                                                                 | every command but `deliver` and `fetch`                          | Read this config file instead of looking for one                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | [0002](/docs/decisions/one-typed-config-from-several-formats)                                                                                                                                  |
| `--no-extensions`                                                                                 | every command but `deliver` and `fetch`                          | Load only the extensions of this package and its first-party plugins, and no third-party code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | [0001](/docs/decisions/a-framework-free-core-behind-nine-ports)                                                                                                                                |
| `--context=<local\|ci\|github\|gitlab\|bitbucket\|azure\|buildkite\|jenkins\|circleci\|pr\|main>` | every command but `deliver` and `fetch`                          | Put the run in this context, and in `ci` beneath a CI's, `pr` and `main`, whose blocks under `contexts` it lays, instead of the one the environment and the CI plan tell; `watch`, `pre-commit` and `pre-push` are in `local` without it                                                                                                                                                                                                                                                                                                                                                                                                                            | [0071](/docs/decisions/a-config-holds-a-block-for-each-context-a-run-is-in)                                                                                                                    |
| `--deliver-later`                                                                                 | `plan`, `survivors`, `verdict`                                   | Send nothing that needs a credential and write no store: leave the ledger and the comment, alert and OTLP payloads in `.mutation-gate/delivery/planned`, `.mutation-gate/delivery/survivors` or `.mutation-gate/delivery/verdict`, begun empty, for `deliver`; on a pull request the comment is left whether or not the job holds a token                                                                                                                                                                                                                                                                                                                           | [0007](/docs/decisions/a-proof-is-keyed-by-everything-its-verdict-reads)                                                                                                                       |
| `--runner=<name>`                                                                                 | every command but `deliver` and `fetch`                          | Set `runner`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | [0002](/docs/decisions/one-typed-config-from-several-formats)                                                                                                                                  |
| `--report=<name>:<path>`                                                                          | every command but `deliver` and `fetch`, repeatable              | Add a file report to `reports`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | [0002](/docs/decisions/one-typed-config-from-several-formats)                                                                                                                                  |
| `--changed-since=<ref>`                                                                           | `plan`, `run` without a plan, `survivors`, `affected`            | Mutate, or list the tests of, only what the change since `<ref>` reaches; `last-passed`, the default of `plan` and `run`, is the newest passing commit; `last-run`, for `plan` and `run` off the default branch, reads the change from the commit the scope's last run of the same kind judged, falling back to the fetched default branch                                                                                                                                                                                                                                                                                                                          | [0005](/docs/decisions/what-a-change-reaches-is-what-is-mutated)                                                                                                                               |
| `--full`                                                                                          | `plan`, `run` without a plan, `survivors`                        | Mutate everything, whatever the event and `run.full`; an error beside `--changed-since`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | [0005](/docs/decisions/what-a-change-reaches-is-what-is-mutated)                                                                                                                               |
| `--unproven`                                                                                      | `plan`, `run` without a plan, `survivors`                        | Mutate everything and take no proof, so every unit runs whatever the ledgers hold: the backstop of a key that reads only the gate's verdict code; an error beside `--changed-since`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | [0084](/docs/decisions/the-gate-is-keyed-by-the-code-a-verdict-depends-on)                                                                                                                     |
| `--sample`                                                                                        | `plan`, `run` without a plan, `survivors`                        | Run a sample of the units no run knows exactly, tree by tree, sized by `sampling.margin` and drawn from `sampling.seed`, and judge each tree on its estimated score's interval: passed where its lower bound reaches the floor, failed where its upper bound is below it, and otherwise undecided, which is exit code 2. New code, a unit a change-scoped run reaches, and every tree at a floor of 100 run in full. A sampled run records no commit as passed, raises no floor, judges no security set, and updates neither the badge, the trend nor the alerts; an error beside `--security` or `--suite`. Every shard and the verdict follow a plan made with it | [0020](/docs/decisions/a-change-lists-its-tests-an-analyser-can-kill-and-a-huge-repository-can-be-sampled)                                                                                     |
| `--budget=<duration>`                                                                             | every command but `deliver` and `fetch`                          | Set `budget`: stop after this long, riskiest code first, such as `90s`, `15m` or `1h30m`; `watch` and `pre-push` take it in place of `local.watchBudget` and `local.prePushBudget`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | [0008](/docs/decisions/a-run-spends-its-time-on-the-riskiest-code-first)                                                                                                                       |
| `--coverage=<dir>`                                                                                | `plan`, `run` without a plan, `survivors`, `affected`            | Read the coverage an earlier job wrote instead of running the suite                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once)                                                                                                                        |
| `--selection-only`                                                                                | `plan`                                                           | Stop at the selection: write the units the plan runs, with why it reached them, as one uncut shard, measuring no held coverage, handing no shard its map and taking no timing, and hand it to no CI. `plan.json` is marked `selectionOnly`, and `run --plan`, `verdict`, `leftovers` and `survivors` refuse it, since it holds no mutant time limit                                                                                                                                                                                                                                                                                                                 | [0290](/docs/decisions/a-plan-can-stop-at-its-selection)                                                                                                                                       |
| `--from=<dir>`                                                                                    | `coverage`                                                       | Read the reports this job's own run of the suite under coverage left in this directory instead of running the suite                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once)                                                                                                                        |
| `--into=<dir>`                                                                                    | `coverage`                                                       | The directory to write `map.json.gz` into, `.mutation-gate/coverage` by default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once)                                                                                                                        |
| `--from=<dir>`                                                                                    | `deliver`                                                        | The delivery to send, `.mutation-gate/delivery` by default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | [0007](/docs/decisions/a-proof-is-keyed-by-everything-its-verdict-reads)                                                                                                                       |
| `--jobs`                                                                                          | `survivors`                                                      | Print the jobs a CI shares the re-check among, as `{"shares":[1,2],"minutes":30}`: one per file of the survivors it takes, at most `survivorsFirst.shards`, none where it takes none, and the minutes each may take; one, saying why aside, where the survivors cannot be told. Re-checks nothing                                                                                                                                                                                                                                                                                                                                                                   | [0106](/docs/decisions/carried-survivors-are-judged-again-and-their-re-check-is-bounded-and-shared)                                                                                            |
| `--share=<i>`                                                                                     | `survivors`                                                      | Re-check the `i`-th share of the files of survivors, counted from 1, beside `--of`, and leave what it made in `.mutation-gate/survivors/<i>.json`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | [0106](/docs/decisions/carried-survivors-are-judged-again-and-their-re-check-is-bounded-and-shared)                                                                                            |
| `--of=<n>`                                                                                        | `survivors`                                                      | How many jobs share the re-check, beside `--share` or `--from`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | [0106](/docs/decisions/carried-survivors-are-judged-again-and-their-re-check-is-bounded-and-shared)                                                                                            |
| `--from=<dir>`                                                                                    | `survivors`                                                      | Report the survivors with what the `--of` shares left in this directory, a share that left nothing not re-checked                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | [0106](/docs/decisions/carried-survivors-are-judged-again-and-their-re-check-is-bounded-and-shared)                                                                                            |
| `--to=<dir>`                                                                                      | `fetch`                                                          | Where to write the default branch's ledger, `.mutation-gate/ledger` by default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | [0007](/docs/decisions/a-proof-is-keyed-by-everything-its-verdict-reads)                                                                                                                       |
| `--from[=<file>]`                                                                                 | `init`                                                           | Start from an Infection config: this file, or the one Infection would read                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | [0016](/docs/decisions/the-gate-takes-over-from-infection-and-reports-what-a-run-costs)                                                                                                        |
| `--ignores-for=<days>`                                                                            | `init`, `import`                                                 | How many days each ignore imported from an Infection config lasts, `90` by default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | [0016](/docs/decisions/the-gate-takes-over-from-infection-and-reports-what-a-run-costs)                                                                                                        |
| `--ci[=<name>]`                                                                                   | every command but `deliver` and `fetch`                          | Set `ci.plan`: this CI's format instead of the detected one. With `init`, also write that CI's definition, or the detected CI's where it names none                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once)                                                                                                                        |
| `--shards=<n>`                                                                                    | `plan`, `run` without a plan, `survivors`                        | Cut exactly n shards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once)                                                                                                                        |
| `--security`                                                                                      | `plan`, `run` without a plan, `survivors`                        | Make mutants with the security-tagged mutators alone, and judge only the security sets: each tree is shown exempt, and no commit is recorded as passed. Every shard and the verdict follow a plan made with it                                                                                                                                                                                                                                                                                                                                                                                                                                                      | [0021](/docs/decisions/mutators-are-written-once-and-first-party-sets-can-leave)                                                                                                               |
| `--suite=<name>`                                                                                  | `plan`, `run` without a plan, `survivors`                        | Judge the mutants by this PHPUnit `<testsuite>`'s tests alone, the coverage run's among them, and hold no floor: each tree and security set is shown exempt, unless `--security` keeps the security sets held, and no commit is recorded as passed. Takes no `--coverage`. Every shard and the verdict follow a plan made with it                                                                                                                                                                                                                                                                                                                                   | [0025](/docs/decisions/unchanged-code-is-pruned-and-tests-are-judged-by-their-assertions)                                                                                                      |
| `--plan=<file>`                                                                                   | `run`, `verdict`, `survivors`                                    | The plan the shards and the verdict follow                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once)                                                                                                                        |
| `--shard=<id>`                                                                                    | `run` with a plan                                                | The shard to mutate, instead of the one the CI names                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once)                                                                                                                        |
| `--leftover=<k>`                                                                                  | `run` with a plan and `--shard`                                  | Judge share k of the mutants the shard left at its deadline, as `leftovers` cut them                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | [0190](/docs/decisions/a-shard-hands-what-it-left-to-a-second-wave)                                                                                                                            |
| `--results=<dir>`                                                                                 | `run` with a plan, `verdict`                                     | Where each shard leaves its result, and where the verdict reads every one                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once)                                                                                                                        |
| `--output=console\|problems`                                                                      | `run`, `watch`, `pre-push`                                       | `problems` prints one `<path>:<line>:<col>: <severity>: <message> [<rule>] <id>` line per result, for editors; `console`, the default, prints the console report                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | [0015](/docs/decisions/a-survivor-reaches-the-editor-the-test-file-and-the-commit)                                                                                                             |
| `--output=events`                                                                                 | `watch`                                                          | Print one line of JSON per judged mutant as its batch ends, and one as each round ends, `{"round", "mutants", "why"}` (`judged`, `changed`, `invalid` or `unjudged`; how many mutants it printed; why it judged none). A mutant's line is `{"mutant", "site", "status", "by", "quick", "unit", "digest"}`, the status `killed`, `survived`, `timeout`, `pending` or `equivalent`, and no verdict                                                                                                                                                                                                                                                                    | [0146](/docs/decisions/a-watch-round-is-quick-advisory-and-keyed-apart)                                                                                                                        |
| `--whole-report`                                                                                  | `watch`                                                          | End each round with the whole report; without it, where `local.streamBatches` is on, the console prints only one block per unit as each batch ends                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | [0146](/docs/decisions/a-watch-round-is-quick-advisory-and-keyed-apart)                                                                                                                        |
| `--only=changed`                                                                                  | `run`, `watch`, `pre-push` with `--output=problems`              | Print only the mutants on changed lines                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | [0015](/docs/decisions/a-survivor-reaches-the-editor-the-test-file-and-the-commit)                                                                                                             |
| `--write`                                                                                         | `stub`                                                           | Append the stub to its nearest covering test file, or create one; never overwrite                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | [0015](/docs/decisions/a-survivor-reaches-the-editor-the-test-file-and-the-commit)                                                                                                             |
| `--write`                                                                                         | `migrate`                                                        | Write the migrated config and baseline                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | [0026](/docs/decisions/configs-and-baselines-move-forward-with-one-command)                                                                                                                    |
| `--write`                                                                                         | `baseline`                                                       | Write the raised floors to the baseline, rather than showing them                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | [0003](/docs/decisions/a-floor-only-rises)                                                                                                                                                     |
| `--format=<format>`                                                                               | `init`, `import`, `config:show`, `explain`, `doctor`, `affected` | The format written: `php`, `json`, `yaml` or `neon` for the config `init` and `import` write (`php` by default) and `config:show` prints (`json` by default); `text` or `json` for `explain` and `doctor`; `files`, `files0`, `ids` or `json` for `affected` (`files` by default)                                                                                                                                                                                                                                                                                                                                                                                   | [0002](/docs/decisions/one-typed-config-from-several-formats), [0020](/docs/decisions/a-change-lists-its-tests-an-analyser-can-kill-and-a-huge-repository-can-be-sampled)                     |
| `--resolved`                                                                                      | `config:show`                                                    | Print the config of a run in the contexts it is in, or those `--context` names, with their blocks laid and `contexts` dropped, naming the contexts on standard error                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | [0071](/docs/decisions/a-config-holds-a-block-for-each-context-a-run-is-in)                                                                                                                    |
| `--editor=vscode`                                                                                 | `init`                                                           | Set VS Code up: its watch task, in `.vscode/tasks.json`, and the SARIF Viewer recommended in `.vscode/extensions.json`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | [0015](/docs/decisions/a-survivor-reaches-the-editor-the-test-file-and-the-commit)                                                                                                             |
| `--detail=<file\|id\|legend>`                                                                     | `digest`                                                         | One file, mutant or cluster in depth, or `legend` for what each word means                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | [0009](/docs/decisions/every-verdict-is-readable-by-a-machine-and-a-reviewer)                                                                                                                  |
| `--survivors=<n\|all>`                                                                            | `digest`                                                         | How many survivors the overview lists, 25 by default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | [0009](/docs/decisions/every-verdict-is-readable-by-a-machine-and-a-reviewer)                                                                                                                  |
| `--tests=<n>`                                                                                     | `digest`                                                         | How many of a mutant's covering tests its detail names, in place of `digest.tests`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | [0009](/docs/decisions/every-verdict-is-readable-by-a-machine-and-a-reviewer)                                                                                                                  |
| `--repeat=<n>`                                                                                    | `triage`                                                         | How many times to run the unit, 2 or more, 5 by default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | [0013](/docs/decisions/a-run-learns-which-tests-kill-and-how-wide-to-cut)                                                                                                                      |
| `--order=runner\|killers-first`                                                                   | `triage`                                                         | The order of each mutant's tests, `tests.order` by default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | [0013](/docs/decisions/a-run-learns-which-tests-kill-and-how-wide-to-cut)                                                                                                                      |
| `--pre-commit`                                                                                    | `hook install`                                                   | Also add the pre-commit hook, which shows the score change and never blocks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | [0010](/docs/decisions/the-gate-runs-while-you-work-and-before-you-push)                                                                                                                       |
| `--org=<org>`, `--out=<dir>`, `--include-private`                                                 | `dashboard`                                                      | The organisation, the directory the dashboard is written to, and whether private and internal repositories are shown                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | [0024](/docs/decisions/the-gate-runs-and-comments-beyond-github-and-aggregates-an-organisation)                                                                                                |
| `--style=pest\|phpunit\|phpspec`                                                                  | `stub`                                                           | The stub's style, instead of the nearest covering test's                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | [0015](/docs/decisions/a-survivor-reaches-the-editor-the-test-file-and-the-commit)                                                                                                             |
| `--dry-run`, `--stdout`                                                                           | `init`                                                           | Print every file, the config and the line `.gitignore` would gain among them, instead of writing it                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | [0015](/docs/decisions/a-survivor-reaches-the-editor-the-test-file-and-the-commit)                                                                                                             |
| `--sharded`, `--single`                                                                           | `init --ci=github`                                               | The reusable workflow or the one-step action, instead of the one the estimated cost picks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | [0015](/docs/decisions/a-survivor-reaches-the-editor-the-test-file-and-the-commit)                                                                                                             |
| `--hook[=git\|captainhook\|grumphp\|pre-commit]`, `--no-hook`                                     | `init`                                                           | Answer the hook question: git's own `pre-push` hook, which a bare `--hook` means, or the hook manager's config calling the gate: CaptainHook's `captainhook.json`, GrumPHP's `grumphp.yml` or the pre-commit framework's `.pre-commit-config.yaml`; where the manager reads a config already, print what to add to it. `--no-hook` sets no hook up                                                                                                                                                                                                                                                                                                                  | [0017](/docs/decisions/adopting-the-gate-takes-one-command-and-every-run-says-what-it-saved), [0024](/docs/decisions/the-gate-runs-and-comments-beyond-github-and-aggregates-an-organisation) |
| `--native=allow\|refuse`                                                                          | `init`                                                           | Answer the native-markers question: `allow` writes `ignores.native: allow`, `refuse` leaves the default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | [0017](/docs/decisions/adopting-the-gate-takes-one-command-and-every-run-says-what-it-saved)                                                                                                   |
| `--no-measure`                                                                                    | `init`, `import`                                                 | Estimate a full run from lines of code, rather than from a coverage run of the suite                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | [0017](/docs/decisions/adopting-the-gate-takes-one-command-and-every-run-says-what-it-saved)                                                                                                   |
| `--stdin=<lines>`                                                                                 | `pre-push`                                                       | The lines git handed the hook, from a hook manager that read them: CaptainHook's `{$STDIN}`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | [0024](/docs/decisions/the-gate-runs-and-comments-beyond-github-and-aggregates-an-organisation)                                                                                                |
| `--measure`                                                                                       | `doctor`                                                         | Add one coverage run: a green suite, a working driver and the hot paths                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | [0017](/docs/decisions/adopting-the-gate-takes-one-command-and-every-run-says-what-it-saved)                                                                                                   |
| `--online`                                                                                        | `doctor`                                                         | Also read GitHub's settings with the token: the required verdict, the fork approval policy, the schedule                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | [0017](/docs/decisions/adopting-the-gate-takes-one-command-and-every-run-says-what-it-saved)                                                                                                   |
| `--kill-matrix=first\|full`                                                                       | `plan`, `run`, `survivors`                                       | `full` records every test that kills each mutant, for the redundant-test report (Pest, and the PHPUnit, PhpSpec, Codeception and Testo runners)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | [0014](/docs/decisions/every-test-is-judged-by-what-it-kills)                                                                                                                                  |
| `--publish-dir=<dir>`                                                                             | `verdict`, `run` without a plan                                  | Where the badge and trend are written, `.mutation-gate/publish` by default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | [0009](/docs/decisions/every-verdict-is-readable-by-a-machine-and-a-reviewer)                                                                                                                  |

## Arguments

| Argument                 | Taken by                       | What it is                                                                                    |
| ------------------------ | ------------------------------ | --------------------------------------------------------------------------------------------- |
| `<id>`                   | `reproduce`, `explain`, `stub` | A mutant's id, or a unique prefix of 6 or more; `explain` and `stub` also take a cluster's id |
| `<path>`                 | `triage`                       | The unit: a file of a tree, or a held path                                                    |
| `install` or `uninstall` | `hook`                         | Whether to add the hooks or remove them                                                       |
| `<file>`                 | `import`                       | The Infection config to import; the one Infection itself would read where none is named       |
| `<remote>`, `<url>`      | `pre-push`                     | The remote pushed to and its URL, as git hands them to the hook                               |

## Exit codes

| Code | Meaning         |
| ---- | --------------- |
| `0`  | Passed          |
| `1`  | Failed          |
| `2`  | Could not judge |

*Could not judge* means, for example, an invalid config, an opening test run
that failed, a shard with no results, a command line the gate cannot read,
a command it does not know, or a failure it did not anticipate. A failed
verdict is always `1`, and nothing else is. `run` with a plan exits `0` once
its shard's result is written, because the verdict judges it, and `2` when it
cannot write it, the plan belongs to another commit, or the CI's shard count
differs from the plan's. `verdict` exits `2` where the plan belongs to another
commit, or where a shard's result stands in the place of another shard.
