NWave nw-mutation-test
Runs feature-scoped mutation testing to validate test suite quality. Use after implementation to verify tests catch real bugs (kill rate >= 80%).
git clone https://github.com/nWave-ai/nWave
T=$(mktemp -d) && git clone --depth=1 https://github.com/nWave-ai/nWave "$T" && mkdir -p ~/.claude/skills && cp -r "$T/nWave/skills/nw-mutation-test" ~/.claude/skills/nwave-ai-nwave-nw-mutation-test && rm -rf "$T"
nWave/skills/nw-mutation-test/SKILL.mdNW-MUTATION-TEST: Feature-Scoped Mutation Testing
Wave: QUALITY_GATE Agent: Crafter (nw-software-crafter)
Overview
Run mutation testing against implementation files from the current feature. Extracts targets from execution-log.json|generates feature-scoped configs|delegates to software-crafter. Uses cosmic-ray (Python)|PIT (Java)|Stryker (JS/TS/C#).
Context Files Required
- Implementation file extractiondocs/feature/{feature-id}/deliver/execution-log.json
- Automated config generation (if available)scripts/mutation/generate_scoped_configs.py
Pre-Invocation
Orchestrator performs before delegating:
- Extract files — Read
, extract implementation files fromexecution-log.json
. Gate: file list non-empty.completed_steps[].files_modified.implementation - Verify on disk — Check all extracted files exist on disk. Gate: zero missing files.
- Detect language — Scan config files (pyproject.toml, pom.xml, package.json, etc.) to select tool. Gate: language identified.
- Confirm tests pass — Run
(or equivalent). Gate: exit code 0, no failures.pytest -x {test_scope} - Ensure mutation venv — For Python, verify
exists with cosmic-ray installed. Gate:.venv-mutation/
succeeds.cosmic-ray --version
Agent Invocation
@nw-software-crafter
Execute mutation testing for project {feature-id}.
Context to pass inline (agent has no Skill access):
- Project ID
- Implementation file list (from execution-log.json)
- Test scope path (e.g.,
)tests/des/ - Kill rate threshold (default: 80%)
- Language and tool selection
Configuration:
- threshold: 80 (percentage, minimum kill rate)
- approach: feature-scoped (one config per component, scoped test commands)
- config_generator:
(preferred over manual)scripts/mutation/generate_scoped_configs.py
Output file:
docs/feature/{feature-id}/deliver/mutation/mutation-report.md
Examples
Example 1: Python project with config generator
/nw-mutation-test des-hook-enforcement tests/des/
Reads execution-log.json, runs
generate_scoped_configs.py des-hook-enforcement, delegates to software-crafter with per-component configs. Agent runs cosmic-ray, produces mutation-report.md.
Example 2: Python project without config generator
/nw-mutation-test auth-upgrade tests/auth/
Extracts files manually from execution-log.json, creates single cosmic-ray config with
module-path = [file1, file2, ...] and test-command = "pytest -x tests/auth/", delegates to agent.
Example 3: Non-Python project
/nw-mutation-test payment-gateway tests/payment/
Detects
package.json, selects Stryker, delegates with Stryker-specific instructions.
Success Criteria
- Implementation files extracted from execution-log.json
- All implementation files verified on disk
- Mutation testing executed without errors
- Per-file breakdown in mutation-report.md
- Kill rate meets threshold (>= 80% PASS, 70-80% WARN, < 70% FAIL)
- Source files restored to HEAD after mutation run (git checkout -- src/ tests/)
Post-Mutation Safety (mandatory)
After EVERY mutation run (success, failure, or interruption):
- Restore source files — Run
. Gate: working tree clean (no mutations remain).git checkout -- src/ tests/ - Verify no corruption — Confirm test suite still passes after restore. Gate:
exits 0.pytest -x {test_scope}
Mutation tools apply mutations directly to source files. An interrupted run can leave corrupted code (e.g.
is not None -> is None). Agent MUST execute these steps even if the run errors out.
Quality Gate
Kill rate thresholds:
- >= 80% PASS — Proceed to next wave.
- 70-80% WARN — Review surviving mutants, document findings, proceed with caution.
- < 70% FAIL — Add tests targeting surviving mutants before proceeding.
Skip conditions (each requires documented justification in mutation-report.md):
- No tool for language — No mutation framework available for detected language.
- Project opt-out —
has.mutation-config.yaml
with justification.skip: true - Broken test suite — Pre-invocation step 4 fails; fix tests before mutation testing.
Note: Python projects require mutation testing. All skips need documented justification.
Next Wave
Handoff To: Phase 8 - Finalize (orchestrator continues develop.md workflow) Deliverables:
docs/feature/{feature-id}/deliver/mutation/mutation-report.md
Expected Outputs
docs/feature/{feature-id}/deliver/mutation/ mutation-report.md cosmic-ray-*.toml (ephemeral)