test-refine
БесплатноЗапускает вложенные скриптыНе проверенRefines an existing Go test suite — removes trivial/duplicate tests, strengthens weak assertions, reshapes tests around invariants, and closes branch-coverage…
от Roasbeef★ 33 звезды на GitHubОб этом скилле
Test Refine
A test suite can be voluminous and yet weak: tests that overlap, assert nothing meaningful, run code without checking outputs, or miss the branches that actually matter. Line coverage doesn't catch this — a 100% line-covered suite can have zero real assertions. This skill operates on an existing test suite and refines it.
This is orthogonal to test generation skills (test-forge, property-based-testing):
test-forgegenerates new tests.property-based-testingdesigns PBT for new or existing functions.mutation-testingvalidates whether existing tests catch behavior changes.test-refine(this skill) consumes the above signals and changes the test suite — strengthening assertions, removing dead weight, reshaping for invariants, closing branch-coverage gaps.
When to Use
- After a
test-forgepass — sharpen the generated tests. - Before opening a PR — clean up the diff so reviewers see strong tests.
- Periodically on critical packages — guard against test-quality drift.
- Following a mutation-testing run with survivors — convert each LIVED mutant into a tightened test.
Two-Phase Workflow
The skill runs read-only triage first, produces a markdown report, then applies fixes only after the user reviews and approves.
Phase A — Triage (read-only)
# Default: package in cwd. JSON intermediates land in /tmp; markdown in
# .reviews/test-refinement/<date>-<scope>.md.
~/.claude/skills/test-refine/scripts/triage.sh
# Pin scope to a single file
~/.claude/skills/test-refine/scripts/triage.sh --scope file --target ./internal/wallet/wallet_test.go
# Diff-scoped (changed test files in current branch vs auto-detected
# default branch — origin/HEAD, then main, then master).
~/.claude/skills/test-refine/scripts/triage.sh --scope diff
# Whole repo (slow)
~/.claude/skills/test-refine/scripts/triage.sh --scope repo
# With mutation testing for the strongest signal. Diff scope fans out
# across the unique set of affected packages (capped by
# MUTATION_FANOUT_CAP=5 by default; override via env var). Repo scope
# hard-fails — narrow before re-trying.
~/.claude/skills/test-refine/scripts/triage.sh --scope package --use-mutations
~/.claude/skills/test-refine/scripts/triage.sh --scope diff --use-mutations
The triage script:
- Resolves scope.
- Runs
go test -cover -covermode=atomicto capture per-function statement+branch coverage. - Optionally calls
~/.claude/skills/mutation-testing/scripts/unleash.shforLIVEDmutant data. - Runs the AST analyzers (
detect-smells.go,detect-duplicates.go,domain-checks.go). - Scores findings via
score.go(composite priority — see below). - Renders the markdown report.
Phase B — Batch Fix (after user approves report)
The user reviews the report. Each finding has a checkbox. The user checks boxes for the fixes they approve, then:
~/.claude/skills/test-refine/scripts/apply-fixes.sh \
--report .reviews/test-refinement/2026-05-06-wallet.md
The script applies only the checked items:
- Strengthen assertions in place.
- Add missing branch tests.
- Reshape into invariants (rewrite using
rapidfor flagged cases). - Remove tests only if explicitly checked.
After fixes, it re-runs go test ./... -race -count=1, appends an "After" metrics section to the same report, and surfaces the diff.
Safety rule: a test is never removed unless its checkbox in the report is explicitly checked. This honors the global rule "never remove/skip tests without asking" from
~/.claude/CLAUDE.md.
Composite Priority Score
When a triage produces dozens of findings, ranking matters. The composite score combines three signals:
priority = w_risk × risk_score(file_path)
+ w_severity × severity(smell_id)
+ w_gap × branch_gap(function)
| Component | Range | Source |
|---|---|---|
risk_score |
0.2–1.0 | File-path heuristic: `consensus |
severity |
0.3 (L) / 0.6 (M) / 1.0 (H) | Smell catalog severity (references/smell-catalog.md) |
branch_gap |
0.0–1.0 | Uncovered branches in the target function / total branches |
Default weights: 0.5 / 0.3 / 0.2. Override via --weights risk=0.6,severity=0.3,gap=0.1.
Smell Catalog (summary)
Full catalog with Go examples in references/smell-catalog.md.
| ID | Smell | Severity |
|---|---|---|
| S01 | No assertions at all (recognises testify, helper-named functions, and t.Run subtests) |
High |
| S02 | Tautological assertion (x == x) |
High |
| S03 | Getter/setter trivial test | Medium |
| S04 | Asserts no panic only | High |
| S05 | Unchecked error from SUT | High |
| S06 | Sensitive equality on rendered text — fmt.Sprint* and non-canonical .String(). Skipped for canonical types (chainhash.Hash, UUID, big.Int, time.Time, OutPoint, etc.) |
Medium |
Установить test-refine в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл test-refine?
Refines an existing Go test suite — removes trivial/duplicate tests, strengthens weak assertions, reshapes tests around invariants, and closes branch-coverage gaps. Uses code-guided coverage and (when available) gremlins mutation-testing survivor data rather than relying on line coverage alone. Use when test quality is uneven, after a test-generation pass, before opening a PR, or as a quality gate on critical paths (consensus, channel state, payment flows). Triggers: "refine these tests", "tests are bloated", "tighten assertions", "remove trivial tests", "audit test quality", "/test-refine".
Как установить скилл test-refine?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл test-refine запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic