Przejdź do treści
Biblioteka skilli
Programowanie · Przegląd i audyt

test-pruning

/test-pruning

Usuwa, składa lub scala zbędne testy w unifi-mcp bez utraty sprawdzanych elementów, łącząc kopiowane testy w sparametryzowane.

Repozytorium
unifi-mcp ↗
Licencja
MIT
Ostatnia zmiana repozytorium
24.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
7
Skrypty
6
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 24.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ą
  • 6 skryptów w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.

Skrypty: scripts/arcdiff.py, scripts/candidates.py, scripts/cov_ctx.sh, scripts/foldsummary.py, scripts/mutdiff.py, scripts/weakscan.py

Co robi i kiedy

Usuwa, składa lub scala zbędne testy w unifi-mcp bez utraty sprawdzanych elementów, łącząc kopiowane testy w sparametryzowane.

Oryginalny opis (EN)

Remove, fold or consolidate redundant tests in unifi-mcp without losing a check. Use when asked to trim, prune, shrink or deduplicate the test suite, to fold copy-pasted tests into parametrized ones, or to review a PR that deletes or folds tests.

Jak działa

  1. 1. Baseline
  2. 2. Candidates
  3. 3. Review every candidate
  4. 4. Gates before the PR
  5. 5. PR
Sekcje z nagłówków SKILL.md, w oryginale · 81 linii, 715 słów
Podgląd SKILL.md
---
name: test-pruning
description: |
  Remove, fold or consolidate redundant tests in unifi-mcp without losing a check. Use when
  asked to trim, prune, shrink or deduplicate the test suite, to fold copy-pasted tests into
  parametrized ones, or to review a PR that deletes or folds tests.
---

# Test pruning

A pruning pass makes the suite smaller while every check still holds. The bar for what may go is
`AGENTS.md` → Test Assertions; this skill is how to apply it at scale. Scripts live in `scripts/`.

The trap is that coverage cannot see a **weakened** test: one that still runs the same code but
would now pass a broken result. On the first pass, branch coverage stayed at zero loss while
review found nine weakened tests. Every gate below exists to catch what coverage misses.

## 1. Baseline

Run `scripts/cov_ctx.sh <worktree> <suite> <out>.coverage` for every suite you will touch, on an
untouched worktree of the base commit. Suites: `core shared relay network protect access api`.
It records per-test branch coverage and unsets `UNIFI_*` first, since exported settings change
which tests collect.

Done when each suite you will touch has a baseline file named `base.<suite>.coverage` in one directory.
Keep the baseline of every other suite there too: step 2 reads them to decide ownership.

## 2. Candidates

`python3 scripts/candidates.py <suite> <baseline-dir> <worktree> <out>.json [exclude.txt]` lists
test functions whose coverage other tests already provide, with the kept tests that overlap each
most. It keeps every arc in the suite's own package, plus arcs in other packages that the owning
suite does not cover, which matches how CI measures coverage. Security, redaction, drift,
symmetry, contract, golden and incident-evidence tests are never candidates.

A candidate is only a lead. In the app suites, many managers now live in `unifi_core`, and the core
suite often runs that code without asserting it, so the app test is the only real check. Expect
to keep most app-suite candidates; folding copy-pasted tests saves more than deleting.

Done when each suite has a candidate file.

## 3. Review every candidate

For each candidate, open it and the kept tests it overlaps, and decide from the assertions:

- **Delete** only under the `AGENTS.md` bar: a kept test asserts the same thing on the same input.
  Record that kept test and its exact assertion.
- **Fold** tests with the same body into one parametrized test, keeping each original's inputs and
  assertions. A fold that swaps in simpler data (one product for three, one value for two) has
  weakened the test.
- **Keep** everything else, with a one-line reason.

Write a ledger: one row per deleted or folded test, naming the kept test and assertion that
covers it. `scripts/foldsummary.py <ledger.md>...` turns ledgers into a PR-sized summary.

Done when every candidate has a row and every deletion names an exact counterpart.

## 4. Gates before the PR

Run all of these on the finished branch; each catches a different kind of weakened test.

1. **Coverage**: `scripts/cov_ctx.sh` on the branch, then `python3 scripts/arcdiff.py <suite>
   <baseline-dir> <after>.coverage` must report no required arc lost. A few arcs are reached
   nondeterministically (the `unifi_api/services/managers.py` loop near line 2045, and the
   connection- and event-manager arcs in `unifi_core/network/managers` reached by the
   `test_server_cleanup.py` connect race). Treat a loss as flaky only after a rerun of the
   unchanged base loses the same arcs.
2. **Weakening scan**: `python3 scripts/weakscan.py <repo> <base-ref> <branch>` flags loops over a
   returned collection with no length check, and expected values that share an object with the
   input under test. Fix or justify each finding.
3. **Independent review**: give a reviewer that did not make the changes only the diff, the
   ledger and the scan output. Ask it to compare every deleted or folded test's assertions with
   what replaced them, and to name any dropped assertion or weaker replacement (empty data,
   different input, a broader end-to-end test). This is the only gate that catches an assertion
   dropped inside a fold, or a fold that changed its inputs.
4. **Mutation diff** (optional, for deletions in high-risk code): `python3 scripts/mutdiff.py
   <clean-worktree> <source-file> <function>[,...] <test-file> <base-ref> <branch>` reports bugs
   the original tests caught that the changed tests let through. It costs one pytest run per
   mutant, so scope it to the functions behind the deletions you are least sure of.

Done when coverage reports no unexplained loss, every scan finding is fixed or justified, and the
reviewer's findings are resolved.

## 5. PR

One PR per suite group, with the ledger summary, collected cases before and after, net lines, and
the coverage result. Then address every valid point in the Copilot review before merging.
Pliki w paczce (7)
  • SKILL.md 5 KB
  • scripts/arcdiff.py 2 KB
  • scripts/candidates.py 6 KB
  • scripts/cov_ctx.sh 1 KB
  • scripts/foldsummary.py 1 KB
  • scripts/mutdiff.py 7 KB
  • scripts/weakscan.py 9 KB

Wersje

W bazie nie ma innych skilli o nazwie test-pruning.

Migawka bazy z 13.11.2026 · wersja paczki 22ddfa8598b8 (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

  • 100test-suite-pruning
    Odchudza rozbudowany zestaw testów: ocenia, co przeoczy błąd, i usuwa testy źródeł, formatowania oraz pustych przypadków.
  • 100test-deduplicator
    Analizuje zestawy testów, by znaleźć zbędne i zduplikowane przypadki na podstawie pokrycia, podobieństwa semantycznego i wyników wykonania, co skraca czas testów.
  • 100audit-tests
    Sprawdza, czy testy warte są kosztu utrzymania, i wskazuje, który zestaw testów odpowiada za dany kontrakt.
  • 90test-audit
    Audytuje istniejące testy pod kątem przypadków mało wartościowych, zdublowanych lub sprzężonych z implementacją i usuwa albo przepisuje je na podstawie dowodów, a w trybie full wskazuje też kontrakty publiczne bez testów.
  • 90test-audit
    Przycina mało wartościowe testy w całym zestawie do zmierzonego celu przy zachowaniu pokrycia, na przykład gdy agenci piszą bezsensowne testy albo trzeba zmniejszyć liczbę testów o 20 proc.
  • 90test-audit
    Usuwa mało wartościowe testy: powtarzające kod źródłowy, dublujące silniejsze dowody, sprzężone z implementacją albo utrzymujące przy życiu produkcyjne szwy tylko dla testów, a nowe testy sprawdza tą samą miarą.

Uwagi i zgłoszenia

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