mutation-testing
Skill4 starsChanged 3 months agoMITView on GitHub
This skill should be used when performing AI-powered mutation testing to evaluate and improve unit test quality. It generates targeted code mutants, runs tests to identify surviving mutants, and strengthens or creates tests to kill them. Accepts a file path, directory, or defaults to git diff changed files.
17 other projects use a version of this.
Adopted by
Most recently taken up by
- dmoka/skillstheir own version, first seen Oct 5, 2026
- jonmumm/skillstheir own version, first seen Oct 4, 2026
- Lixiuxiu559/AgentForgetheir own version, first seen Sep 29, 2026
- Hakkadaikon/hymmetheir own version, first seen Sep 9, 2026
- Amplicode/spring-skillstheir own version, first seen Sep 2, 2026
- auralshin/coding-skillstheir own version, first seen Aug 27, 2026
Other versions17 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 17
- rshankras/claude-code-apple-skills★ 777same name
- jvm-skills/jvm-skills★ 140same name
- Amplicode/spring-skills★ 126same name
- hugobowne/show-us-your-agent-skills★ 68same name
- mixpanel/mixpanel-headless★ 18same name
- tae0y/python-project-template★ 14same name
- kao273183/qa-claude-skill★ 8same name
- aks-builds/quality-skills★ 5same name
- shangyiy/life-kit★ 4same name
- vmobifystudio/app-dev-team★ 4same name
7 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository29 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .claude-pr/CLAUDE.mdCLAUDE.md
- claude-code-actionSkill
- harness-parity-councilSkill
- lisa-enforcement-censusSkill
- lisa-integration-testSkill
- lisa-learnSkill
- lisa-repair-intakeSkill
- lisa-review-projectSkill
- lisa-update-projectsSkill
- lisa-wiki-ingestSkill
- lisa-wiki-setupSkill
- lisa-wiki-usageSkill
- analyze-pluginSkill
- claude-code-actionSkill
- implement-plugin-paritySkill
- lisa-codex-paritySkill
- lisa-coding-agent-paritySkill
- lisa-enforcement-censusSkill
- lisa-integration-testSkill
- lisa-learnSkill
- lisa-review-projectSkill
- lisa-update-projectsSkill
- lisa-wiki-ingestSkill
- lisa-wiki-setupSkill
- lisa-wiki-usageSkill
- mutation-testingSkill
- plugin-parity-driftSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. 0 are common, 19 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 14 edited versions we read keep these.
19
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
If no argument provided, default to files changed in the current branch (via git diff).
- Distinctive: line 27
If no target files found, notify the user and stop.
- Distinctive: line 107
If build fails: discard the mutant, revert the change, log failure reason, continue to next
- Distinctive: line 130
If no distinguishing input exists → Discard as equivalent
- Distinctive: line 131
If a distinguishing input exists → Keep as a unique actionable mutant
- Distinctive: line 132
If uncertain → Keep and flag for human review
- Distinctive: line 173
Add assertions that detect the behavioral difference introduced by the mutant
- Distinctive: line 174
Add or modify test inputs that expose the defect in the mutant code
- Distinctive: line 176
Avoid adding trivial or unrelated checks
- Distinctive: line 195
If validation fails, refine the test (up to 3 total attempts).
- Distinctive: line 213
Add an inline comment above the test referencing the mutant:
- Distinctive: line 217
Commit the test improvement to the experimental branch
- Distinctive: line 230
If such a test needs a note about why its assertion is strong, write that in plain language.
- Distinctive: line 237
Remove all mutant commits from the experimental branch, keeping only test improvements:
- Distinctive: line 251
Run full test suite on the clean code with test improvements:
- Distinctive: line 255
All tests must pass. If any fail, investigate and fix.
- Distinctive: line 307
If the user chooses to merge:
- Distinctive: line 319
Commit mutants to protected branches (dev, staging, main)
- Distinctive: line 320
Leave mutant code in the codebase after completion
- Very specific: line 324
Use --no-verify with any git command
“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI-Powered Mutation Testing
Target: $ARGUMENTS
If no argument provided, default to files changed in the current branch (via git diff).
This skill implements the mutation testing workflow: generate targeted mutants, filter unproductive ones, run tests to find survivors, and harden the test suite by strengthening or creating tests that kill surviving mutants.
Step 1: Gather Context
1a. Identify Target Files
Determine what to mutate based on $ARGUMENTS:
- File path — Mutate the specified source file
- Directory — Mutate source files in the directory (exclude test files)
- No argument — Use git diff to find changed source files:
git diff --name-only $(git merge-base HEAD main)...HEAD -- '*.ts' '*.tsx' ':!*.spec.*' ':!*.test.*'
If no target files found, notify the user and stop.
1b. Gather Supporting Context
For each target source file, collect:
- Source code — Read the full file contents
- Existing tests — Find corresponding test files (
*.spec.ts,*.test.ts) via naming convention or import analysis - Test coverage — Run tests with coverage for the target file to identify uncovered lines:
The status is captured before the pipe, because a pipeline reports its LAST stage's exit code —status=0 bun run test -- --coverage --collectCoverageFrom='<target-file>' --silent >cov.log 2>&1 || status=$? tail -n 20 cov.log; echo "exit=$status"tailalways succeeds, so a failing run reads asexit=0(falsifiable-checks, pager-shadowed status).|| status=$?rather than; status=$?: underset -ethe;form exits before the assignment, so the failure is never reported at all. - Recent git history — Check for recent defects or frequent changes:
git log --oneline -10 -- <target-file> - Risk factors — Assess which risk factors apply to each file:
| Risk Factor | Indicators |
| Data security / compliance | Handles PII, auth, authorization, encryption, tokens |
| Integrations | External API calls, HTTP clients, webhooks, message queues |
| Code vs data model | Database queries, ORM entities, schema validation |
| Historic defects | Frequent bug-fix commits, complex conditional logic |
| Change impact | Exported utility functions, shared modules, base classes |
| Performance | Loops over large datasets, recursive calls, caching logic |
1c. Determine Test Runner
Detect the project's test framework from package.json scripts and devDependencies:
- Jest:
bun run test - Vitest:
bun run test - Other: adapt accordingly
Step 2: Generate Mutants
2a. Create Experimental Branch
git stash --include-untracked || true
git checkout -b mutation-testing/$(date +%Y-%m-%d-%H%M%S)
git stash pop || true2b. Generate Risk-Factor-Guided Mutants
For each target source file, generate 3-5 mutants that target the identified risk factors. Apply these mutation operators:
| Operator Type | Examples |
| Decision mutations | Change > to >=, && to ||, === to !== |
| Value mutations | Change constants, swap string literals, alter numeric values |
| Statement mutations | Remove guard clauses, delete error handling, skip validation |
| Integration mutations | Remove timeout handling, skip error code checks, bypass retry logic |
| Security mutations | Remove auth checks, bypass input validation, expose sensitive data in logs |
For each mutant, produce:
- Mutant ID — Sequential identifier (M001, M002, etc.)
- File and line — Exact location of the change
- Mutation description — What was changed and why
- Risk factor — Which risk factor this targets
- The code change — A minimal, atomic edit to introduce the defect
Mutant quality criteria — Each mutant must be:
- Non-trivial — Not just whitespace, comments, or formatting
- Buildable — The project must still compile/typecheck
- Realistic — Simulates a plausible programming error
- Targeted — Addresses a specific risk factor
- Atomic — Exactly one logical change per mutant
2c. Apply and Validate Each Mutant
For each generated mutant, one at a time:
- Apply the mutation — Edit the source file to introduce the defect
- Build check — Run
bun run typecheckto verify the project still compiles- If build fails: discard the mutant, revert the change, log failure reason, continue to next
- Commit the mutant —
git commit -am "mutant: M00X - <description>"
Step 3: Filter Mutants
3a. Run Tests Against Each Mutant
Process mutants in reverse order (LIFO — latest commit first):
- Run relevant tests against the mutant:
bun run test -- <test-file-path> --silent 2>&1 - Evaluate result:
- Test fails (mutant killed) → Revert the mutant commit. Log as killed. Proceed to next mutant.
- Test passes (mutant survived) → The mutant reveals a test gap. Keep it for Step 4.
3b. Equivalence Detection for Surviving Mutants
For each surviving mutant, verify it is not semantically equivalent to the original:
- AST-level comparison — Compare the diff. If the change is purely syntactic (reordering independent statements, renaming to equivalent aliases), discard it.
- Behavioral analysis — Reason about whether any input could distinguish the mutant from the original:
- If no distinguishing input exists → Discard as equivalent
- If a distinguishing input exists → Keep as a unique actionable mutant
- If uncertain → Keep and flag for human review
3c. Record Mutant Metadata
For each mutant, maintain a record:
{
"mutant_id": "M001",
"file": "<source-file>",
"line": 42,
"risk_factor": "Data security / compliance",
"description": "Removed authentication check before data access",
"status": "survived|killed|equivalent|discarded",
"commit_hash": "<hash>",
"tests_run": ["test-file.spec.ts"],
"equivalence_result": "not_equivalent|equivalent|uncertain"
}Print a summary table after filtering:
| Mutant | File | Risk Factor | Status |
|--------|------|-------------|--------|
| M001 | ... | ... | survived |
| M002 | ... | ... | killed |Step 4: Harden Test Suite
For each surviving, non-equivalent mutant:
4a. Determine Test Strategy
- Existing test covers the mutated region → Strengthen the existing test
- No test covers the mutated region → Generate a new test
4b. Strengthen Existing Test or Generate New Test
When strengthening an existing test, modify the test to:
- Add assertions that detect the behavioral difference introduced by the mutant
- Add or modify test inputs that expose the defect in the mutant code
- Preserve the test method name, signature, and overall structure
- Avoid adding trivial or unrelated checks
When generating a new test, create a test that:
- Specifically exercises the behavioral difference between original and mutant code
- Uses strong, precise assertions that detect the exact defect
- Focuses on the identified risk factor
- Includes realistic test data that exposes the mutant's flawed behavior
- Follows existing test naming conventions and structure from the codebase
4c. Validate Each Test (3-attempt limit)
For each improved or new test, validate with up to 3 attempts:
- Revert the mutant — Switch to original code
- Build check — Ensure the test compiles
- Run on original code — Test must PASS on unmodified code
- Re-apply the mutant — Switch back to mutated code
- Run on mutant code — Test must FAIL on the mutant
If validation fails, refine the test (up to 3 total attempts). If still failing after 3 attempts, flag for manual review.
4d. Apply Decision Matrix
Classify each test result:
| Original Code | Mutant Code | Signal | Action |
| Builds + Passes | Builds + Fails | Strong detection | Keep — alert developer |
| Builds + Passes | Builds + Passes | Weak assertion | Refine — strengthen assertion |
| Builds + Fails | Builds + Passes | Bad test | Discard — generate new test |
| Doesn't build | Any | Broken test | Discard — generate new test |
| Builds + Passes | Doesn't build | Untestable mutant | Discard — notify developer |
| Builds + Fails | Builds + Fails | Ambiguous signal | Discard — generate new test |
4e. Finalize Tests
For each validated test:
- Add an inline comment above the test referencing the mutant:
// Test hardened to kill mutant M001 (Risk Factor: Data security / compliance) - Commit the test improvement to the experimental branch
This annotation belongs to tests hardened during a mutation run, and to no others. "Validated test" means a test validated against a mutant this run generated and assigned an id to. It is not a general requirement on new or changed tests.
The annotation's only function is to point at the mutant it killed. A test
written from a code review, a bug report, or ordinary TDD has no mutant to
reference, and inventing one — M001 for a run that never happened, a risk
factor nobody assessed — is worse than omitting the comment: a later reader
reasonably concludes the file carries mutation coverage it does not have.
If such a test needs a note about why its assertion is strong, write that in plain language. Do not borrow this format, because the format is a citation.
Step 5: Cleanup and Report
5a. Revert All Mutants
Remove all mutant commits from the experimental branch, keeping only test improvements:
# Revert only the mutant commits recorded in Step 3c metadata.
jq -r '.[].commit_hash // empty' .mutation-testing/mutants.json | while read -r commit_hash; do
if printf '%s' "$commit_hash" | grep -Eq '^[0-9a-f]{7,40}$'; then
git revert --no-commit "$commit_hash"
fi
done
git commit -m "chore: revert all mutants after test hardening"5b. Validate Clean State
- Run full test suite on the clean code with test improvements:
bun run test 2>&1 - All tests must pass. If any fail, investigate and fix.
5c. Report Results
Print a comprehensive mutation testing report:
## Mutation Testing Report
**Target**: <files tested>
**Date**: <timestamp>
**Branch**: <experimental branch name>
### Summary
- Total mutants generated: X
- Killed by existing tests: X
- Survived (test gaps found): X
- Equivalent (discarded): X
- Build failures (discarded): X
- **Mutation Score**: X% (killed / (total - equivalent))
### Test Improvements
- Tests strengthened: X
- New tests generated: X
- Tests validated successfully: X
- Tests requiring manual review: X
### Surviving Mutants (Unresolved)
| Mutant | File | Line | Risk Factor | Description |
|--------|------|------|-------------|-------------|
| M00X | ... | ... | ... | ... |
### Oracle Gap
- Code coverage: X%
- Mutation score: X%
- Oracle gap: X% (coverage - mutation score)
### Risk Factor Coverage
| Risk Factor | Mutants | Killed | Survived | Score |
|---|---|---|---|---|
| Data security | X | X | X | X% |
| Integrations | X | X | X | X% |5d. Present Options
Ask the user:
- Merge test improvements — Cherry-pick test commits to the original branch, delete experimental branch
- Keep experimental branch — For further review before merging
- Discard everything — Delete the experimental branch, no changes kept
If the user chooses to merge:
git checkout <original-branch>
git cherry-pick <test-improvement-commits>
git branch -D <experimental-branch>Never
- Modify test files to make them pass on mutants (defeats the purpose)
- Generate mutants in test files (only mutate source code)
- Skip the build check after generating a mutant
- Commit mutants to protected branches (dev, staging, main)
- Leave mutant code in the codebase after completion
- Generate more than 5 mutants per file (diminishing returns)
- Skip equivalence detection for surviving mutants
- Mark a test as valid without running it on both original and mutant code
- Use
--no-verifywith any git command
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

