[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ASRA35D1XKKHXAHFD9MVMN":3,"skill-same:01M7ASRA35D1XKKHXAHFD9MVMN":63},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7ASRA35D1XKKHXAHFD9MVMN","mutation-testing",null,"Finds weak or missing tests by analyzing if code changes would be caught. Use when verifying test effectiveness, strengthening test suites, or validating TDD workflows.","saski\u002Farnesto","saski","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F140356?v=4","01M7ASBDSNXTRYDYB4K1PEA1RV","01M7ASBDTAKBDAAV99S1GE7HK6",6,"Unlicense","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmutation-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: mutation-testing\ndescription: Finds weak or missing tests by analyzing if code changes would be caught. Use when verifying test effectiveness, strengthening test suites, or validating TDD workflows.\n---\n\nSTARTER_CHARACTER = 🧬🔬\n\n# Mutation Testing\n\nMutation testing answers the question: **\"Are my tests actually catching bugs?\"**\n\nCode coverage tells you what code your tests execute. Mutation testing tells you if your tests would **detect changes** to that code. A test suite with 100% coverage can still miss 40% of potential bugs.\n\n---\n\n## Core Concept\n\n**The Mutation Testing Process:**\n\n1. **Generate mutants**: Introduce small bugs (mutations) into production code\n2. **Run tests**: Execute your test suite against each mutant\n3. **Evaluate results**: If tests fail, the mutant is \"killed\" (good). If tests pass, the mutant \"survived\" (bad - your tests missed the bug)\n\n**The Insight**: A surviving mutant represents a bug your tests wouldn't catch.\n\n---\n\n## When to Use\n\nUse mutation testing analysis when:\n\n- Reviewing code changes on a branch\n- Verifying test effectiveness after TDD\n- Identifying weak tests that appear to have coverage\n- Finding missing edge case tests\n- Validating that refactoring didn't weaken test suite\n\n**Integration with TDD:**\n\n```\nTDD Workflow                    Mutation Testing Validation\n┌─────────────────┐             ┌─────────────────────────────┐\n│ RED: Write test │             │                             │\n│ GREEN: Pass it  │──────────►  │ After GREEN: Verify tests   │\n│ REFACTOR        │             │ would kill relevant mutants │\n└─────────────────┘             └─────────────────────────────┘\n```\n\n---\n\n## Systematic Branch Analysis Process\n\nFollow this systematic process when analyzing code on a branch:\n\n### Step 1: Identify Changed Code\n\n```bash\n# For JavaScript\u002FTypeScript\ngit diff main...HEAD --name-only | grep -E '\\.(ts|js|tsx|jsx)$' | grep -v '\\.test\\.'\n\n# For Python\ngit diff main...HEAD --name-only | grep '\\.py$' | grep -v 'test_'\n\n# Get detailed diff for analysis\ngit diff main...HEAD -- src\u002F\n```\n\n### Step 2: Generate Mental Mutants\n\nFor each changed function\u002Fmethod, mentally apply mutation operators (see Language-Specific Operators below).\n\n### Step 3: Verify Test Coverage\n\nFor each potential mutant, ask:\n\n1. **Is there a test that exercises this code path?**\n2. **Would that test FAIL if this mutation were applied?**\n3. **Is the assertion specific enough to catch this change?**\n\n### Step 4: Document Findings\n\nCategorize findings:\n\n| Category | Description | Action Required |\n|----------|-------------|-----------------|\n| Killed | Test would fail if mutant applied | None - tests are effective |\n| Survived | Test would pass with mutant | Add\u002Fstrengthen test |\n| No Coverage | No test exercises this code | Add behavior test |\n| Equivalent | Mutant produces same behavior | None - not a real bug |\n\n---\n\n## Universal Mutation Operators\n\nThese mutation operators apply across most languages:\n\n### Arithmetic Operators\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `a + b` | `a - b` | Addition behavior |\n| `a - b` | `a + b` | Subtraction behavior |\n| `a * b` | `a \u002F b` | Multiplication behavior |\n| `a \u002F b` | `a * b` | Division behavior |\n| `a % b` | `a * b` | Modulo behavior |\n\n**Key Pattern:**\n\n```\n\u002F\u002F ❌ WEAK TEST - Would NOT catch mutant\ncalculate(10, 1)  \u002F\u002F 10 * 1 = 10, 10 \u002F 1 = 10 (SAME!)\n\n\u002F\u002F ✅ STRONG TEST - Would catch mutant\ncalculate(10, 3)  \u002F\u002F 10 * 3 = 30, 10 \u002F 3 = 3.33 (DIFFERENT!)\n```\n\n### Conditional Expressions\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `a \u003C b` | `a \u003C= b` | Boundary value at equality |\n| `a \u003C b` | `a >= b` | Both sides of condition |\n| `a \u003C= b` | `a \u003C b` | Boundary value at equality |\n| `a > b` | `a >= b` | Boundary value at equality |\n| `a >= b` | `a > b` | Boundary value at equality |\n\n**Key Pattern:**\n\n```\n\u002F\u002F ❌ WEAK TEST - Would NOT catch boundary mutant\nisAdult(25)  \u002F\u002F 25 >= 18 = true, 25 > 18 = true (SAME!)\n\n\u002F\u002F ✅ STRONG TEST - Would catch boundary mutant\nisAdult(18)  \u002F\u002F 18 >= 18 = true, 18 > 18 = false (DIFFERENT!)\n```\n\n### Equality Operators\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `a == b` | `a != b` | Both equal and not equal cases |\n| `a != b` | `a == b` | Both equal and not equal cases |\n\n### Logical Operators\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `a AND b` | `a OR b` | Case where one is true, other is false |\n| `a OR b` | `a AND b` | Case where one is true, other is false |\n| `NOT a` | `a` | Negation is necessary |\n\n**Key Pattern:**\n\n```\n\u002F\u002F ❌ WEAK TEST - Would NOT catch mutant\ncanAccess(true, true)  \u002F\u002F true OR true = true AND true (SAME!)\n\n\u002F\u002F ✅ STRONG TEST - Would catch mutant\ncanAccess(true, false)  \u002F\u002F true OR false = true, true AND false = false (DIFFERENT!)\n```\n\n### Boolean Literals\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `true` | `false` | Both true and false outcomes |\n| `false` | `true` | Both true and false outcomes |\n\n### Block Statements\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| Function body | Empty function | Side effects of the function |\n\n**Key Pattern:**\n\n```\n\u002F\u002F ❌ WEAK TEST - Would NOT catch mutant\nprocessOrder(order)  \u002F\u002F No assertions - empty function also doesn't throw!\n\n\u002F\u002F ✅ STRONG TEST - Would catch mutant\nprocessOrder(order)\nverifyOrderWasSaved(order)  \u002F\u002F Verifies side effect\n```\n\n### String Literals\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `\"text\"` | `\"\"` | Non-empty string behavior |\n| `\"\"` | `\"XX\"` | Empty string behavior |\n\n### Collection Literals\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `[1, 2, 3]` | `[]` | Non-empty collection behavior |\n| `{}` | Empty or mutated | Empty collection behavior |\n\n---\n\n## Language-Specific Operators\n\nDifferent languages have specific mutation operators beyond the universal ones:\n\n- **JavaScript\u002FTypeScript**: See [languages\u002Fjavascript.md](languages\u002Fjavascript.md) for optional chaining (`?.`), nullish coalescing (`??`), and JS-specific methods\n- **Python**: See [languages\u002Fpython.md](languages\u002Fpython.md) for identity operators (`is`), membership (`in`), floor division (`\u002F\u002F`), and Python-specific patterns\n\n---\n\n## Mutant States and Metrics\n\n### Mutant States\n\n| State | Meaning | Action |\n|-------|---------|--------|\n| **Killed** | Test failed when mutant applied | Good - tests are effective |\n| **Survived** | Tests passed with mutant active | Bad - add\u002Fstrengthen test |\n| **No Coverage** | No test exercises this code | Add behavior test |\n| **Timeout** | Tests timed out (infinite loop) | Counted as detected |\n| **Equivalent** | Mutant produces same behavior | No action - not a real bug |\n\n### Metrics\n\n- **Mutation Score**: `killed \u002F valid * 100` - The higher, the better\n- **Detected**: `killed + timeout`\n- **Undetected**: `survived + no coverage`\n\n### Target Mutation Score\n\n| Score | Quality |\n|-------|---------|\n| \u003C 60% | Weak test suite - significant gaps |\n| 60-80% | Moderate - many improvements possible |\n| 80-90% | Good - but still gaps to address |\n| > 90% | Strong - but watch for equivalent mutants |\n\n---\n\n## Equivalent Mutants\n\nEquivalent mutants produce the same behavior as the original code. They cannot be killed because there is no observable difference.\n\n### Common Equivalent Mutant Patterns\n\n**Pattern 1: Operations with identity elements**\n\n```\n\u002F\u002F Mutant in conditional where both branches have same effect\nif (whatever) {\n  number += 0  \u002F\u002F Can mutate to -= 0, *= 1, \u002F= 1 - all equivalent!\n} else {\n  number += 0\n}\n```\n\n**Pattern 2: Boundary conditions that don't affect outcome**\n\n```\n\u002F\u002F When max equals min, condition doesn't matter\nmax = max(a, b)\nmin = min(a, b)\nif (a >= b) {  \u002F\u002F Mutating to \u003C= or \u003C has no effect when a == b\n  result = 10 ** (max - min)  \u002F\u002F 10 ** 0 = 1 regardless\n}\n```\n\n**Pattern 3: Dead code paths**\n\n```\n\u002F\u002F If this path is never reached, mutations don't matter\nif (impossibleCondition) {\n  doSomething()  \u002F\u002F Mutating this won't affect behavior\n}\n```\n\n### Handle Equivalent Mutants\n\n1. **Identify**: Analyze if mutation truly changes observable behavior\n2. **Document**: Note why mutant is equivalent\n3. **Accept**: 100% mutation score may not be achievable\n4. **Consider refactoring**: Sometimes equivalent mutants indicate unclear code\n\n---\n\n## Branch Analysis Checklist\n\nWhen analyzing code changes on a branch:\n\n### For Each Function\u002FMethod Changed:\n\n- [ ] **Arithmetic operators**: Would changing +, -, *, \u002F be detected?\n- [ ] **Conditionals**: Are boundary values tested (>=, \u003C=)?\n- [ ] **Boolean logic**: Are all branches of AND, OR tested?\n- [ ] **Return statements**: Would changing return value be detected?\n- [ ] **Method calls**: Would removing or swapping methods be detected?\n- [ ] **String literals**: Would empty strings be detected?\n- [ ] **Collections**: Would empty collections be detected?\n\n### Red Flags (Likely Surviving Mutants):\n\n- [ ] Tests only verify \"no error thrown\"\n- [ ] Tests only check one side of a condition\n- [ ] Tests use identity values (0, 1, empty string)\n- [ ] Tests only verify function was called, not with what\n- [ ] Tests don't verify return values\n- [ ] Boundary values not tested\n\n### Questions to Ask:\n\n1. \"If I changed this operator, would a test fail?\"\n2. \"If I negated this condition, would a test fail?\"\n3. \"If I removed this line, would a test fail?\"\n4. \"If I returned early here, would a test fail?\"\n\n---\n\n## Strengthening Weak Tests\n\n### Pattern: Add Boundary Value Tests\n\n```\n\u002F\u002F Original weak test\ntest('validates age', () => {\n  assert(isAdult(25) === true)\n  assert(isAdult(10) === false)\n})\n\n\u002F\u002F Strengthened with boundary values\ntest('validates age at boundary', () => {\n  assert(isAdult(17) === false)  \u002F\u002F Just below\n  assert(isAdult(18) === true)   \u002F\u002F Exactly at boundary\n  assert(isAdult(19) === true)   \u002F\u002F Just above\n})\n```\n\n### Pattern: Test Both Branches of Conditions\n\n```\n\u002F\u002F Original weak test - only tests one branch\ntest('returns access result', () => {\n  assert(canAccess(true, true) === true)\n})\n\n\u002F\u002F Strengthened - tests all meaningful combinations\ntest('grants access when admin', () => {\n  assert(canAccess(true, false) === true)\n})\n\ntest('grants access when owner', () => {\n  assert(canAccess(false, true) === true)\n})\n\ntest('denies access when neither', () => {\n  assert(canAccess(false, false) === false)\n})\n```\n\n### Pattern: Avoid Identity Values\n\n```\n\u002F\u002F Weak - uses identity values\ntest('calculates', () => {\n  assert(multiply(10, 1) === 10)  \u002F\u002F x * 1 = x \u002F 1\n  assert(add(5, 0) === 5)         \u002F\u002F x + 0 = x - 0\n})\n\n\u002F\u002F Strong - uses values that reveal operator differences\ntest('calculates', () => {\n  assert(multiply(10, 3) === 30)  \u002F\u002F 10 * 3 != 10 \u002F 3\n  assert(add(5, 3) === 8)         \u002F\u002F 5 + 3 != 5 - 3\n})\n```\n\n### Pattern: Verify Side Effects\n\n```\n\u002F\u002F Weak - no verification of side effects\ntest('processes order', () => {\n  processOrder(order)\n  \u002F\u002F No assertions!\n})\n\n\u002F\u002F Strong - verifies observable outcomes\ntest('processes order', () => {\n  processOrder(order)\n  verifyOrderSaved(order)\n  verifyEmailSent(order.customerEmail)\n})\n```\n\n---\n\n## Tool Setup\n\nMutation testing tools automate the mutation generation and test execution:\n\n- **Stryker (JavaScript\u002FTypeScript)**: See [tools\u002Fstryker.md](tools\u002Fstryker.md)\n- **mutmut (Python)**: See [tools\u002Fmutmut.md](tools\u002Fmutmut.md)\n\n---\n\n## Summary: Mutation Testing Mindset\n\n**The key question for every line of code:**\n\n> \"If I introduced a bug here, would my tests catch it?\"\n\n**For each test, verify it would catch:**\n- Arithmetic operator changes\n- Boundary condition shifts\n- Boolean logic inversions\n- Removed statements\n- Changed return values\n\n**Remember:**\n- Coverage measures execution, mutation testing measures detection\n- A test that doesn't make assertions can't kill mutants\n- Boundary values are critical for conditional mutations\n- Avoid identity values that make operators interchangeable\n\n---\n\n## Quick Reference\n\n### Operators Most Likely to Have Surviving Mutants\n\n1. `>=` vs `>` (boundary not tested)\n2. `AND` vs `OR` (only tested when both true\u002Ffalse)\n3. `+` vs `-` (only tested with 0)\n4. `*` vs `\u002F` (only tested with 1)\n\n### Test Values That Kill Mutants\n\n| Avoid | Use Instead |\n|-------|-------------|\n| 0 (for +\u002F-) | Non-zero values |\n| 1 (for *\u002F) | Values > 1 |\n| Empty collections | Collections with multiple items |\n| Identical values for comparisons | Distinct values |\n| All true\u002Ffalse for logical ops | Mixed true\u002Ffalse |\n","STARTER_CHARACTER = 🧬🔬\n\n# Mutation Testing\n\nMutation testing answers the question: **\"Are my tests actually catching bugs?\"**\n\nCode coverage tells you what code your tests execute. Mutation testing tells you if your tests would **detect changes** to that code. A test suite with 100% coverage can still miss 40% of potential bugs.\n\n---\n\n## Core Concept\n\n**The Mutation Testing Process:**\n\n1. **Generate mutants**: Introduce small bugs (mutations) into production code\n2. **Run tests**: Execute your test suite against each mutant\n3. **Evaluate results**: If tests fail, the mutant is \"killed\" (good). If tests pass, the mutant \"survived\" (bad - your tests missed the bug)\n\n**The Insight**: A surviving mutant represents a bug your tests wouldn't catch.\n\n---\n\n## When to Use\n\nUse mutation testing analysis when:\n\n- Reviewing code changes on a branch\n- Verifying test effectiveness after TDD\n- Identifying weak tests that appear to have coverage\n- Finding missing edge case tests\n- Validating that refactoring didn't weaken test suite\n\n**Integration with TDD:**\n\n```\nTDD Workflow                    Mutation Testing Validation\n┌─────────────────┐             ┌─────────────────────────────┐\n│ RED: Write test │             │                             │\n│ GREEN: Pass it  │──────────►  │ After GREEN: Verify tests   │\n│ REFACTOR        │             │ would kill relevant mutants │\n└─────────────────┘             └─────────────────────────────┘\n```\n\n---\n\n## Systematic Branch Analysis Process\n\nFollow this systematic process when analyzing code on a branch:\n\n### Step 1: Identify Changed Code\n\n```bash\n# For JavaScript\u002FTypeScript\ngit diff main...HEAD --name-only | grep -E '\\.(ts|js|tsx|jsx)$' | grep -v '\\.test\\.'\n\n# For Python\ngit diff main...HEAD --name-only | grep '\\.py$' | grep -v 'test_'\n\n# Get detailed diff for analysis\ngit diff main...HEAD -- src\u002F\n```\n\n### Step 2: Generate Mental Mutants\n\nFor each changed function\u002Fmethod, mentally apply mutation operators (see Language-Specific Operators below).\n\n### Step 3: Verify Test Coverage\n\nFor each potential mutant, ask:\n\n1. **Is there a test that exercises this code path?**\n2. **Would that test FAIL if this mutation were applied?**\n3. **Is the assertion specific enough to catch this change?**\n\n### Step 4: Document Findings\n\nCategorize findings:\n\n| Category | Description | Action Required |\n|----------|-------------|-----------------|\n| Killed | Test would fail if mutant applied | None - tests are effective |\n| Survived | Test would pass with mutant | Add\u002Fstrengthen test |\n| No Coverage | No test exercises this code | Add behavior test |\n| Equivalent | Mutant produces same behavior | None - not a real bug |\n\n---\n\n## Universal Mutation Operators\n\nThese mutation operators apply across most languages:\n\n### Arithmetic Operators\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `a + b` | `a - b` | Addition behavior |\n| `a - b` | `a + b` | Subtraction behavior |\n| `a * b` | `a \u002F b` | Multiplication behavior |\n| `a \u002F b` | `a * b` | Division behavior |\n| `a % b` | `a * b` | Modulo behavior |\n\n**Key Pattern:**\n\n```\n\u002F\u002F ❌ WEAK TEST - Would NOT catch mutant\ncalculate(10, 1)  \u002F\u002F 10 * 1 = 10, 10 \u002F 1 = 10 (SAME!)\n\n\u002F\u002F ✅ STRONG TEST - Would catch mutant\ncalculate(10, 3)  \u002F\u002F 10 * 3 = 30, 10 \u002F 3 = 3.33 (DIFFERENT!)\n```\n\n### Conditional Expressions\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `a \u003C b` | `a \u003C= b` | Boundary value at equality |\n| `a \u003C b` | `a >= b` | Both sides of condition |\n| `a \u003C= b` | `a \u003C b` | Boundary value at equality |\n| `a > b` | `a >= b` | Boundary value at equality |\n| `a >= b` | `a > b` | Boundary value at equality |\n\n**Key Pattern:**\n\n```\n\u002F\u002F ❌ WEAK TEST - Would NOT catch boundary mutant\nisAdult(25)  \u002F\u002F 25 >= 18 = true, 25 > 18 = true (SAME!)\n\n\u002F\u002F ✅ STRONG TEST - Would catch boundary mutant\nisAdult(18)  \u002F\u002F 18 >= 18 = true, 18 > 18 = false (DIFFERENT!)\n```\n\n### Equality Operators\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `a == b` | `a != b` | Both equal and not equal cases |\n| `a != b` | `a == b` | Both equal and not equal cases |\n\n### Logical Operators\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `a AND b` | `a OR b` | Case where one is true, other is false |\n| `a OR b` | `a AND b` | Case where one is true, other is false |\n| `NOT a` | `a` | Negation is necessary |\n\n**Key Pattern:**\n\n```\n\u002F\u002F ❌ WEAK TEST - Would NOT catch mutant\ncanAccess(true, true)  \u002F\u002F true OR true = true AND true (SAME!)\n\n\u002F\u002F ✅ STRONG TEST - Would catch mutant\ncanAccess(true, false)  \u002F\u002F true OR false = true, true AND false = false (DIFFERENT!)\n```\n\n### Boolean Literals\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `true` | `false` | Both true and false outcomes |\n| `false` | `true` | Both true and false outcomes |\n\n### Block Statements\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| Function body | Empty function | Side effects of the function |\n\n**Key Pattern:**\n\n```\n\u002F\u002F ❌ WEAK TEST - Would NOT catch mutant\nprocessOrder(order)  \u002F\u002F No assertions - empty function also doesn't throw!\n\n\u002F\u002F ✅ STRONG TEST - Would catch mutant\nprocessOrder(order)\nverifyOrderWasSaved(order)  \u002F\u002F Verifies side effect\n```\n\n### String Literals\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `\"text\"` | `\"\"` | Non-empty string behavior |\n| `\"\"` | `\"XX\"` | Empty string behavior |\n\n### Collection Literals\n\n| Original | Mutated | Test Should Verify |\n|----------|---------|-------------------|\n| `[1, 2, 3]` | `[]` | Non-empty collection behavior |\n| `{}` | Empty or mutated | Empty collection behavior |\n\n---\n\n## Language-Specific Operators\n\nDifferent languages have specific mutation operators beyond the universal ones:\n\n- **JavaScript\u002FTypeScript**: See [languages\u002Fjavascript.md](languages\u002Fjavascript.md) for optional chaining (`?.`), nullish coalescing (`??`), and JS-specific methods\n- **Python**: See [languages\u002Fpython.md](languages\u002Fpython.md) for identity operators (`is`), membership (`in`), floor division (`\u002F\u002F`), and Python-specific patterns\n\n---\n\n## Mutant States and Metrics\n\n### Mutant States\n\n| State | Meaning | Action |\n|-------|---------|--------|\n| **Killed** | Test failed when mutant applied | Good - tests are effective |\n| **Survived** | Tests passed with mutant active | Bad - add\u002Fstrengthen test |\n| **No Coverage** | No test exercises this code | Add behavior test |\n| **Timeout** | Tests timed out (infinite loop) | Counted as detected |\n| **Equivalent** | Mutant produces same behavior | No action - not a real bug |\n\n### Metrics\n\n- **Mutation Score**: `killed \u002F valid * 100` - The higher, the better\n- **Detected**: `killed + timeout`\n- **Undetected**: `survived + no coverage`\n\n### Target Mutation Score\n\n| Score | Quality |\n|-------|---------|\n| \u003C 60% | Weak test suite - significant gaps |\n| 60-80% | Moderate - many improvements possible |\n| 80-90% | Good - but still gaps to address |\n| > 90% | Strong - but watch for equivalent mutants |\n\n---\n\n## Equivalent Mutants\n\nEquivalent mutants produce the same behavior as the original code. They cannot be killed because there is no observable difference.\n\n### Common Equivalent Mutant Patterns\n\n**Pattern 1: Operations with identity elements**\n\n```\n\u002F\u002F Mutant in conditional where both branches have same effect\nif (whatever) {\n  number += 0  \u002F\u002F Can mutate to -= 0, *= 1, \u002F= 1 - all equivalent!\n} else {\n  number += 0\n}\n```\n\n**Pattern 2: Boundary conditions that don't affect outcome**\n\n```\n\u002F\u002F When max equals min, condition doesn't matter\nmax = max(a, b)\nmin = min(a, b)\nif (a >= b) {  \u002F\u002F Mutating to \u003C= or \u003C has no effect when a == b\n  result = 10 ** (max - min)  \u002F\u002F 10 ** 0 = 1 regardless\n}\n```\n\n**Pattern 3: Dead code paths**\n\n```\n\u002F\u002F If this path is never reached, mutations don't matter\nif (impossibleCondition) {\n  doSomething()  \u002F\u002F Mutating this won't affect behavior\n}\n```\n\n### Handle Equivalent Mutants\n\n1. **Identify**: Analyze if mutation truly changes observable behavior\n2. **Document**: Note why mutant is equivalent\n3. **Accept**: 100% mutation score may not be achievable\n4. **Consider refactoring**: Sometimes equivalent mutants indicate unclear code\n\n---\n\n## Branch Analysis Checklist\n\nWhen analyzing code changes on a branch:\n\n### For Each Function\u002FMethod Changed:\n\n- [ ] **Arithmetic operators**: Would changing +, -, *, \u002F be detected?\n- [ ] **Conditionals**: Are boundary values tested (>=, \u003C=)?\n- [ ] **Boolean logic**: Are all branches of AND, OR tested?\n- [ ] **Return statements**: Would changing return value be detected?\n- [ ] **Method calls**: Would removing or swapping methods be detected?\n- [ ] **String literals**: Would empty strings be detected?\n- [ ] **Collections**: Would empty collections be detected?\n\n### Red Flags (Likely Surviving Mutants):\n\n- [ ] Tests only verify \"no error thrown\"\n- [ ] Tests only check one side of a condition\n- [ ] Tests use identity values (0, 1, empty string)\n- [ ] Tests only verify function was called, not with what\n- [ ] Tests don't verify return values\n- [ ] Boundary values not tested\n\n### Questions to Ask:\n\n1. \"If I changed this operator, would a test fail?\"\n2. \"If I negated this condition, would a test fail?\"\n3. \"If I removed this line, would a test fail?\"\n4. \"If I returned early here, would a test fail?\"\n\n---\n\n## Strengthening Weak Tests\n\n### Pattern: Add Boundary Value Tests\n\n```\n\u002F\u002F Original weak test\ntest('validates age', () => {\n  assert(isAdult(25) === true)\n  assert(isAdult(10) === false)\n})\n\n\u002F\u002F Strengthened with boundary values\ntest('validates age at boundary', () => {\n  assert(isAdult(17) === false)  \u002F\u002F Just below\n  assert(isAdult(18) === true)   \u002F\u002F Exactly at boundary\n  assert(isAdult(19) === true)   \u002F\u002F Just above\n})\n```\n\n### Pattern: Test Both Branches of Conditions\n\n```\n\u002F\u002F Original weak test - only tests one branch\ntest('returns access result', () => {\n  assert(canAccess(true, true) === true)\n})\n\n\u002F\u002F Strengthened - tests all meaningful combinations\ntest('grants access when admin', () => {\n  assert(canAccess(true, false) === true)\n})\n\ntest('grants access when owner', () => {\n  assert(canAccess(false, true) === true)\n})\n\ntest('denies access when neither', () => {\n  assert(canAccess(false, false) === false)\n})\n```\n\n### Pattern: Avoid Identity Values\n\n```\n\u002F\u002F Weak - uses identity values\ntest('calculates', () => {\n  assert(multiply(10, 1) === 10)  \u002F\u002F x * 1 = x \u002F 1\n  assert(add(5, 0) === 5)         \u002F\u002F x + 0 = x - 0\n})\n\n\u002F\u002F Strong - uses values that reveal operator differences\ntest('calculates', () => {\n  assert(multiply(10, 3) === 30)  \u002F\u002F 10 * 3 != 10 \u002F 3\n  assert(add(5, 3) === 8)         \u002F\u002F 5 + 3 != 5 - 3\n})\n```\n\n### Pattern: Verify Side Effects\n\n```\n\u002F\u002F Weak - no verification of side effects\ntest('processes order', () => {\n  processOrder(order)\n  \u002F\u002F No assertions!\n})\n\n\u002F\u002F Strong - verifies observable outcomes\ntest('processes order', () => {\n  processOrder(order)\n  verifyOrderSaved(order)\n  verifyEmailSent(order.customerEmail)\n})\n```\n\n---\n\n## Tool Setup\n\nMutation testing tools automate the mutation generation and test execution:\n\n- **Stryker (JavaScript\u002FTypeScript)**: See [tools\u002Fstryker.md](tools\u002Fstryker.md)\n- **mutmut (Python)**: See [tools\u002Fmutmut.md](tools\u002Fmutmut.md)\n\n---\n\n## Summary: Mutation Testing Mindset\n\n**The key question for every line of code:**\n\n> \"If I introduced a bug here, would my tests catch it?\"\n\n**For each test, verify it would catch:**\n- Arithmetic operator changes\n- Boundary condition shifts\n- Boolean logic inversions\n- Removed statements\n- Changed return values\n\n**Remember:**\n- Coverage measures execution, mutation testing measures detection\n- A test that doesn't make assertions can't kill mutants\n- Boundary values are critical for conditional mutations\n- Avoid identity values that make operators interchangeable\n\n---\n\n## Quick Reference\n\n### Operators Most Likely to Have Surviving Mutants\n\n1. `>=` vs `>` (boundary not tested)\n2. `AND` vs `OR` (only tested when both true\u002Ffalse)\n3. `+` vs `-` (only tested with 0)\n4. `*` vs `\u002F` (only tested with 1)\n\n### Test Values That Kill Mutants\n\n| Avoid | Use Instead |\n|-------|-------------|\n| 0 (for +\u002F-) | Non-zero values |\n| 1 (for *\u002F) | Values > 1 |\n| Empty collections | Collections with multiple items |\n| Identical values for comparisons | Distinct values |\n| All true\u002Ffalse for logical ops | Mixed true\u002Ffalse |\n",{"name":5,"description":7},"main","3c24fc2c035029b08c7326774bee3fef8fb95566",".agents\u002Fskills\u002Fmutation-testing",0,"https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto","https:\u002F\u002Fgithub.com\u002Fsaski","http:\u002F\u002Fsaski.com","2026-11-12 20:09:16",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add saski\u002Farnesto --skill mutation-testing",{"tool":37,"command":38},"bunx","bunx skills add saski\u002Farnesto --skill mutation-testing",{"tool":40,"command":41},"pnpm","pnpm dlx skills add saski\u002Farnesto --skill mutation-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmutation-testing\u002FSKILL.md",true,[45,51,55,59],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"languages\u002Fjavascript.md","REFERENCE","参考文档",8321,"https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmutation-testing\u002Flanguages\u002Fjavascript.md",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"languages\u002Fpython.md",10737,"https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmutation-testing\u002Flanguages\u002Fpython.md",{"path":56,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":57,"sourceHtmlUrl":58},"tools\u002Fmutmut.md",7680,"https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmutation-testing\u002Ftools\u002Fmutmut.md",{"path":60,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":61,"sourceHtmlUrl":62},"tools\u002Fstryker.md",6247,"https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmutation-testing\u002Ftools\u002Fstryker.md",[64,71,78,85,92,99],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":18},"01M7AT7F5FSHNAMFMF01N0QA1X","visualize","Use \u002Fvisualize for creating compact charts, diagrams, or other visuals inline as part of the conversation itself. It chooses among Markdown tables, Mermaid, inline HTML, and other supported in-transcript forms. Use Canvas for durable artifacts outside the transcript that users may revisit, refine, or share.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fvisualize\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":18},"01M7AT79MHSAR3JDDMP7DGERM9","update-cursor-settings","Modify Cursor\u002FVSCode user settings in settings.json. Use when you want to change editor settings, preferences, configuration, themes, font size, tab size, format on save, auto save, keybindings, or any settings.json values.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fupdate-cursor-settings\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M7AT73WF3Y22E0FKYAMCCJES","update-cli-config","View and modify Cursor CLI configuration settings in ~\u002F.cursor\u002Fcli-config.json. Use when the user wants to change CLI settings, configure permissions, switch approval mode, enable vim mode, toggle display options, configure sandbox, or manage any CLI preferences.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fupdate-cli-config\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M7AT6F3FBP85AJJ5BJNR8B5W","statusline","Configure a custom status line in the CLI. Use when the user mentions status line, statusline, statusLine, CLI status bar, prompt footer customization, or wants to add session context above the prompt.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fstatusline\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":18},"01M7AT6D24QFS5XRAFN8S5XJ7W","split-to-prs","Split current work into small reviewable PRs. Use when the user asks to split a chat, set of changes, branch, or PR.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fsplit-to-prs\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":18},"01M7AT69FYFN84XZKW452JV5DF","shell","Runs the rest of a \u002Fshell request as a literal shell command. Use only when the user explicitly invokes \u002Fshell and wants the following text executed directly in the terminal.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fshell\u002FSKILL.md",[],[]]