Repository avatar
Developer Tools
v1.0.0
active

mutantgate

io.github.luckystore1/mutantgate

Diff-scoped mutation testing for PRs: score only changed lines, list surviving mutants, gate CI.

Documentation

MutantGate

Diff-scoped mutation testing for pull requests and coding agents. Mutation-test only the lines a PR changed, get a score that says whether the tests actually catch bugs, and hand the surviving mutants to the agent that wrote them — in CI, in the terminal, or over MCP from Claude Code, Cursor or Codex.

Coverage only checks if a line ran; MutantGate checks if your tests actually break when the code is mutated. A green suite proves the code executed — not that a test would have failed had the logic been wrong. Everything below is about measuring that difference.

Measured on a real PR (unjs/defu #111): Stryker reports 70.21% for the package, while the lines the PR changed score 52.9%. Six tests written against the survivors MutantGate listed moved that diff to 91.2% (exit 1 → exit 0). Cold run 19 s, warm 10 s. Every number in that document comes from a command that was run.

CI release license: MIT

Start here — landing page · npm · measured benchmark

npm i -D @stryker-mutator/core @stryker-mutator/vitest-runner && npx stryker init   # once per repo
npx mutantgate --base origin/main --threshold 70                                    # score this PR's lines
npm i -D mutantgate                                                                 # or pin it in package.json

Agent skills and template packs (Agensi handles checkout): free skill · Survivor Pack $12 · MCP security pack $9 · bundle $16. The two paid items are template packs; no software licence is included and nothing in them needs one.

### MutantGate — diff mutation score: **33.3%** ❌ below threshold

**1 of 3** injected bugs in the changed lines were caught by the test suite.

| # | Location              | Mutation                    | Status   |
|--:|-----------------------|-----------------------------|----------|
| 1 | `src/pricing.ts:5`    | EqualityOperator → `>=`     | Survived |
| 2 | `src/pricing.ts:6`    | BlockStatement → `{}`       | Survived |

Get it

WhereInstallNotes
npmnpx mutantgate or npm i -D mutantgatemutantgate@1.0.0; Node 20.11+
GitHub Actionuses: luckystore1/mutantgate@v1no local install
Agent skill, free (Agensi)copy the SKILL.md into your agentthe same workflow as skills/mutantgate/SKILL.md
Agent skill pack, $12 (Agensi)MutantGate Survivor Pack: Test-Gen Prompts & PR Gate Kittemplate pack: 16 mutator recipes, survivor-kill playbook, PR-gate workflow and templates. No software licence included
Agent skill pack, $9 (Agensi)MCP Security Audit & PR Gate: Claude Code & Cursoraudits the MCP config a PR can change and gates it
Both packs (Agensi)MutantGate Complete bundle$16 instead of $21 (24% off)
Agent skill, GitHubnpx skills add luckystore1/mutantgateNode 22.20+ — that is the skills CLI's requirement, not MutantGate's

The problem

Coding agents write tests that pass. Passing is not the same as testing.

An agent asked to "add tests for the new fee logic" will happily write three assertions on the happy path and leave the boundary at subtotal > 20 untested. CI is green, coverage goes up, and the bug ships. The reviewer — who now spends more time reading agent PRs than writing code — has no cheap way to see which behaviours are actually asserted.

The usual answer is mutation testing: change the code slightly, see whether the suite notices. It works, but whole-repository mutation testing takes 20–40 minutes on a real TypeScript project, so nobody puts it in a PR gate.

Running Stryker with --incremental and --mutate fixes the runtime but creates a second problem: the number is wrong for review. Stryker reuses earlier results and reports the package score (say 87%, 38 survivors), while the diff may be 33% — or the other way round. A reviewer who sees "87%, fine" on a PR that added two untested branches is worse off than with no number at all.

What MutantGate does

  1. Computes the changed line spans with git diff -U0 against the merge base.
  2. Runs Stryker with --mutate scoped to exactly those spans (src/pricing.ts:5-6), with --incremental for speed.
  3. Re-reads the Stryker JSON report and keeps only the mutants whose whole location falls inside a changed span, using the same comparison Stryker uses for --mutate ranges.
  4. Reports the diff mutation score, the surviving mutants, and (Pro) a PR comment plus a fix prompt for Claude Code / Codex / any coding agent.
PR event
   │
   ├─ git merge-base(base, head) → git diff -U0 → changed spans
   │      src/pricing.ts:5-6, src/cart.ts:41
   │
   ├─ stryker run --mutate "src/pricing.ts:5-6,src/cart.ts:41" --incremental
   │
   ├─ mutation.json → keep mutants inside the spans → 1 killed / 2 survived → 33.3%
   │
   ├─ PR comment: score, survivors, where to look
   └─ agent fix prompt: one survivor per task, with a definition of done

Quickstart (5 minutes)

Published on npm. npm i -D mutantgate adds the CLI to a repository, or run it without installing with npx mutantgate; the MCP server comes from the same package as npx -y mutantgate mcp. The GitHub Action (uses: luckystore1/mutantgate@v1) needs no local install. The CLI requires Node 20.11 or newer.

1. Install Stryker in your repository

MutantGate orchestrates StrykerJS; it does not bundle it. In your TypeScript/JavaScript project:

npm i -D @stryker-mutator/core @stryker-mutator/vitest-runner   # or jest-runner
npx stryker init                                                 # writes stryker.conf.json

Minimal stryker.conf.json:

{
  "packageManager": "npm",
  "reporters": ["json", "clear-text"],
  "jsonReporterFile": "reports/mutation/mutation.json",
  "testRunner": "vitest",
  "mutate": ["src/**/*.ts", "!src/**/*.test.ts"],
  "incremental": true,
  "concurrency": 4
}

mutate is replaced at run time by the diff scope, so it only matters for manual runs.

2. Add the workflow

name: Mutation gate
on: pull_request

permissions:
  contents: read
  pull-requests: write      # for the PR comment (Pro)

jobs:
  mutantgate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0     # MutantGate needs the merge base
      - uses: actions/setup-node@v4
        with:
          node-version: 24
          cache: npm
      - run: npm ci
      - uses: luckystore1/mutantgate@v1
        with:
          threshold: '70'
          mode: block
          license-key: ${{ secrets.MUTANTGATE_LICENSE_KEY }}   # optional; Free works without

That is the whole setup. First run on a PR with three changed lines and three mutants: if all three survive, the step fails with 33.3% and lists them.

3. Or run the CLI locally

npx mutantgate --base origin/main --threshold 70
npx mutantgate --base origin/main --mutate-args      # src/pricing.ts:5-6,src/cart.ts:41
npx mutantgate --base origin/main --format json      # machine readable
npx mutantgate --base origin/main --report reports/mutation/mutation.json --no-run-stryker

4. Or let your coding agent call it (MCP)

claude mcp add mutantgate -- npx -y mutantgate mcp
npx -y mutantgate mcp        # any MCP client, stdio, no runtime dependencies
MCP toolPlanReturns
mutantgate_scopeFreeThe --mutate value for the changed lines (no test run).
mutantgate_scanFreeDiff mutation score, verdict, and every surviving mutant.
mutantgate_fix_promptProOne repair task per survivor, with a definition of done. Without a verified mg1. Ed25519 or Polar license it returns the Free survivor list and explains the plan.

Client configs for Claude Code, Claude Desktop, Cursor and Codex, plus copy-paste CLAUDE.md / AGENTS.md / Cursor-rule snippets: docs/agent-snippets.md. The server is listed in server.json (official MCP registry) and smithery.yaml.

5. Or install it as an agent skill

Agents that support Agent Skills — Claude Code, Codex, Cursor and the other clients listed there — can install the whole workflow with one command:

npx skills add luckystore1/mutantgate

npx skills add requires Node 22.20 or newer (the skills CLI's own minimum); the MutantGate CLI it installs alongside needs only Node 20.11+. If you are on Node 20 or 22.0–22.19, install the skill by copying skills/mutantgate/SKILL.md, or take the free Agensi listing.

That installs the mutantgate skill: when to scan, how to read the diff score, and what to do with each surviving mutant (write the missing test, never raise the threshold to pass). Pair it with the MCP server from step 4 so the agent can call mutantgate_scan, or let the skill drive the CLI.

Inputs

InputDefaultDescription
baseorigin/$GITHUB_BASE_REF, else origin/mainBase ref of the three-dot diff.
headHEADHead ref.
threshold70Minimum diff mutation score (0–100).
modeblockblock fails the step below the threshold; warning only reports.
report-path–Score an existing Stryker JSON report instead of running Stryker.
run-strykertrueSet false with report-path to skip the Stryker run.
stryker-config–Path to stryker.conf.json (passed as --configFile).
stryker-timeout-seconds900Hard timeout for the Stryker process.
incrementaltruePass --incremental.
include–Globs of files that may be mutated (src/**,!src/vendor/**).
exclude–Extra globs to skip; defaults already skip tests, mocks, fixtures, dist/, *.d.ts, generated files.
use-default-excludestrueTurn the default excludes off if you really want to mutate tests.
configauto.mutantgate.yml or .mutantgate.json in the repository.
license-key–Polar license key, or an mg1. signed offline license.
license-organization-id–Polar organization id for the validation call.
polar-url–Override the validation endpoint (sandbox, proxy, mock server).
offline-licensefalseNever call the network; accept only signed offline licenses.
commenttruePost/update the PR comment (Pro).
github-token${{ github.token }}Token used for the comment; needs pull-requests: write.
fix-prompt-outRUNNER_TEMP/mutantgate/mutantgate-fix-prompt.mdWhere the agent fix prompt is written (Pro).
formatconsoleconsole, json or markdown.
working-directory.Repository subdirectory.
fail-on-errorfalseExit 3 when the score cannot be computed (git/Stryker/report problem).
fail-on-no-mutantsfalseExit 1 when the changed lines contain no mutants at all.
cache-dirRUNNER_TEMP/mutantgateLicense cache directory.
verbosefalseDebug output (resolved refs, report path mapping, license source).

Outputs

OutputDescription
scoreDiff mutation score in percent, empty when nothing is in scope.
detected / undetectedKilled+Timeout / Survived+NoCoverage inside the changed lines.
verdictpass, weak, no-mutants, skipped or error.
passed'true' or 'false'.
planfree, solo, team, self-hosted.
scopeThe Stryker --mutate value used (src/a.ts:5-6,...).
report-path, comment-path, fix-prompt-pathFiles written by the run.

Use them for later steps:

      - id: gate
        uses: luckystore1/mutantgate@v1
        with: { threshold: '70', mode: warning }
      - if: steps.gate.outputs.verdict == 'weak'
        run: echo "Diff mutation score is ${{ steps.gate.outputs.score }}% — see the PR comment"

Free vs Pro

FreeSolo ProTeamSelf-hosted
Price$0$12/repo/month or $99/repo/year$49/month (5 repos)$299/month
Diff mutation score (console/JSON)✅✅✅✅
Threshold gate and exit codes✅✅✅✅
Stryker scope for external tools (--mutate-args)✅✅✅✅
mutantgate_scan / mutantgate_scope over MCP✅✅✅✅
PR comment with the survivor table–✅✅✅
Agent fix prompt (mutantgate_fix_prompt, Claude Code / Codex)–✅✅✅
Monorepo profiles, policy floor, forced block mode––✅✅
Air-gapped signed licenses, GitHub Enterprise–––✅
Supportcommunityemailpriorityonboarding call

Free is a real gate: it fails the build, prints the score, and lists survivors in the log. The paid tiers add the two things a team cannot script in an afternoon — the comment a reviewer reads without opening logs, and the prompt that makes the agent fix its own tests.

Where to buy today. The paid software tiers above are not on sale yet (Polar checkout is still being set up), so there is no licence button to press. What is for sale now are the Agensi template packs in Get it — the $12 Survivor Pack and the $9 MCP security pack. They are Markdown, YAML and config; none of them includes or needs a MutantGate licence key, and the free CLI is not limited by buying or not buying them.

Configuration file

.mutantgate.yml (or .mutantgate.json) in the repository root:

version: 1
threshold: 70
mode: block
exclude:
  - src/vendor/**
reportPathPrefix: services/api        # if the Stryker report is rooted in a subdirectory

profiles:
  api:
    paths:
      - services/api/**
    threshold: 80
  web:
    paths: [services/web/**]
    threshold: 60
    mode: warning

policy:                               # Team: enforced over local settings
  minThreshold: 50
  requireBlockMode: true

The profile whose paths match the most changed files is used; profile: forces one. Every key has an environment variable equivalent (MUTANTGATE_THRESHOLD, MUTANTGATE_MODE, MUTANTGATE_INCLUDE, …) and a CLI flag, which wins over both the file (flags > env > config).

Licensing (Polar)

Payments and license keys run through Polar as merchant of record; the GitHub Marketplace listing points at the same entitlement.

  1. Create the product in Polar with three benefits (Solo Pro, Team, Self-hosted).
  2. Create a license-key benefit and note the benefit ids.
  3. Point MutantGate at them (environment, optional — descriptions are also matched):
MUTANTGATE_POLAR_ORGANIZATION_ID=org_xxx
MUTANTGATE_BENEFIT_SOLO=ben_xxx
MUTANTGATE_BENEFIT_TEAM=ben_yyy
MUTANTGATE_BENEFIT_SELF_HOSTED=ben_zzz
MUTANTGATE_LICENSE_KEY=polar_lic_xxx

How validation behaves:

  • POST https://api.polar.sh/v1/customers/license-keys/validate with { "key", "organization_id" } (the documented customer-portal path is tried automatically if that one returns 404; MUTANTGATE_POLAR_URL overrides both).
  • The key is validated, never activated — CI runs do not consume activations.
  • A successful response is cached for 24 h (RUNNER_TEMP/mutantgate), so a 20-job matrix hits Polar once.
  • Polar unreachable: the cached plan is used for up to 7 days; after that, the run degrades to Free with a warning. A license outage never blocks a merge.
  • The key is never written to disk or to the report; the cache stores a SHA-256 hash.

Air-gapped / GitHub Enterprise: buy the self-hosted plan and use a signed offline license instead of a key. mg1.<payload>.<ed25519 signature> is verified locally against the embedded public key:

node tools/mint-license.mjs --plan self-hosted --org acme --days 365 --key ~/.mutantgate/signing-key.pem
# → mg1.<payload>.<signature>   (put it in a secret; never commit it)

MUTANTGATE_LICENSE_PUBLIC_KEY replaces the embedded key when you rotate your signing key.

Sandbox: point --polar-url at a local mock server; the response handling (granted / revoked / 422 / 5xx / timeout) is covered by tests.

Troubleshooting

SymptomCauseFix
MG_E_SHALLOW: Cannot compute the merge base … in a shallow cloneactions/checkout defaults to depth 1with: fetch-depth: 0 — the step fails (exit 2) rather than reporting an empty diff
Base ref "origin/dev" does not existbase branch not fetchedadd a fetch step, or pass base: ${{ github.event.pull_request.base.sha }} — the step fails (exit 2) because no score was computed
MG_E_REPORT_MISSING: … wrote no reportStryker crashed, or the json reporter is offcheck the printed Stryker output; ensure "reporters": ["json"] and jsonReporterFile
Score is empty / "no mutants in scope"the PR only touched tests, docs or typesexpected; use fail-on-no-mutants: true if you want it red
Score much lower than the Stryker logyou are comparing a package score to a diff scorethat is the point — MutantGate reports the diff
None of the changed files appear in the reportmonorepo: report paths are relative to a subdirectoryset reportPathPrefix: services/api
Stryker times outtoo many changed lines, cold incremental cachenarrow include, raise stryker-timeout-seconds, keep incremental: true, warm the cache in a nightly job
Comment not postedtoken lacks pull-requests: write, or not a PR eventadd the permission; on push there is no PR to comment on
running in Free mode with a keyPolar said revoked/expired, or the network was down and the cache expiredcheck the warning line; validate the key in the Polar portal

Exit codes: 0 pass (or warning mode / nothing to score), 1 below threshold in block mode, 2 usage or configuration — including an unknown base ref or a shallow clone without a merge base, because in those cases the gate did not run at all — 3 infrastructure (Stryker crash or timeout, unreadable report, network), which only fails the step when fail-on-error: true; otherwise it stays green with a warning.

Stryker versions

MutantGate detects the installed Stryker major version and uses the matching CLI: Stryker ≤ 9 (--configFile, --jsonReporterFile) and Stryker 10+ (positional config file, jsonReporter.fileName via a generated overlay config that inherits your settings). Tested against 10.1.1; the compatibility path is covered by unit and integration tests. If a global binary rejects a legacy flag, the run retries once with the current interface.

For AI coding agents

Agent skill: npx skills add luckystore1/mutantgate installs skills/mutantgate/SKILL.md — the same rules as the CLAUDE.md / AGENTS.md snippets, delivered as a skill the agent discovers on its own.

Machine-readable summary for LLM tooling: llms.txt (role, install, Free vs Pro, MCP tools, measured numbers, limitations). Registry metadata lives in server.json (io.github.luckystore1/mutantgate) and smithery.yaml.

Honest limitations

  • A high score is evidence, not proof. Mutation testing samples behaviours; equivalent mutants survive forever. Read the survivor list, do not chase 100%.
  • Only changed lines are mutated, so untouched weak tests stay weak. Pair it with a nightly whole-package run if you care.
  • TypeScript/JavaScript only in this version (StrykerJS). Python/Go/Java adapters are the obvious next step, not a shipped feature.
  • Speed is your suite's speed. A diff of 20 lines still runs the tests that cover those lines. Repos with 30-minute E2E suites need unit tests before any mutation tool helps.
  • Not a replacement for CodeRabbit/Greptile/Copilot review. Those read the diff; MutantGate measures whether the tests would notice a bug in it.

Security and privacy

  • Your code never leaves the runner. MutantGate calls Polar only to validate a license key; no source, report, or mutant detail is uploaded.
  • The Action needs contents: read and (for comments) pull-requests: write. Nothing else.
  • Fork PRs: do not pass license-key as a plain input on pull_request_target; use pull_request with read-only tokens, as the example does.
  • The license key is read from a secret, hashed before caching, and never printed — --verbose redacts it.
  • Stryker runs inside your CI with your own permissions; MutantGate pins no remote code and has no runtime dependencies.

Development

npm ci
npm run typecheck
npm test              # builds, then node --test on 143 unit, integration and MCP tests
npm run demo          # throwaway repo: Free run (exit 1) then Pro run (comment + prompt)
bash scripts/action-smoke.sh   # drives dist/src/main.js with INPUT_* and GITHUB_OUTPUT

Layout: src/diff.ts (spans), src/report.ts (Stryker filtering and score), src/license.ts (Polar + cache), src/license-key.ts (offline tokens), src/render.ts (console/JSON/comment/prompt), src/stryker.ts (process control + Stryker version compatibility), src/execute.ts (orchestration), src/main.ts (Action entry), src/mcp.ts (MCP stdio server).

More docs: real-repository benchmark · agent snippets · agent skill · Marketplace copy · launch posts

License

MIT. MutantGate orchestrates Stryker Mutator (Apache-2.0), which you install in your own repository; Stryker is not bundled here. See LICENSE and the third-party notice it contains.

Not affiliated. MutantGate is an independent project. It is not affiliated with, sponsored by, or endorsed by Stryker, Anthropic, or Anysphere. Stryker, Claude Code, Cursor, Codex and GitHub Actions are trademarks of their respective owners and are named only to describe what the tool works with. No logos or brand assets of those projects are used or redistributed here.

NPM
mutantgate
Install Command
npm install mutantgate