property-based-testing
Provides guidance for property-based testing across multiple languages and smart contracts. Use when writing tests, reviewing code with serialization/validation/parsing patterns, designing features, or when property-based testing would provide stronger coverage than example-based tests.
Security Assessment
Detected risks:
About property-based-testing
The property-based-testing skill provides comprehensive guidance for implementing property-based testing (PBT) across multiple programming languages and smart contract environments. This skill is designed to help developers move beyond traditional example-based tests by focusing on generalized properties and invariants that should hold for a wide range of inputs. By analyzing patterns such as serialization pairs, parsers, normalizers, validators, mathematical functions, and smart contract operations, it assists developers in identifying opportunities where property-based testing can improve test coverage and reliability.
Key features of this skill include a detailed catalog of testing properties such as roundtrip, idempotence, invariants, commutativity, associativity, identity, inverse, oracle verification, and exception safety. It provides automatic detection cues for when to apply PBT based on code patterns and design elements, prioritizing high-value areas like pure functions, serialization pairs, and smart contract state invariants. Additionally, the skill includes a decision tree linking development tasks to recommended reference guides for generating tests, designing features, refactoring code for testability, reviewing existing tests, and interpreting test failures. It also outlines clear limitations, advising against use in simple CRUD operations, one-off scripts, or scenarios with non-isolatable side effects.
This skill is particularly useful for software engineers, QA professionals, and developers working with complex data transformations, algorithmic logic, or smart contracts in languages like Solidity and Vyper. It is suitable for teams aiming to enhance unit and component testing coverage, ensuring that transformations, validations, and algorithmic behaviors meet rigorous property-based criteria. Target users benefit from more reliable, maintainable, and robust code through systematic detection of properties and guided testing strategies.
FAQ
When should I use the property-based-testing skill?
Invoke this skill when your code includes serialization/deserialization pairs, parsers, normalizers, validators, custom data structures, mathematical functions, or smart contract operations, especially where general properties can be tested rather than relying on fixed examples.
Which programming languages and environments are supported?
The skill is applicable across multiple programming languages and smart contract platforms, including Solidity and Vyper. It focuses on patterns and transformations rather than language-specific APIs.
Are there situations where I should avoid using property-based-testing?
Yes. Avoid using it for simple CRUD operations without transformations, one-off scripts, code with unisolatable side effects (like network or database operations), or where example-based tests are sufficient. It is primarily for unit and component testing, not integration or end-to-end testing.
What types of properties can I test with this skill?
The skill supports testing for properties such as roundtrip, idempotence, invariants, commutativity, associativity, identity, inverse, oracle checks, and exception safety. These help verify that code behaves correctly across a wide range of inputs.
Can this skill help with reviewing existing tests?
Yes. It provides guidance for reviewing property-based tests, including checklists and anti-patterns, to ensure tests are thorough, correctly designed, and maintainable.
Install property-based-testing
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
trailofbits/skills