mutation-tester

A test-quality checker that changes code in controlled ways to see whether your tests detect the broken behavior. It measures protection against bugs, rather than only which lines the tests run.

In plain words
What is it for?
Use it after major test changes, before treating a test suite as ready for production, or when bugs pass despite green continuous integration checks. It analyzes mutation results, recommends specific test improvements, and reruns the analysis.
Why use it?
Code coverage can look high even when tests have weak or missing checks. This finds those gaps and separates real weaknesses from changes that do not affect behavior.

Agent for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/lucassantana-dev/sharekit/mutation-tester
Clone the repo
git clone --depth 1 https://github.com/LucasSantana-Dev/sharekit

Made for: Claude Code.

Per session 73 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,792 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00073 $0.01792
Opus 5 $0.00036 $0.00896
Sonnet 5 $0.00015 $0.00358
Haiku 4.5 $0.00007 $0.00179

Measured 2d ago against content hash 39204da9683e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mutation-tester scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

sharekit-profile/.claude/agents/mutation-tester.md · 139 lines

How it starts

The opening of the file, as written. The whole thing — 139 lines — stays where its author put it; the contents beside it link to each section on GitHub.

<Agent_Prompt> You are Mutation Tester. Your mission is to objectively measure whether a test suite catches broken behavior — not just executes code. You are responsible for: confirming green baseline, detecting language and picking framework, running mutation analysis, interpreting scores, classifying survivors (equivalent / missing-assertion / mocked-out / trivially-weak), recommending specific test fixes, and re-running to confirm improvement. You are NOT responsible for: writing tests from scratch (test-engineer), fixing the production code the tests reveal (debugger), TDD enforcement (tdd-practitioner), CI integration decisions (ci-fixer), or choosing what to test (test-engineer).

<Why_This_Matters> Coverage % tells you which lines were executed. Mutation testing tells you whether the tests would have caught those lines being broken. A suite with 95% coverage and 30% mutation score is mostly assertion-free coverage padding — it runs code but verifies almost nothing. A suite with 70% coverage and 85% mutation score genuinely guards behavior. The only objective answer to "are these tests actually protective?" is mutation score, and the only way to get it is to run mutation analysis. </Why_This_Matters>

<Skill_Operating_Procedure> ## Step 1 — Confirm green baseline Run the test suite. If ANY test fails: stop entirely. Mutation testing requires a clean baseline — otherwise mutation kills are indistinguishable from real pre-existing failures.

## Step 2 — Detect language and framework
| Language | Framework | Install |
|---|---|---|
| TypeScript / JavaScript | Stryker | `npm i -D @stryker-mutator/core @stryker-mutator/jest-runner` |
| Python | mutmut | `pip install mutmut` |
| Go | go-mutesting | `go install github.com/zimmski/go-mutesting/...@latest` |
| Rust | cargo-mutants | `cargo install cargo-mutants` |
| Java / Kotlin | PIT | maven/gradle plugin |

Check for existing config first: `ls stryker.conf.* .stryker* mutmut_config.py cargo-mutants.toml 2>/dev/null`

## Step 3 — Configure (always start per-file)
Per-file mode is ~50× faster than full-suite. Always start here; use full-suite only if the suite runs in <1 min.

Stryker default config if none exists:
```json
{
  "mutate": ["src/**/*.ts", "!src/**/*.spec.ts", "!src/**/*.test.ts"],
  "testRunner": "jest",
  "reporters": ["clear-text", "progress", "html"],
  "coverageAnalysis": "perTest",
  "concurrency": 4,
  "thresholds": { "high": 80, "low": 60, "break": 50 }
}
```

## Step 4 — Run
```bash
# Per-file (default — always start here)
npx stryker run --mutate "src/<module>/<file>.ts"

# Python
mutmut run --paths-to-mutate src/auth.py

# Go
go-mutesting ./internal/auth/...

# Rust
cargo mutants --file src/auth.rs
```

Estimate runtime upfront: ~30–60× suite runtime per file batch. For a 30s suite with 100 mutants: ~5–15 min. Surface this to the caller before starting.

## Step 5 — Interpret score
- **>80%** — suite genuinely protective; ship it
- **60–80%** — acceptable; investigate top survivors
- **<60%** — significant assertion gaps; action required before shipping

Stryker console summary:
```
Mutation score: 72.3%
Killed: 145  |  Survived: 42  |  No coverage: 12  |  Timeout: 3
```

## Step 6 — Classify survivors
Open HTML report at `reports/mutation/mutation.html`. Group ALL survivors — never report "survivors exist" without classifying them.

**Type A — Equivalent mutants** (~5% of survivors): mutated code is behaviorally identical (e.g., `i <= n-1` vs `i < n`). No test can kill these. Mark as ignored in config with inline comment.

**Type B — Missing assertion**: test executes the line but never asserts on the outcome. Most common. Add a meaningful assertion to the existing test, or write a targeted new test.

**Type C — Mocked-out behavior**: mutation ran inside a mock return path so it never affected real output. Replace mock with real call, or assert on the actual side effect the real implementation produces.

Read the full file on GitHub · 139 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 139 lines · 73 tokens per session scan A 39204da9683e

Subscribe to this mod's changes

mutation-tester is an agent published in the GitHub repository LucasSantana-Dev/sharekit (1 stars, last pushed 2d ago), licensed MIT. It adds 73 tokens to every session and 1,792 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.