agentleFS
rundopsrundops/dops/.claude/skills/mutation-testing/SKILL.md

mutation-testing

Skill3 starsChanged 8 months agoMITView on GitHub

Mutation testing with Gremlins for Go. Use when assessing test quality, finding weak tests, or when the user asks about mutation testing. Triggers on "mutation test", "gremlins", "test quality", "test effectiveness", or after completing a feature to verify test strength.

  • Installs packages

30 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use domain-modeling, code-review and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • GoogleSkill

    domain-modeling

    Build and sharpen a project's domain model. Use when the user wants to pin down domain terminology or a ubiquitous language, record an architectural decision, or when another skill needs to maintain the domain model.

    Also in 3 projects that use this

  • GoogleSkill

    code-review

    Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

    Also in 5 projects that use this

  • MicrosoftSkill

    grill-with-docs

    Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 26 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Default operators (all enabled):

    line 51
  2. Very specific:

    Create .gremlins.yaml in the project root:

    line 71
  3. Very specific:

    Use --diff origin/main in PRs for fast runs.

    line 144
  4. Distinctive:

    Test doesn't verify the computed value precisely.

    line 160
  5. Distinctive:

    When you encounter these, exclude the file or accept the lower efficacy score.

    line 174
  6. Very specific:

    Targeted runs: Always use --coverpkg or --diff instead of full-module runs

    line 189
  7. Distinctive:

    Schedule full runs: Run full-module mutation testing weekly, not per-commit

    line 192

“Common” is measured: kept by at least 6 in 10 of the 26 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Mutation Testing with Gremlins

Gremlins tests your tests. It introduces small bugs (mutants) into your code and checks whether your test suite catches them. Surviving mutants = weak tests.

Install

brew tap go-gremlins/tap && brew install gremlins
# or
go install github.com/go-gremlins/gremlins/cmd/gremlins@latest

Quick Start

# Dry run — see what would be mutated, no testing
gremlins unleash --dry-run

# Run mutation testing on the full module
gremlins unleash

# Run only on specific packages
gremlins unleash --coverpkg ./internal/vars/...

# Run only on code changed since main (fast, use in PRs)
gremlins unleash --diff main

Reading Results

StatusMeaningAction
KILLEDTests caught the mutationGood. No action needed.
LIVEDTests did NOT catch the mutationBad. Write a better test.
NOT COVEREDNo test coverage at mutation siteWrite tests for this code.
TIMED OUTTests hung on the mutantUsually good (mutation broke a loop).
NOT VIABLEMutation caused compile errorIgnore.

Key metrics:

  • Efficacy = KILLED / (KILLED + LIVED) — target 70-80%
  • Mutant coverage = tested mutations / total mutations

What Gremlins Mutates

Default operators (all enabled):

OperatorExample
arithmetic-base+ becomes -, * becomes /
conditionals-boundary> becomes >=, < becomes <=
conditionals-negation== becomes !=, < becomes >=
increment-decrement++ becomes --
invert-negatives-x becomes x

Additional operators (opt-in):

gremlins unleash --invert-logical      # && <-> ||
gremlins unleash --invert-loopctrl     # break <-> continue
gremlins unleash --invert-assignments  # += <-> -=

Configuration

Create .gremlins.yaml in the project root:

unleash:
  diff: ""
  workers: 0                    # 0 = all CPUs
  exclude-files:
    - ".*_generated\\.go$"
    - "internal/executor/demo_data\\.go$"
  threshold:
    efficacy: 70                # exit code 10 if below
    mutant-coverage: 80         # exit code 11 if below

mutants:
  arithmetic-base:
    enabled: true
  conditionals-boundary:
    enabled: true
  conditionals-negation:
    enabled: true
  increment-decrement:
    enabled: true
  invert-negatives:
    enabled: true
  invert-logical:
    enabled: false              # enable when baseline is strong
  invert-loopctrl:
    enabled: false
  invert-assignments:
    enabled: false

Workflow

After Completing a Feature

# 1. Run tests first (must be green)
go test ./...

# 2. Mutation test the packages you changed
gremlins unleash --diff main

# 3. Filter to only survived mutants
gremlins unleash --diff main --output-statuses l

# 4. For each LIVED mutant, write a test that kills it
# 5. Re-run to confirm the mutant is now KILLED

Improving Test Quality on Existing Code

# 1. Pick a package
gremlins unleash --coverpkg ./internal/config/...

# 2. Focus on LIVED mutants in business-critical code
# 3. Ignore LIVED mutants in:
#    - Logging/formatting code
#    - Error message strings
#    - Generated code
#    - Demo/fixture data

In CI (GitHub Actions)

- uses: go-gremlins/gremlins-action@v1
  with:
    version: latest
    args: --diff origin/main --threshold-efficacy 70

Use --diff origin/main in PRs for fast runs. Run full module weekly on a schedule.

Interpreting LIVED Mutants

A LIVED mutant means: "I changed this line and no test noticed."

Common patterns and fixes:

  1. Boundary mutation survived (> became >=)
    • Missing edge case test. Add a test for the exact boundary value.
    // If maxItems > 100 survived becoming >= 100:
    // Add test: {name: "exactly 100", items: 100, wantErr: false}
  2. Arithmetic mutation survived (+ became -)
    • Test doesn't verify the computed value precisely. Add exact value assertions.
  3. Condition negation survived (== became !=)
    • Both branches produce acceptable results. Either the test is too loose or the code has an equivalent mutant (false positive).
  4. Increment survived (++ became --)
    • Loop counter or index not tested at boundaries. Add tests for first/last element.

Equivalent mutants (false positives): Some mutations produce semantically identical code. These show as LIVED but aren't real weaknesses:

  • Changing < to <= when the boundary value never occurs
  • Arithmetic on constants used only for cosmetic purposes
  • Negating conditions that return the same value in both branches

When you encounter these, exclude the file or accept the lower efficacy score.

What Gremlins Does NOT Catch

  • Logic errors in test assertions themselves
  • Missing test scenarios (it only mutates covered code)
  • Concurrency bugs
  • Integration issues between packages
  • Incorrect error messages (doesn't mutate strings)
  • Missing validation for new fields

Mutation testing complements — not replaces — code review, integration tests, and property-based testing.

Performance Tips

  • Targeted runs: Always use --coverpkg or --diff instead of full-module runs
  • Worker control: --workers 4 to limit CPU usage
  • Exclude data files: Exclude demo_data.go, generated files, fixtures
  • Schedule full runs: Run full-module mutation testing weekly, not per-commit
  • Start small: Begin with default operators; enable extras as baseline improves

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.