contract-driven-testing

Derive a three-level testing pyramid from function code contracts.

15|5|Updated May 19, 2026
One-click install
npx skills add https://github.com/bobmatnyc/trusty-tools --skill contract-driven-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: contract-driven-testing
Source: https://github.com/bobmatnyc/trusty-tools/tree/main/crates/trusty-code/src/assets/skills/contract-driven-testing
Command: npx skills add https://github.com/bobmatnyc/trusty-tools --skill contract-driven-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill eliminates the ambiguity in test planning by mechanically deriving a comprehensive three-level test pyramid directly from a function's defined preconditions, postconditions, and invariants.

Core Features & Use Cases

  • Contract-Targeted Unit Tests: Generates focused tests for happy paths and boundary conditions based on specific postconditions.
  • Property-Based Testing: Translates contracts into property assertions that validate logic across a wide range of generated inputs.
  • Precondition Violation Tests: Ensures the system fails gracefully and explicitly when input contracts are violated.
  • Use Case: When refactoring a critical math library, use this skill to ensure that every function's invariants are protected by both unit and property-based tests.

Quick Start

Apply the contract-driven-testing skill to the current function to generate a complete test plan including unit, property-based, and violation tests.

Frequently Asked Questions about contract-driven-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate tests from preconditions and postconditions?

Contract-driven testing derives a three-level test pyramid from function-level preconditions, postconditions, and invariants. It generates focused unit tests, property-based tests, and negative violation tests to ensure software verification.

What is contract-driven testing and how does it work?

Contract-driven testing eliminates test planning ambiguity by mechanically deriving a comprehensive test pyramid from a function's defined preconditions, postconditions, and invariants to validate logic across generated inputs.

Can I use property-based testing frameworks like hypothesis and fast-check with contract testing?

Yes, contract-driven testing requires integration with language-specific assertion libraries and property-testing frameworks like hypothesis, proptest, or fast-check to translate contracts into property assertions.

How do I test that my function fails gracefully when input contracts are violated?

Contract-driven testing generates precondition violation tests to ensure the system fails gracefully and explicitly when input contracts are violated, protecting function invariants during refactoring.

What's the best way to verify math library invariants during a refactor?

Deriving contract-targeted unit tests from postconditions protects math library invariants by validating boundary conditions and happy paths, ensuring every function's logic is verified across wide input ranges.

Does contract-driven testing cover boundary conditions and happy paths?

Yes, contract-driven testing generates focused unit tests for happy paths and boundary conditions based on specific postconditions, alongside property-based tests and precondition violation tests.