Skip to content

CLI Reference

Run go-mutesting --help for the authoritative flag list. The most commonly used flags are documented here.

Targets

go-mutesting [flags] <pkg|file|dir> ...

Targets can be Go source files, directories, or import paths. The ... wildcard searches recursively. Test files (_test.go) are excluded automatically.

You can run go-mutesting from outside the targets' module, such as from a parent directory or from another module. It runs go in the targets' module, so the result matches a run from inside it. Targets that span more than one module, or are not in a module, are a tool error (exit 3); run go-mutesting once per module. This check is skipped when a go.work workspace is in use, and when a custom --exec runs the tests.

Core flags

Flag Default Description
--exec (built-in) Custom exec command for testing each mutation; limited to one worker. Empty/whitespace-only commands use the built-in runner.
--exec-timeout 10 Seconds to wait before killing the test process
--timeout-coefficient 0 (disabled) Scale per-mutation timeout as a multiple of an uncached baseline test-suite run (e.g. 3 = 3× the clean run). The clean pre-flight/coverage run uses a generous cap so a suite slower than --exec-timeout can still be measured. Overrides --exec-timeout when set for the built-in runner. With --exec, warns and is ignored; the script keeps --exec-timeout.
--workers all CPUs Number of parallel mutation workers
--config — Path to YAML config file

Output flags

Flag Description
--dry-run Count mutations per file and mutator without generating files or running tests; prints a summary table and exits 0. The count uses the same scope as a real run (--git-diff-lines, --blacklist, duplicate edits, and --run-mutant-id) and does not apply coverage
--no-exec Generate-only: write each mutant's source to the temp dir (keep it with --do-not-remove-tmp-folder) without running tests. Prints no summary, writes no reports, does not update the baseline, and skips quality gates; exits 0 unless a tool error occurs
--noop No-op (backward compatibility). The baseline pre-flight check — run the suite once unmutated, exit with a tool error if it fails — is now always on by default. Skipped under --coverage, --no-exec, --dry-run, or a custom --exec
--no-diffs Suppress diff output for all mutation results (useful in CI where diffs are noisy and the JSON report is consumed instead)
--output-statuses Show only listed result statuses in the terminal: k=killed e=escaped s=skipped n=not-covered x=errored (e.g. --output-statuses=ke). Does not affect JSON reports. Overrides --quiet when set.
--quiet Suppress killed/skipped lines; show only escaped mutants and summary (equivalent to --output-statuses=e)
--verbose Print full test output for each mutation
--debug Print internal debug information, including each mutation's 32-character blacklist checksum
--logger-github Emit escaped mutants as ::warning GitHub Actions annotations
--logger-gitlab Write go-mutesting-gitlab.json in GitLab Code Quality format
--logger-summary-json Write compact stats to go-mutesting-summary.json
--logger-agentic-json Write LLM-ready report to go-mutesting-agentic.json
--run-mutant-id Run only the mutant with this stable ID (copy the id field from go-mutesting-agentic.json). Other mutants are not classified or counted. --dry-run counts only this mutant. Exits 3 if no matching mutant is found or execution errors. Valid-ID runs suppress the summary and quality gates.
--version, -v Print version and exit 0

Quality gates

Flag Default Description
--min-msi -1 (disabled) Fail (exit 4) if overall MSI is below this value (0–100)
--min-covered-msi -1 (disabled) Fail (exit 4) if covered-code MSI is below this value
--fail-on-escaped false Fail (exit 4) if any mutant survives, without requiring --min-msi
--ignore-msi-with-no-mutations false Exit 0 when no mutations are generated (useful in PR mode)

MSI is killed mutants divided by all mutants. Skipped and errored mutants count in the total but not as kills. Covered MSI excludes not-covered mutants from the total.

Coverage

Flag Description
--coverage Run go test -coverprofile first; stop with exit 3 if it fails, otherwise skip test execution for uncovered lines and exclude them from covered-MSI
--per-test Build a per-test coverage map and run only the tests that cover each mutation. Best for packages with slow tests. Pairs well with --coverage. With --test-recursive, the map also covers subpackage tests. If any test's coverage profile is missing or unreadable, go-mutesting runs the full suite instead. With --exec, warns and is ignored.
--test-flags Extra flags passed to every go test call (e.g. --test-flags=-short). Use the = form for values starting with a dash. Adaptive timeout preserves a positive -count=N, adds -count=1 when absent, and rejects -count=0. With --exec --coverage, flags still apply to coverage preparation, never to custom command arguments. Without coverage, unused flags produce a warning.

Custom-runner option warnings go to stderr once per run, even without --verbose, and do not alter structured reports. --dry-run and --no-exec do not prepare coverage, run scripts, or emit these execution-option warnings.

Clause condition coverage

Go's statement coverage profiles do not record separate coverage counters for expression conditions in switch, type switch, or select case clauses (*ast.CaseClause.List or *ast.CommClause.Comm). A condition evaluated solely as false would therefore appear as uncovered in raw profiles. Under --coverage, mutations in a clause head (from its case or default keyword to its colon, which includes select/case-remove and select/default-remove) are treated as covered if their enclosing switch, type switch, or select statement header is covered. The clause heads are read before any mutation is applied. Clause bodies continue to use their own line coverage (an unselected clause body remains NOT COVERED).

Limitation: A header hit indicates that the switch statement ran, but cannot prove that an earlier clause did not always match first and shadow subsequent clauses. If an earlier clause always matches, mutants in subsequent conditions will be tested and reported as ESCAPED (a visible diagnostic) rather than NOT COVERED.

Target loading

Before generating mutants, go-mutesting stops with a tool error (exit 3) if any target package has load or type errors. The Cannot load target packages diagnostic includes the error count, package paths, and error text. This applies even when go test succeeds, and also to --dry-run and --no-exec; go-mutesting never silently skips type-dependent mutants because a target failed to type-check.

Vet

Every built-in go test run (baseline pre-flight, coverage, and mutant runs) passes -vet=off by default. A mutant is not meant to be lint-clean, and a go vet diagnostic on mutated code would fail the run and be miscounted as KILLED. The baseline and coverage runs use the same setting so they judge tests the same way the mutant runs do. Pass your own -vet via --test-flags to re-enable it (e.g. --test-flags=-vet=all); your flag wins in every run and no duplicate is added.

With --test-recursive, every run targets <package>/..., so the baseline and coverage runs cover the same tests as the mutant runs. The coverage run also passes -coverpkg=<package>, so tests in subpackages count towards the package's coverage.

Mutant test runs also pass -failfast. One failing test is enough to kill a mutant, so go test starts no new tests after the first failure. Pass --test-flags=-failfast=false to run the whole suite for every mutant; your flag wins and no duplicate is added.

--per-test builds its map the same way. Listing packages and tests gets only your build flags (-tags, -race, -gcflags, -ldflags, -mod, and so on), so tests behind a build tag are mapped. The coverage test binary is compiled with all of your flags, and each test runs with your runner flags (-short, -count, -v, ...) in -test.* form. Flags may be written -name, --name, or -name=value.

If a generated mutant does not compile, it is skipped rather than counted as killed by a test.

Filtering

Flag Description
--blacklist <file> File of MD5 checksums to skip
--disable <mutator> Disable a mutator by name (repeatable). Supports trailing-* wildcard (e.g. 'arithmetic/*'). Quote wildcard patterns to prevent shell glob expansion. A name that matches no mutator prints a warning on stderr. Config file equivalents: disable_mutators (denylist) and enable_mutators (allowlist) — see config reference.
--git-diff-lines Only mutate lines changed since --git-diff-base (compared against the merge-base, so it matches the PR diff even when the branch is behind its target)
--git-diff-base Git ref to diff against (default: HEAD)

Baseline

Flag Description
--baseline <file> Known-survivors file; only fail on new escapes
--update-baseline Record current survivors and exit 0; leave the baseline unchanged and exit 3 if any mutant errors

Exit codes

Code Meaning
0 All mutations tested; all quality gates passed
3 Invalid input or tool failure, including a failed clean coverage run, any errored mutant, or targets that are not in one Go module
4 A quality gate was not met (--min-msi, --min-covered-msi, or --fail-on-escaped)

A CLI exploratory-testing report for mutago documents coverage, per-test filtering, diff scoping, report output, and quality-gate workflows. That run tested mutago; it is a related-project reference, not a verification report for go-mutesting.

A later mutago CLI testing pass records custom executors and score gates. Its evidence also covers mutago, not go-mutesting.