Skip to content
Back to skills

Property Based Testing

ASecurity

Writes property-based tests with generators, invariants and shrinking for parsers, serializers and pure logic where example tests miss edge cases.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 15, 2026
ai-agentsgotestingapi

Works with

  • api

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill property-based-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Property Based Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Property Based Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-property-based-testing/badge)](https://www.skillsdirectory.com/skills/workspace-templates-property-based-testing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: property-based-testing
description: Writes property-based tests with generators, invariants and shrinking for parsers, serializers and pure logic where example tests miss edge cases.
---

# Property based testing

Find a rule that must always hold, then let a generator attack it.

## Steps

1. Pick the library already in the project, or the standard one for the language (fast-check, Hypothesis, jqwik, gopter or rapid, proptest). Do not add a second.
2. Write the property in one plain sentence before any code. Good shapes:
   - round trip: `decode(encode(x)) == x`
   - idempotence: `normalize(normalize(x)) == normalize(x)`
   - invariant: output length, sum or sort order is preserved
   - oracle: the fast version equals a naive, obviously correct version
   - no crash: arbitrary input returns a value or a documented error, never an unhandled exception
3. Build generators for the domain, not raw strings: valid records, boundary numbers (0, -1, max, NaN), unicode, empty and huge collections. Constrain with filters sparingly, since heavy filtering wastes runs.
4. Run at least 200 cases locally and more in CI. Keep the seed printed on failure.
5. When a property fails, use the shrunk counterexample: decide whether the code or the property is wrong, fix it, and keep the counterexample as a plain example test.

## Rules

- A property must not recompute the implementation. That proves nothing.
- Never swallow the library's seed or disable shrinking.
- Keep each property to one rule.

## Report

The properties added, the generators, any bug found with its shrunk input, and the run count used.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.