/nexa-claude-audit:mutation-auditfrom nexa-claude-audit
Runs a mutation audit on the current repository: serial unit tests, time-boxed mutation testing on core logic, and a second unit test run, reporting the mutation score against an 80% threshold. Operates in a temporary git worktree without altering the working tree. Invoked explicitly via /mutation-audit.
Ships in nexa-claude-audit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
/mutation-audit, optionally with paths to mutate and --budget <minutes>
(default: 30). Example: /mutation-audit src/domain src/services --budget 60.
The paths are the core logic to mutate first, for example the matching engine and the rate
computation.This skill measures how well the unit tests detect a change in behaviour. A mutation run takes
much time, so it is a separate skill. It does not measure coverage; /test-efficacy-audit does
that. It does not triage the surviving mutants and it does not add tests. For that, use
/mutation-test of the Next.js or Go plugin.
Read ${CLAUDE_PLUGIN_ROOT}/skills/test-efficacy-audit/SKILL.md and apply these sections, with
the changes below:
Test efficacy audit: Scope exception. Also show the mutation tool before the first install.
Test efficacy audit: Test run rules, except the coverage rule: this skill runs the unit tests only. A mutation tool runs the test command once for each mutant, and a container start for each mutant makes the run too slow. Also set the mutation tool to one worker:
| Tool | Serial option |
|---|---|
| StrykerJS / Stryker.NET | --concurrency 1 |
| gremlins | --workers 1 |
| mutmut | --max-children 1 |
| PIT | -Dthreads=1 |
| cargo-mutants / Infection | -j 1 / --threads=1 |
| Metric | Pass | Warn | Fail |
|---|---|---|---|
| Mutation score (sampled scope) | ≥ 80 % | ≥ 60 % and < 80 % | < 60 % |
The threshold of 80 % is the same threshold as /mutation-test in the Go plugin.
Read and follow ${CLAUDE_PLUGIN_ROOT}/shared/AUDIT_CONTRACT.md: establish the report context,
detect the stack, and select the report path. Skill name: mutation-audit.
Title: Mutation Audit.
Do Test efficacy audit: Create the worktree.
Not measured for the mutation score, and
go to step 7. Mutation testing needs a green test run.Scope: use the paths from the arguments. Else use the business logic folders: services,
domain, use cases, validators, handlers with branches, utilities. Drop test files, generated
code, UI-only components and pages, cmd/ entry points, migrations, and configuration.
Core logic first: find the code that computes the results of the product: engines, matchers, calculators, rate and price computation, scoring, rules. Search the names and the folders for these words, and read the use cases. Put the core logic first in the scope, so that the budget reaches it first. Record the core logic files in the report.
Tool: install the tool in the worktree, or run it ephemerally. Add the serial option (see Shared rules):
| Language | Tool | Invocation (in $WT) | Scope option |
|---|---|---|---|
| TypeScript / JavaScript | StrykerJS | npm i -D @stryker-mutator/core @stryker-mutator/<runner>-runner, then npx stryker run --testRunner <runner> --reporters json,clear-text | --mutate <files> |
| Go | gremlins | go run github.com/go-gremlins/gremlins/cmd/gremlins@latest unleash --output "$TMP/gremlins-<n>.json" | package path argument |
| Python | mutmut | .venv/bin/pip install mutmut, then .venv/bin/mutmut run | paths_to_mutate in [tool.mutmut] |
| Java / Kotlin | PIT | Maven: mvn org.pitest:pitest-maven:mutationCoverage -DoutputFormats=XML; Gradle: add the info.solidsoft.pitest plugin in the worktree | -DtargetClasses=<pattern> |
| C# | Stryker.NET | dotnet tool install dotnet-stryker --tool-path "$TMP/tools", then "$TMP/tools/dotnet-stryker" --reporter json | --mutate <glob> |
| Rust | cargo-mutants | cargo install cargo-mutants --root "$TMP/tools", then "$TMP/tools/bin/cargo-mutants" --json | --file <path> |
| PHP | Infection | composer require --dev infection/infection, then vendor/bin/infection --logger-json="$TMP/infection.json" | --filter=<paths> |
| Ruby | mutant | gem install mutant mutant-rspec. Mutant needs a commercial license for private code: record this as a Gap, and ask the user first | subject expression |
When the language has no tool in this table, write Not measured and the reason.
Time budget: mutate the core logic files first. Then order the other scope files round-robin across the business logic folders, so that each folder is sampled early. Mutate in batches of up to 5 files (for Go: one package). Before each batch, compare the elapsed mutation time with the budget. Do not start a batch that the budget cannot contain. Estimate a batch from the earlier batches. Run a batch in the background when it can take longer than the command timeout. Wait for it to finish before the next batch.
Record the mutated files and the files that the budget did not reach. When a file in the scope has only integration tests, record it as a Gap.
Map the tool statuses to four groups:
| Group | Tool statuses |
|---|---|
| Detected | Killed, Timeout (StrykerJS, Stryker.NET, PIT, gremlins KILLED/TIMED OUT, cargo-mutants caught/timeout, mutmut killed/timeout) |
| Survived | Survived, LIVED, missed, survived |
| No coverage | NoCoverage, NOT COVERED, NO_COVERAGE |
| Excluded | CompileError, RuntimeError, Ignored, NOT VIABLE, unviable, skipped |
Mutation score = Detected / (Detected + Survived + No coverage), on the mutated files only. Excluded mutants are not in the score.
git -C "$WT" checkout -- . (keep the installed dependencies).Do Test efficacy audit: Remove the worktree. Do this also when an earlier step failed.
Use this template after the contract header, ## Summary, and ## Gaps. Gaps include a warn or
fail status, a Not measured mutation score, a red baseline, a difference between the baseline
and the post test run, the files that the budget did not reach, and the mutation tool license
note.
## Environment and tools
| Item | Value |
|------|-------|
| Measured commit | <full hash> (HEAD, uncommitted changes not measured) |
| Install command | |
| Unit test command | <command, with the serial option> |
| Excluded tests | <filter and reason> |
| Mutation tool and version | |
| Mutation test command | |
| Mutation budget | <n> min (used: <n> min) |
| Core logic files | <list> |
## Metrics and thresholds
| Metric | Value | Threshold (pass) | Status |
|--------|-------|------------------|--------|
| Mutation score | <n> % (<detected> / <total>) | ≥ 80 % | |
## Baseline test run
| Passed | Failed | Skipped | Duration |
|--------|--------|---------|----------|
(failing tests, when any: test file#line, test name, error line)
## Mutation run
| Mutated file | Detected | Survived | No coverage | Excluded | Score |
|--------------|----------|----------|-------------|----------|-------|
Files not reached in the budget: <list or "none">
## Surviving mutants
| File#line | Mutator | Original → mutated |
|-----------|---------|--------------------|
## Post test run
| Passed | Failed | Skipped | Duration | Same result as baseline |
|--------|--------|---------|----------|-------------------------|
List at most 50 surviving mutants, ordered by file and line, and give the total count. Include
the no-coverage mutants in the same table, marked (no coverage).
Confirm the contract checklist, then:
git worktree list shows no worktree from this run.Mutation run totals.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub nexadevapp/nexa-claude-skills-marketplace --plugin nexa-claude-audit8 skills in this plugin
/architecture-auditWrites a dated architecture audit report for the current repository: links to the existing architecture documents, diagrams, and ADRs; the dependencies found in the implementation; C4 context, container, and component diagrams, sequence diagrams, and entity relationship diagrams in Mermaid, drawn from the code; a 4+1 view coverage map; and a trace of the non-functional requirements. Works on any repository and any tech stack. Writes only docs/audit/architecture-audit/architecture-audit-YYYY-MM-DD-<hash>.md. This skill must only be invoked explicitly via /architecture-audit — never inferred from user messages.
/cicd-auditWrites a dated CI/CD audit report for the current repository: the CI/CD system and local gates, a table of every pipeline with its triggers, jobs, test categories, and deploy target, a Mermaid flowchart of the main pipeline, the quality gates, and the gaps. Works on any repository and any CI system (GitHub Actions, GitLab CI, Jenkins, CircleCI, Azure Pipelines, Bitbucket, and others). Writes only docs/audit/cicd-audit/cicd-audit-YYYY-MM-DD-<hash>.md. This skill must only be invoked explicitly via /cicd-audit — never inferred from user messages.
/code-metrics-auditWrites a dated code metrics audit report for the current repository: cyclomatic complexity, duplicated code percentage, coupling between objects (CBO), and depth of inheritance tree (DIT), each with a pass / warn / fail status against a fixed threshold. Static analysis only; runs no tests and no builds. Works on any repository and any tech stack. Writes only docs/audit/code-metrics-audit/code-metrics-audit-YYYY-MM-DD-<hash>.md. This skill must only be invoked explicitly via /code-metrics-audit — never inferred from user messages.
/infra-auditWrites a dated infrastructure audit report for the current repository: where and how the infrastructure is defined (Terraform, Pulumi, CDK, Helm, Kubernetes, Dockerfiles, Compose, serverless configs), the environments and how one is selected, the secret references (names only), and the local development infrastructure. Works on any repository and any tech stack. Writes only docs/audit/infra-audit/infra-audit-YYYY-MM-DD-<hash>.md. This skill must only be invoked explicitly via /infra-audit — never inferred from user messages.
/qa-auditWrites a dated QA audit report for the current repository: an inventory of every automated test, each put in exactly one category (unit, integration, E2E, misc), plus the explicitly tagged smoke tests and the skipped or disabled tests. Works on any repository and any tech stack. Writes only docs/audit/qa-audit/qa-audit-YYYY-MM-DD-<hash>.md. This skill must only be invoked explicitly via /qa-audit — never inferred from user messages.
/requirements-traceability-auditWrites a dated requirements traceability audit report for the current repository: the use case catalog, a matrix of which tests are linked to which use case by an explicit ID, candidate links, the gaps, and the external references (Jira keys, issue numbers, URLs) found in the repository. Works on any repository and any tech stack. Writes only docs/audit/requirements-traceability-audit/requirements-traceability-audit-YYYY-MM-DD-<hash>.md. This skill must only be invoked explicitly via /requirements-traceability-audit — never inferred from user messages.