Skip to main content
command

add-property-based-testing — Claude Code command: setup and use

This command analyzes a project and adds property-based tests, from invariant discovery to data generators. Use it when example-based tests miss broader behavior.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --command testing/add-property-based-testing
Open on GitHub

What add-property-based-testing does

The command inspects a codebase and sets up property-based testing. It looks for mathematical properties in functions, business invariants, symmetry, and round-trip behavior. The listed framework options include fast-check, Hypothesis, QuickCheck, and proptest, with the language guiding the choice.

It can create data generators, add preconditions and postconditions, configure shrinking for failures, and connect the tests to an existing suite. The description also covers stateful and model-based testing, parallel execution, and performance properties. For JavaScript and TypeScript, it searches for Jest configuration; for Python, it checks for pytest. Other cases may be classified as multi-language.

You can pass JavaScript, Python, Java, Haskell, Rust, or Clojure as the language argument. Since the project scan does not identify every language explicitly, pass the language yourself when working with one of these options.

What it helps with

  • find invariants in business logic
  • test mathematical properties of functions
  • build generators for test data
  • shrink a failing case to a smaller example
  • add property-based tests to an existing suite

Example prompts for the agent

  • Add property-based tests for the Python calculation module.
  • Find invariants in the cart logic and create suitable generators.
  • Test round-trip behavior in this JavaScript code.

How to install add-property-based-testing

1claude-code-templates

npx claude-code-templates@latest --command testing/add-property-based-testing

2Manually: put the files in place

.claude/commands/add-property-based-testing.md

Call it with /add-property-based-testing. For all projects use ~/.claude/commands/

Questions about add-property-based-testing

How do I install add-property-based-testing in Claude Code?

Run npx claude-code-templates@latest --command testing/add-property-based-testing. The command file is available at .claude/commands/add-property-based-testing.md.

What does add-property-based-testing do?

It analyzes a codebase, selects a property-testing framework, and identifies invariants. It can then create generators and integrate tests with the existing suite.

Which languages can add-property-based-testing work with?

You can specify JavaScript, Python, Java, Haskell, Rust, or Clojure. The command can also try to infer the language from project files.

Source text

add-property-based-testing.md · MIT
---
allowed-tools: Read, Write, Edit, Bash
argument-hint: "[language] | --javascript | --python | --java | --haskell | --rust | --clojure"
description: Implement property-based testing with framework selection and invariant identification
---

# Add Property-Based Testing

Implement property-based testing framework with invariant analysis and test generation: **$ARGUMENTS**

## Current Testing Context

- Language: !`find . -name "*.js" -o -name "*.ts" | head -1 >/dev/null && echo "JavaScript/TypeScript" || find . -name "*.py" | head -1 >/dev/null && echo "Python" || echo "Multi-language"`
- Test framework: !`find . -name "jest.config.*" -o -name "pytest.ini" | head -1 || echo "Detect framework"`
- Mathematical functions: Analysis of codebase for property-testable functions
- Business logic: Identification of invariants and properties in domain logic

## Task

Implement comprehensive property-based testing with invariant analysis and automated test generation:

**Language Focus**: Use $ARGUMENTS to specify JavaScript, Python, Java, Haskell, Rust, Clojure, or auto-detect from codebase

**Property-Based Testing Framework**:

1. **Framework Selection** - Choose appropriate tool (fast-check, Hypothesis, QuickCheck, proptest), install dependencies, configure integration
2. **Property Identification** - Analyze mathematical properties, identify business invariants, discover symmetries, evaluate round-trip properties
3. **Generator Design** - Create custom data generators, implement constraint-based generation, design composite generators, optimize generation strategies
4. **Property Implementation** - Write property tests, implement preconditions, design postconditions, create invariant checks
5. **Shrinking Configuration** - Configure test case shrinking, optimize failure minimization, implement custom shrinkers, enhance debugging
6. **Integration & Reporting** - Integrate with existing test suite, configure reporting, setup CI integration, optimize execution performance

**Advanced Features**: Stateful property testing, model-based testing, custom generators, parallel property execution, performance property testing.

**Quality Assurance**: Property completeness analysis, edge case coverage, performance optimization, maintainability assessment.

**Output**: Complete property-based testing setup with identified properties, custom generators, integrated test suite, and performance optimization.

© davila7 · MIT · davila7/claude-code-templates

Similar slash commands

All slash commands for Testing and QA →

From the same set804

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor