Logo Mutation Testing

Mutation Testing

Cộng đồng
hugobowne
mutation-testing

Perform mutation testing on the codebase. Introduces deliberate bugs one at a time, checks whether the test suite catches each one, and reports on test suite gaps. Optionally implements missing tests.

Tổng quan

Nhà phát hànhhugobowne
Kho mãshow-us-your-agent-skills
Tên kỹ năngmutation-testing
Sao
70
Bản fork
10
Tệp đi kèm
1
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 1 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được hugobowne công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Mutation Testing trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/hugobowne/show-us-your-agent-skills/tree/main/skills/mutation-testing
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/hugobowne/show-us-your-agent-skills.git /tmp/show-us-your-agent-skills
mkdir -p .claude/skills
cp -r /tmp/show-us-your-agent-skills/skills/mutation-testing .claude/skills/mutation-testing
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Mutation Testing trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Mutation Testing ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Mutation Testing không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Project: honnibal/claude-skills. "Claude skills I'm experimenting with. Please review carefully before use."

License: MIT License. Full license text is in LICENSE alongside this file.

Snapshot: Frozen copy of mutation-testing.md.txt as of 2026-05-22. The maintained version lives upstream and may have evolved since this snapshot.

Mutation Testing

You are now in mutation testing mode. Your job is to assess the strength of the project's test suite by introducing deliberate bugs (mutations) into the source code, one at a time, and checking whether any test fails. A mutation that the tests don't catch reveals a gap in coverage.

Scope

$ARGUMENTS

  • If the user names specific files or directories, restrict mutations to those.
  • If no argument is given, look at the project's source layout and use AskUserQuestion to agree on a starting scope. Don't try to mutate everything at once — pick a module or package and work through it.
  • Test files themselves are out of scope for mutation. Only mutate production code.
  • Prioritise code that has meaningful logic (branching, arithmetic, state changes) over boilerplate, config, or trivial accessors.

Pre-flight

Before mutating anything:

  1. Clean working tree. Run git status on the files in scope. If there are uncommitted changes to any file you plan to mutate, stop and ask the user to commit or stash first. You need a clean baseline so every mutation can be reverted cleanly with git checkout -- <file>.
  2. Find the test runner. Look for pytest.ini, pyproject.toml [tool.pytest], setup.cfg [tool:pytest], tox.ini, a Makefile test target, or a tests/ directory. Ask the user if you can't determine how to run tests. Confirm that the test suite passes on the unmodified code before starting — if it doesn't, stop and tell the user.
  3. Map the code. Read the files in scope. Build a mental model of each module's structure and data flow so you can choose mutations that are meaningful rather than trivially dead.

Workflow

Work through the files in scope one at a time. For each file:

  1. Choose mutations. Read the file and identify 3–8 candidate mutations using the catalogue below. Prefer mutations that test interesting behaviour — a bug a real developer might introduce — over mechanical operator swaps on dead code. For each candidate, write a one-line description of what the mutation does and what behaviour it should break.

  2. Apply, test, revert. For each mutation: a. Apply the mutation using Edit. Change as little as possible — usually a single line. b. Run the test suite (or the relevant subset if the suite is large). Use a timeout — if the tests hang, that still counts as "caught" (the mutation broke something). c. Record the result:

    • Killed — a test failed. Note which test, and briefly assess how helpful the failure message is. Would a developer reading this failure immediately understand what went wrong, or would they have to dig?
    • Survived — no test failed. This is a gap. Note what behaviour is untested. d. Revert the mutation: git checkout -- <file>. Confirm the file is back to its original state before moving on.
  3. Never leave a mutation in place. After each test run, revert immediately. If something goes wrong and you're unsure of the file state, run git diff <file> to check, and git checkout -- <file> to restore.

Use TaskCreate to track progress across files when there are more than a handful.

Mutation Catalogue

Choose mutations from these categories, ordered roughly from most to least likely to reveal meaningful test gaps.

1. Delete or skip a side effect

Remove or comment out a line that modifies state — an assignment, a method call that updates an object, an append to a list, a cache write, a database call. This tests whether the suite verifies that the side effect actually happened.

python
# Original
self.count += 1
results.append(item)

# Mutation: delete the line entirely

2. Negate or invert a condition

Flip a boolean condition: if x → if not x, x > 0 → x <= 0, x and y → x or y, x is None → x is not None.

python
# Original
if user.is_active and user.has_permission:

# Mutation
if user.is_active or user.has_permission:

3. Change a boundary or comparison

Off-by-one and boundary errors: < → <=, >= → >, == 0 → == 1, range(n) → range(n - 1).

python
# Original
if retry_count < max_retries:

# Mutation
if retry_count <= max_retries:

4. Swap or hardcode a return value

Replace a computed return value with a constant, or swap two return paths in a conditional. This tests whether callers actually use and verify the return value.

python
# Original
return calculated_score

# Mutation
return 0

5. Delete an early return or guard clause

Remove a guard clause (if bad_input: return/raise) to see whether the suite has a test for the guarded condition.

python
# Original
def process(items):
    if not items:
        return []
    ...

# Mutation — delete the guard
def process(items):
    ...

6. Change an operator

Swap arithmetic or string operators: + → -, * → /, // → /, + → `` (concatenation removed). Use sparingly — only when the operation has a testable effect on output.

7. Modify a default argument or constant

Change a default parameter value, a class constant, or a module-level constant. This tests whether any test exercises the default path.

python
# Original
def connect(host, port=5432):

# Mutation
def connect(host, port=5433):

8. Swap the order of arguments or operands

Reverse argument order in an internal call, or swap operands around a non-commutative operator. This tests whether the suite is sensitive to argument semantics rather than just arity.

python
# Original
result = divide(numerator, denominator)

# Mutation
result = divide(denominator, numerator)

Assessing test failures

When a mutation is killed, briefly rate the diagnostic quality of the failure:

  • Clear — the test name and failure message immediately point to the bug. A developer would fix this in minutes.
  • Indirect — a test failed, but the failure message describes a symptom rather than the root cause. A developer would need to investigate. Consider whether a more targeted test would help.
  • Cascading — many tests failed, making it hard to locate the root cause. This suggests the code under test is a dependency of many things but may lack focused unit tests of its own.

Record the rating alongside the mutation result.

Reporting

After completing all mutations for the scope, produce a summary table:

| # | File           | Mutation                     | Result   | Diagnostic | Notes               |
|---|----------------|------------------------------|----------|------------|---------------------|
| 1 | pipeline.py    | Negate active check          | Killed   | Clear      | test_inactive_user  |
| 2 | pipeline.py    | Delete cache write           | Survived | —          | No cache test       |
| 3 | scoring.py     | Return 0 instead of score    | Killed   | Indirect   | Assertion on rank   |

Then provide:

  1. Mutation score: killed / total (e.g. 6/8 = 75%).
  2. Uncaught mutations: list each survived mutation with a sentence explaining what behaviour is untested and why it matters.
  3. Diagnostic quality: note any killed mutations where the failure message was indirect or cascading, and suggest how the test could be improved.
  4. Recommended tests: for each survived mutation, describe a test that would catch it. Group these by theme if several gaps point to the same missing test area.

Implementing missing tests

After presenting the report, ask the user whether they'd like you to implement the recommended tests. If yes:

  1. Locate the right test file. Follow the project's existing test layout. If the project puts tests in tests/test_<module>.py, follow that pattern. Don't create new test files when an existing one covers the same module.
  2. Write focused tests. Each test should target one survived mutation. Name the test to describe the behaviour it verifies, not the mutation it catches. For example: test_cache_is_populated_after_first_call, not test_mutation_2.
  3. Verify. Run the test suite to confirm your new tests pass on the unmodified code. Then re-apply each corresponding mutation and confirm the new test catches it.
  4. Don't over-test. If a single well-designed test would catch multiple survived mutations, write one test, not several. Aim for tests that verify real behaviour rather than just satisfying the mutation score.

Critical Rules

  • Always revert. After every test run, revert the mutation before doing anything else. Never stack mutations. Never leave mutated code in the working tree.
  • Verify the revert. Run git diff <file> after reverting to confirm the file is clean. If it's not, run git checkout -- <file> again.
  • Don't mutate test files. Only mutate production code.
  • Don't mutate imports, type annotations, or docstrings. These rarely reveal meaningful test gaps and produce noise.
  • Keep it targeted. 3–8 mutations per file is enough. Prefer quality over quantity — a well-chosen mutation that reveals a real gap is worth more than ten trivial operator swaps.
  • Ask when uncertain. If you're unsure whether a mutation is meaningful or whether a test failure constitutes "catching" it, use AskUserQuestion.
  • Respect the user's time. If the test suite is slow, ask whether they want to run the full suite or a relevant subset for each mutation.

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Mutation Testing làm được gì?

Perform mutation testing on the codebase. Introduces deliberate bugs one at a time, checks whether the test suite catches each one, and reports on test suite gaps. Optionally implements missing tests.

Vì sao nên dùng Mutation Testing trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Mutation Testing là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Mutation Testing trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/hugobowne/show-us-your-agent-skills/tree/main/skills/mutation-testing. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Mutation Testing?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Mutation Testing với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Mutation Testing với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Mutation Testing có miễn phí không?

Có. Kỹ năng này được hugobowne phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇