Przejdź do treści
Biblioteka skilli
Programowanie · Testowanie

property-based-testing

/property-based-testing

Generuje działający test oparty na właściwościach dla wskazanej funkcji: test odwracalności dla pary encode i decode albo test niezmienników dla postwarunków, z Hypothesis w Pythonie i fast-check w JavaScript lub TypeScript.

Licencja
MIT
Ostatnia zmiana repozytorium
14.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
13
Skrypty
7
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 14.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co sprawdzić przed instalacją
  • 7 skryptów w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.

Skrypty: fixtures/invariant_fixture.py, fixtures/js-roundtrip/roundtrip.js, fixtures/js-roundtrip/roundtrip.properties.test.js, fixtures/no_property_fixture.py, fixtures/roundtrip_fixture.py, scripts/detect_and_dispatch.py, scripts/hypothesis_scaffold.py

Co robi i kiedy

Generuje działający test oparty na właściwościach dla wskazanej funkcji: test odwracalności dla pary encode i decode albo test niezmienników dla postwarunków, z Hypothesis w Pythonie i fast-check w JavaScript lub TypeScript.

Wyzwalacze z opisu

returns sortedis idempotents language via project-initgenerate a property testproperty-based test this functionadd Hypothesis/fast-check tests

Argumenty

/property-based-testing <module_path> <function_name>
Oryginalny opis (EN)

Generate a runnable property-based test for a target function from its signature/docstring — a round-trip test when an encode/decode pair exists, or an invariant test when the docstring documents a postcondition (e.g. "returns sorted", "is idempotent"). Detects the project's language via project-init's stack detection, uses Hypothesis for Python and fast-check for JavaScript/TypeScript, and recommends running /mutation-testing against the generated suite afterward. Use when the user says "generate a property test", "property-based test this function", "add Hypothesis/fast-check tests", or want

Jak działa

  1. Procedure
  2. When not to apply
Sekcje z nagłówków SKILL.md, w oryginale · 114 linii, 647 słów
Podgląd SKILL.md
---
name: property-based-testing
description: Generate a runnable property-based test for a target function from its signature/docstring — a round-trip test when an encode/decode pair exists, or an invariant test when the docstring documents a postcondition (e.g. "returns sorted", "is idempotent"). Detects the project's language via project-init's stack detection, uses Hypothesis for Python and fast-check for JavaScript/TypeScript, and recommends running /mutation-testing against the generated suite afterward. Use when the user says "generate a property test", "property-based test this function", "add Hypothesis/fast-check tests", or wants round-trip/invariant coverage for a pure function rather than hand-written example-based tests.
role: worker
user-invocable: true
argument-hint: "<module_path> <function_name>"
allowed-tools: Read, Write, Bash(python3 "${CLAUDE_PLUGIN_ROOT}/skills/property-based-testing/scripts/detect_and_dispatch.py" *, python3 "${CLAUDE_PLUGIN_ROOT}/skills/property-based-testing/scripts/hypothesis_scaffold.py" *, npm install *, npx vitest *)
---

# Property-Based Testing

Role: worker. This command derives and generates property-based tests
directly — it does not replace example-based tests, and it does not
fabricate a weak "doesn't crash" property when no round-trip pair or
documented invariant can be found.

## Procedure

### Step 1: Detect the target language (reuse project-init — never re-derive)

Run project-init's own stack detection —
`${CLAUDE_PLUGIN_ROOT}/skills/project-init/SKILL.md` § "Step 1: Detect the
stack" — over the target project. That section is this repo's canonical,
single source of truth for stack detection (its own frontmatter says so);
this skill reuses its result and never re-implements the filesystem-signal
table (`package.json`/`tsconfig.json` for JS/TS, `pyproject.toml`/
`requirements*.txt`/`setup.py` for Python, `*.sln`/`*.csproj` for C#,
`pom.xml`/`build.gradle` for Java) itself.

Reduce that step's result to a single detected-language value:

- Exactly one stack detected → its display name, verbatim as project-init's
  own stack table spells it (`Python`, `JS/TS`, `C#`, `Java`).
- Zero or ambiguous signals (project-init's own "ask the user" branch) →
  no detected language.

### Step 2: Gate on support

Pass the detected language (or nothing, when Step 1 found none) to
[`scripts/detect_and_dispatch.py`](scripts/detect_and_dispatch.py):

```bash
python3 "${CLAUDE_PLUGIN_ROOT}/skills/property-based-testing/scripts/detect_and_dispatch.py" --language "<detected language>"
```

This script decides support — it does not detect anything itself (see its
own module docstring). When the language is neither `Python` nor `JS/TS`,
or no language was passed at all, it prints the exact message below and
exits non-zero. **Stop here — no partial run, no file written**, exactly as
the Gherkin "Unsupported or undetected language" scenario requires:

```
Unsupported language: <detected|unknown> — supported: Python, JS/TS.
```

`<detected>` is the actual detected language name (e.g. `Go`, `C#`) when
Step 1 found one but it isn't supported; the literal word `unknown` when
Step 1 found nothing at all.

On a supported language, the script prints which generator to dispatch to
next and exits `0` — continue to Step 3.

### Step 3: Install the property-testing tool if missing

Follow project-init's own detection-gated-tool install pattern (`Step 4:
Install missing tools` of `project-init/SKILL.md`) rather than inventing a
new install mechanism — the tool is only installed when it's actually
missing from the target project:

- **Python — Hypothesis.** Add `hypothesis` to the project's own
  dev-dependency mechanism (`pyproject.toml` dev group or
  `requirements-dev.txt`, creating the latter if neither exists), exactly
  as project-init's Python lane already does for `ruff`/`mypy`/`pytest`.
- **JS/TS — fast-check.** `npm install --save-dev fast-check`, mirroring
  project-init's existing `npm` devDependency install shape for
  `oxlint`/`@playwright/test`.

Never a global/user-level install — same repo-level-only rule project-init
states for every lane and capability tool.

### Step 4: Generate the property test

- **Python** — invoke Step 4.1's scaffold directly:

  ```bash
  python3 "${CLAUDE_PLUGIN_ROOT}/skills/property-based-testing/scripts/hypothesis_scaffold.py" <module_path> <function_name> [--out-dir <dir>]
  ```

  It derives a round-trip property (a literal `encode`/`decode` pair) or an
  invariant property (a recognized docstring postcondition phrase near a
  type hint), writes `test_<function_name>_properties.py`, and prints its
  path. When neither heuristic matches, it prints the exact "No property
  derived" message and writes nothing — report that message verbatim rather
  than fabricating a property.

- **JS/TS** — follow
  [`references/languages/javascript.md`](references/languages/javascript.md)
  for the fast-check equivalent of the Python scaffold above: the same
  round-trip/invariant heuristic (an `encode`/`decode` export pair, or a
  recognized postcondition phrase in a JSDoc comment near a type
  signature), emitting a runnable `fc.assert(fc.property(...))` test file.

### Step 5: Recommend the mutation-testing follow-up (documentation only)

After Step 4 writes a test file, **recommend** — do not auto-run —
verifying it actually catches behavioral changes:

> Run `/mutation-testing` against the generated test file and report the
> resulting mutation score.

This skill never invokes `/mutation-testing` itself; that stays a separate,
user-initiated step so this skill doesn't re-implement mutation-testing's
own orchestration.

## When not to apply

- A function with no obvious round-trip pair or documented invariant — see
  Step 4's "No property derived" message rather than generating a weak
  "doesn't crash" test.
- A language other than Python or JS/TS, or a project whose stack detection
  is ambiguous — see Step 2's unsupported-language message.
Pliki w paczce (13)
  • SKILL.md 6 KB
  • fixtures/invariant_fixture.py 1 KB
  • fixtures/no_property_fixture.py 1 KB
  • fixtures/roundtrip_fixture.py 1 KB
  • fixtures/js-roundtrip/.gitignore 1 KB
  • fixtures/js-roundtrip/README.md 2 KB
  • fixtures/js-roundtrip/package-lock.json 37 KB
  • fixtures/js-roundtrip/package.json 1 KB
  • fixtures/js-roundtrip/roundtrip.js 1 KB
  • fixtures/js-roundtrip/roundtrip.properties.test.js 1 KB
  • references/languages/javascript.md 5 KB
  • scripts/detect_and_dispatch.py 3 KB
  • scripts/hypothesis_scaffold.py 11 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · bdfinst/agentic-dev-team100MIT
laurigates/claude-plugins100MIT
craftos-dev/craftbot100MIT
TomerAberbach/claude-config100MIT
Amey-Thakur/AI-SKILLS100MIT
vibeeval/vibecosystem100MIT
jacob-balslev/skill-graph100Apache-2.0
foryourhealth111-pixel/Vibe-Skills95Apache-2.0
redhatproductsecurity/prodsec-skills91Apache-2.0

Migawka bazy z 28.10.2026 · wersja paczki 8f46f2d4dbe2 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100qa-property-based-tests
    Pisze testy oparte na właściwościach w Hypothesis, fast-check lub proptest, definiując niezmienniki, generatory i strategie skracania.
  • 90quality-property-based-testing
    Podpowiada w testach opartych na właściwościach: testach generatywnych, fuzzingu, QuickCheck i fast-check oraz testowaniu niezmienników.
  • 95hypothesis-testing
    Prowadzi testowanie własności biblioteką Hypothesis do wykrywania przypadków brzegowych i walidacji niezmienników w złożonej logice z wieloma danymi wejściowymi.
  • 90testing-python-libraries
    Projektuje zestawy testów pytest dla bibliotek Python: fixtures, parametryzację, mockowanie, testy właściwości Hypothesis i CI.
  • 95bitcoin-testing-property-based
    Stosuje testy właściwości (proptest, quickcheck, hypothesis) do parserów Bitcoin: serializacja transakcji, round-trip deskryptorów i spełnialność miniscriptu.
  • 100property-based-test-helper
    Prawdopodobnie pomaga pisać i uruchamiać testy oparte na własnościach w ramach automatyzacji testów.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.