agentleFS
ClarituneClaritune/mutantx/.cursor/skills/mx-generate/SKILL.md

mx-generate

Skill2 starsChanged 4 months agoMITView on GitHub

MutantX Phase 2 — Generate realistic code mutants as unified diff patches.

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read .mutants/detect.json for project configuration (language, test command, source files).

    line 27
  2. Very specific:

    Look for .mutants/manifest.json in the project root.

    line 31
  3. Very specific:

    If .mutants/manifest.json does not exist or regen is "true", proceed with full generation.

    line 33
  4. Very specific:

    If the manifest exists AND regen is not "true", do a per-file staleness check:

    line 35
  5. Very specific:

    Read the manifest. It contains a file_hashes map of { "path": "<sha256>" } for every source file that was mutated.

    line 37
  6. Distinctive:

    Configuration constants: only used at startup.

    line 87
  7. Distinctive:

    Dead code: never reached by any execution path.

    line 88
  8. Distinctive:

    Before finalizing a mutant, verify:

    line 92
  9. Distinctive:

    Create or update the following directory structure:

    line 99
  10. Very specific:

    Verify each patch applies cleanly: git apply --check .mutants/patches/NNN.patch.

    line 130
  11. Distinctive:

    After saving all patches and the manifest, report to the user how many mutants were generated and in which files.

    line 165
  12. Very specific:

    After creating the .mutants/ directory, check if .mutants/ is in .gitignore.

    line 169

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

MutantX — Phase 2: Mutant Generation

You are the mutant generation phase of a mutation testing engine. Your job is to read source files and generate realistic code mutations as unified diff patches.

Key principle: You are NOT an AST-based tool applying blind syntactic transformations. You understand the code semantically. Generate mutations that represent realistic bugs a developer might actually introduce — off-by-one errors, wrong operator choices, forgotten edge cases, swapped arguments, missing null checks. Avoid trivial or equivalent mutations.


Input

Read .mutants/detect.json for project configuration (language, test command, source files). If the file doesn't exist and files is not provided, tell the user to run /mx-detect first.

Check for Cached Mutants

Look for .mutants/manifest.json in the project root.

If .mutants/manifest.json does not exist or regen is "true", proceed with full generation.

If the manifest exists AND regen is not "true", do a per-file staleness check:

  1. Read the manifest. It contains a file_hashes map of { "path": "<sha256>" } for every source file that was mutated.
  2. For each source file in scope, compute its current content hash: sha256sum <file> | cut -d' ' -f1.
  3. Compare against the stored hash:
    • Hash matches → the file hasn't changed. Keep its existing mutants and skip regeneration for this file.
    • Hash differs → the file has changed. Delete its old patches, remove its mutants from the manifest, and regenerate mutants for this file.
    • File is new (not in file_hashes) → generate mutants for it.
    • File was deleted (in file_hashes but no longer exists) → remove its mutants and patches.
  4. Also run git apply --check on each kept patch to verify it still applies cleanly. If a patch no longer applies, discard that mutant and regenerate.

Report the cache status to the user:

Cached: 8 mutants for 3 unchanged files
Regenerating: 2 files changed (src/billing.ts, src/auth.ts)
New: 1 file added (src/payments.ts)
Removed: 1 file deleted (src/legacy.ts)

Generating Mutants

For each source file, read the full file and generate up to count (default 5) mutants. Each mutant must:

  • Change exactly ONE thing (single fault).
  • Be syntactically valid (the code must still compile/parse).
  • Be semantically different from the original (NOT an equivalent mutant).
  • Represent a realistic bug.

Mutation Categories

Apply a MIX of these categories across the file. Don't generate all mutants from the same category.

CategoryDescriptionExample
Arithmetic OperatorChange + to -, * to /, etc.total = a + b → total = a - b
Relational BoundaryOff-by-one in comparisonsi < len → i <= len or i < len - 1
Logical OperatorSwap &&/||, flip boolean logica && b → a || b
Negated ConditionalInvert a conditionif (x > 0) → if (x <= 0)
Return ValueChange what a function returnsreturn result → return null / return [] / return 0
Removed CallRemove a function call (especially side effects)list.sort() → (removed)
Constant MutationChange numeric/string constantstimeout = 30 → timeout = 0
Argument SwapSwap arguments of similar typerange(start, end) → range(end, start)
Exception/Error HandlingRemove or weaken error handlingRemove a catch block body, or change the exception type
Collection OperationChange collection method.filter(...) → .map(...) or .find(...)
Early ReturnAdd or remove an early returnInsert return before main logic, or remove a guard clause
Null/Undefined InjectionReturn or assign null/nil/None/undefinedgetUser() → null

What NOT to Mutate

  • Type declarations, interfaces, or type annotations — compile-time only.
  • Import/export statements — cause parse/compile errors, not behavioral bugs.
  • Comments or documentation.
  • Logging or debug statements — unless they affect control flow.
  • Configuration constants only used at startup.
  • Dead code never reached by any execution path.

Quality Checks

Before finalizing a mutant, verify:

  1. Not equivalent: Does this mutation actually change observable behavior?
  2. Not trivially caught: Will this cause a compile/type error rather than a behavioral change?
  3. Testable: Is there a plausible test that COULD catch this? If the mutated code is never exercised by any test, note this but still include it (it reveals a coverage gap).

Saving Mutants

Create or update the following directory structure:

.mutants/
├── manifest.json
└── patches/
    ├── 001.patch
    ├── 002.patch
    └── ...

Patch Files

Each patch file is a unified diff that can be applied with git apply:

--- a/src/utils.ts
+++ b/src/utils.ts
@@ -40,7 +40,7 @@
 function calculateTotal(items: Item[]): number {
   let total = 0;
   for (const item of items) {
-    total += item.price * item.quantity;
+    total += item.price + item.quantity;
   }
   return total;
 }

Produce the unified diff directly. Use correct line numbers and 3 lines of context above and below the change.

Verify each patch applies cleanly: git apply --check .mutants/patches/NNN.patch. If it doesn't apply cleanly, fix the patch.

Manifest File

Write .mutants/manifest.json:

{
  "version": 1,
  "generated_at": "<ISO 8601 timestamp>",
  "config": {
    "language": "<detected language>",
    "test_command": "<test command>",
    "source_patterns": ["<glob patterns used>"],
    "count_per_file": 5
  },
  "file_hashes": {
    "src/utils.ts": "<sha256 of file content at generation time>",
    "src/billing.ts": "<sha256>"
  },
  "mutants": [
    {
      "id": "001",
      "file": "src/utils.ts",
      "line": 42,
      "category": "arithmetic_operator",
      "description": "Changed * to + in price calculation within calculateTotal",
      "patch_file": "patches/001.patch",
      "status": "pending"
    }
  ],
  "summary": null
}

After saving all patches and the manifest, report to the user how many mutants were generated and in which files.

.gitignore

After creating the .mutants/ directory, check if .mutants/ is in .gitignore. If not, ask the user whether they want to add it.

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.