$ recombobulate _
home / tips / write-property-based-tests-with-fast-check-and-claude
0

Write Property-Based Tests with fast-check and Claude

bagwaa @bagwaa · Mar 26, 2026 · Workflows
write-property-based-tests-with-fast-check-and-claude

Unit tests check the cases you thought of — property-based tests check the cases you didn't. Ask Claude to write them and it'll find the invariants you'd never think to enumerate manually.

claude "Read src/utils/currency.ts and write property-based tests using fast-check. Identify the mathematical invariants — commutativity, idempotency, round-trip encoding, boundary behaviours — and test each one with generated inputs including edge cases like zero, negative values, and floating-point precision."

Claude identifies the right properties for your domain: a sorting function should be stable and produce the same length output; a parser should round-trip any valid input; a price formatter should never lose precision.

// Claude generates tests like this
it('formatting then parsing is a round trip', () => {
  fc.assert(
    fc.property(fc.integer({ min: 0, max: 10_000_00 }), (amount) => {
      expect(parseCurrency(formatCurrency(amount))).toBe(amount);
    })
  );
});

For APIs and data pipelines, property tests are especially valuable:

claude "Write fast-check property tests for the UserSchema Zod validator. Test that any object satisfying the schema passes validation, that objects with required fields missing always fail, and that no valid input can cause an unhandled exception."

Claude can also shrink failures for you — when fast-check finds a counterexample, ask Claude to explain why that specific minimal case breaks the property.

Property tests find bugs that 1000 hand-written unit tests won't — and Claude writes them faster than you can dream up the invariants.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Generate a Typed API Client SDK from Your OpenAPI Spec with Claude

Give Claude your OpenAPI spec and ask for a handcrafted typed API client — clean method names, custom error handling, and TanStack Query hooks, without the ugly auto-gen output.

bagwaa @bagwaa · 2 hours ago