.claude/skills/mutation-testing/SKILL.md
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.
npx skillsauth add codyswanngt/lisa mutation-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
Determine what to mutate based on $ARGUMENTS:
git diff --name-only $(git merge-base HEAD main)...HEAD -- '*.ts' '*.tsx' ':!*.spec.*' ':!*.test.*'
If no target files found, notify the user and stop.
For each target source file, collect:
*.spec.ts, *.test.ts) via naming convention or import analysisbun run test -- --coverage --collectCoverageFrom='<target-file>' --silent 2>&1 | tail -20
git log --oneline -10 -- <target-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 |
Detect the project's test framework from package.json scripts and devDependencies:
bun run testbun run testgit stash --include-untracked || true
git checkout -b mutation-testing/$(date +%Y-%m-%d-%H%M%S)
git stash pop || true
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 quality criteria — Each mutant must be:
For each generated mutant, one at a time:
bun run typecheck to verify the project still compiles
git commit -am "mutant: M00X - <description>"Process mutants in reverse order (LIFO — latest commit first):
bun run test -- <test-file-path> --silent 2>&1
For each surviving mutant, verify it is not semantically equivalent to the original:
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 |
For each surviving, non-equivalent mutant:
When strengthening an existing test, modify the test to:
When generating a new test, create a test that:
For each improved or new test, validate with up to 3 attempts:
If validation fails, refine the test (up to 3 total attempts). If still failing after 3 attempts, flag for manual review.
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 |
For each validated test:
// Test hardened to kill mutant M001 (Risk Factor: Data security / compliance)
Remove all mutant commits from the experimental branch, keeping only test improvements:
# Revert mutant commits (identified by "mutant:" prefix in commit message)
git log --oneline | grep "^.* mutant:" | awk '{print $1}' | while read hash; do
git revert --no-commit "$hash"
done
git commit -m "chore: revert all mutants after test hardening"
bun run test 2>&1
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% |
Ask the user:
If the user chooses to merge:
git checkout <original-branch>
git cherry-pick <test-improvement-commits>
git branch -D <experimental-branch>
--no-verify with any git commanddocumentation
Onboard a user to the project via its LLM Wiki. Interviews the user about themselves in relation to the project, captures that to project-scoped memory only, then gives a guided tour of what the project is and sample questions they can ask. Use when someone is new to the project or asks to be onboarded. Read-mostly — it does not open PRs or write PII into the wiki.
documentation
Migrate an existing, hand-rolled wiki implementation onto the lisa-wiki kernel — phased and compatibility-first, with a strict no-loss guarantee. Use when adopting lisa-wiki in a repo that already has its own wiki/, ingest skills, docs, or roles. Renaming things into the canonical shape is fine; losing functionality or data is not. Ends by running /doctor.
development
Health-check the LLM Wiki. Reports orphan pages, contradictions, stale claims, broken internal links, missing index/log coverage, structure-manifest violations, and secret/tenant leaks. Use periodically or before hardening a wiki. Read-only — it reports findings, it does not fix them.
testing
Ingest source material into the LLM Wiki. With an argument (URL, file path, or prompt) it ingests that one source; with no argument it runs a full ingest across every enabled non-external-write source. Routes to the right connector, then runs the ordered pipeline (source note → synthesis → index → log → verify → state → commit/PR). Use whenever new knowledge should enter the wiki.