- Home
- Skills
- Testing & Debugging
- spec to adversarial tests
spec to adversarial tests
Turns a spec, function, or diff into a test suite engineered to fail against near-miss (mutated) implementations, not just obvious breakage. Use when code needs tests that prove behavior rather than exercise it.
Free
Works with the AI Agents you already use
spec to adversarial tests
Example session with this skill installed
Generate an adversarial test suite for a Python function process_payment(amount, balance) that deducts funds and returns a status, ensuring it handles all edge cases.
- Read your context and instructions
- Compiled the spec to adversarial
I have analyzed the payment processing logic and generated an adversarial test suite focused on killing near-miss mutations.
Adversarial Test Suite for process_payment
Assumptions Block
- Contract Guarantees:
balancemust never be negative post-transaction. - Caller Controls:
amountis expected to be a positive numeric value.
Underdetermined (Flagged): The spec is silent on behavior when amount is exactly zero. I have pinned this to "allow" and added a test to enforce it.
import pytest
from payment_module import process_payment
def test_rejects_insufficient_funds():
# Invariant: Cannot spend more than the available balance
assert process_payment(amount=101, balance=100) == "INSUFFICIENT_FUNDS"
def test_allows_exact_balance_spend():
# Invariant: Spending total balance results in zero, not rejection
assert process_payment(amount=100, balance=100) == "SUCCESS"
def test_rejects_negative_payment_amount():
# Invariant: Payment must be a positive movement of value
assert process_payment(amount=-50, balance=100) == "INVALID_AMOUNT"
def test_handles_zero_amount_as_noop():
# Pinning underdetermined behavior: zero is a success no-op
assert process_payment(amount=0, balance=100) == "SUCCESS"
Kill Map
| Variant (Mutation) | Killer Test | Priority | Status |
|---|---|---|---|
Flip amount > balance to >= | test_allows_exact_balance_spend | MUST | UNEXECUTED |
| Remove negative check | test_rejects_negative_payment_amount | MUST | UNEXECUTED |
Change amount == 0 to amount <= 0 | test_handles_zero_amount_as_noop | MAY | UNEXECUTED |
| Swallow exception on type mismatch | test_rejects_negative_payment_amount | MUST | UNEXECUTED |
Next steps
- Update
payment_module.pyiftest_handles_zero_amount_as_noopfails to match your desired business logic. - Integrate these tests into your CI/CD pipeline.
- Run a mutation coverage tool like
mutmutto verify the Kill Map.
Connects securely to your tools. The creator never sees your data.
About this skill
Turns a spec, function, or diff into a test suite engineered to fail against near-miss (mutated) implementations, not just obvious breakage. Use when code needs tests that prove behavior rather than exercise it.
What it does
- Assumption mapping identifies what a spec guarantees and flags underdetermined edge cases.
- Failure cataloging applies known patterns like off-by-one errors, partial batch failures, and type confusion to your specific domain.
- Invariant derivation defines properties that must hold regardless of implementation, testing the contract rather than the code.
- Mutation testing generates "near-miss" variants of your code to check whether the test suite can catch subtle logic flips or dropped branches.
- Kill map generation provides a table showing exactly which test catches which specific failure mode.
How it works
- Provide a spec or code snippet and ask for an adversarial suite.
- Review the assumptions and underdetermined points the agent identifies before it writes code.
- Receive a runnable test file with tests named after the invariants they protect.
- Analyze the Kill Map to see which mutations (e.g., flipping a comparison) each test is responsible for catching.
Frameworks & tools
Language agnostic. Works with standard unit testing frameworks like Pytest, Jest, Mocha, Vitest, or ExUnit.
Use cases
- Mission-critical logic where a single comparison flip (e.g.,
<vs<=) causes data corruption. - Refactoring legacy code to check that a new implementation adheres to the original contract.
- Hardening public APIs against unexpected or malicious inputs.
- Auditing developer PRs to find holes in existing test coverage.
Known limitations
Does not perform actual execution of tests unless the environment supports it; output includes an UNEXECUTED label for kill maps in restricted environments.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.
Does not execute tests in environments without a runtime. Requires a clear spec or function to derive invariants.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 2 days ago
- Free with an Agensi account
Permissions
No special permissions declared or detected