quality-property-based-testing
Use when the user asks about property-based testing, Hypothesis, fast-check, QuickCheck, generators and shrinking, invariants, stateful testing or fuzzing…
by j4flmao★ 47 GitHub stars
Install quality-property-based-testing in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
Property-Based Testing
Purpose
Use property-based testing to define invariants and properties, generate random inputs, shrink failing cases, and discover edge cases that example-based testing misses. This skill covers generator design, property formulation, shrinking optimization, stateful testing, and CI integration.
Agent Protocol
Trigger
User mentions property-based testing, fuzzing, generative testing, QuickCheck, fast-check, Hypothesis, invariant testing, random testing, or asks about finding edge cases automatically.
Input Context
- Functions or modules under test
- Existing example-based test suite
- Input type definitions and constraints
- Business rule invariants
- Performance requirements for test execution
Output Artifact
Property-based test suite with generators, property definitions, and CI integration configuration.
Response Format
Structured property test suite with:
- Property definitions (invariants, round-trips, metamorphic relations)
- Custom generator implementations (with shrinking)
- Stateful command models for stateful systems
- CI configuration for fast and thorough runs
Completion Criteria
- Properties defined for all identified invariants
- Generators produce valid domain inputs with < 10% rejection rate
- Shrinking produces minimal counterexamples
- CI integration with adaptive run depth (fast on commit, thorough nightly)
- Failing seeds captured and counterexamples added as regression tests
Workflow
- Identify properties: Analyze the system under test; categorize properties as invariants, round-trips, idempotence, metamorphic, or stateful
- Design generators: Build generators for all input types using built-in generators, combinators, and custom arbitraries. Avoid heavy filtering
- Implement properties: Write property assertions using chosen framework (fast-check, Hypothesis, jqwik). Verify preconditions before postconditions
- Run and shrink: Execute with default run count (100). Verify shrinking produces actionable minimal counterexamples
- Analyze failures: Inspect shrunk inputs. Add counterexamples as regression tests. Store seeds for reproduction
- Optimize generators: Profile generation and shrinking performance. Replace filters with constrained generation. Reduce rejection rate
- Integrate CI: Configure CI with adaptive depth. Fast run (100 runs) on every commit. Thorough run (1000+ runs) nightly. Store seeds in build artifacts
- Add stateful models: For stateful systems, implement command-based models with preconditions, postconditions, and invariants
- Track metrics: Monitor property coverage, shrinking efficiency, counterexample discovery rate, and generator rejection rate
- Maintain property suite: Review properties during refactoring. Remove obsolete properties. Add new properties for modified code
Architecture / Decision Trees
Framework Selection Decision Tree
Inputs: language, team expertise, existing tooling
├── TypeScript/JavaScript → fast-check
│ ├── Stateful testing needed? → Use fc.Command + fc.modelRun
│ └── Async code? → Use fc.asyncProperty
├── Python → Hypothesis
│ ├── Stateful testing needed? → RuleBasedStateMachine
│ └── Pandas/NumPy? → pandas strategies
├── Java/Kotlin → jqwik
│ ├── Spring Boot? → Combine with Spring tests
│ └── Stateful testing? → StateMachine
└── Haskell → QuickCheck
Property Type Selection Decision Tree
Can you express a relation between input and output?
├── YES → Is the function an involution?
│ ├── YES → Reflective property: f(f(x)) == x
│ └── NO → Is the function idempotent?
│ ├── YES → Idempotence property: f(f(x)) == f(x)
│ └── NO → Round-trip property: decode(encode(x)) == x
└── NO → Can you express an invariant?
├── YES → Invariant property (e.g., output is sorted)
└── NO → Metamorphic property: related inputs → related outputs
Common Pitfalls
- Heavy filtering in generators: Filter that rejects > 50% of values kills performance and shrinking. Replace with constrained generation (e.g.,
fc.integer({ min: 1 })instead offc.integer().filter(n => n > 0)) - Testing tautologies: Properties that can never fail (e.g., asserting the sum of two positive integers is positive when the generator only produces positive integers)
- Ignoring shrinking quality: If the shrunk output is still complex, the shrinker is not working well. Use constrained generators and avoid flatMap when possible
- Insufficient run count: Running only 10-20 random tests is not property-based testing. Minimum 100 runs; prefer 1000 for thorough validation
- No seed tracking: Failing to record the seed makes failures unreproducible. Always log seed and path
- Stateful test state pollution: Commands that share mutable state produce irreproducible failures. Each test run must start from a clean state
- Over-constrained generation: Generators that only produce "nice"
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
- references/custom-generators.md
- references/hypothesis-strategies.md
- references/property-based-testing-advanced.md
- references/property-based-testing-fundamentals.md
- references/property-patterns.md
- references/property-testing-architecture.md
- references/property-testing-decision-framework.md
- references/shrinking-guide.md
- references/stateful-testing-deep.md
- references/stateful-testing.md
FAQ
What does the quality-property-based-testing skill do?
Use when the user asks about property-based testing, Hypothesis, fast-check, QuickCheck, generators and shrinking, invariants, stateful testing or fuzzing. Produces properties, generators and stateful models. Not for example-based unit tests (use quality-unit-testing) or smart contract invariants (use blockchain-testing).
How do I install the quality-property-based-testing skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the quality-property-based-testing skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…