Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

test-refine

БесплатноЗапускает вложенные скриптыНе проверен

Refines an existing Go test suite — removes trivial/duplicate tests, strengthens weak assertions, reshapes tests around invariants, and closes branch-coverage…

Roasbeefот 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-forge generates new tests.
  • property-based-testing designs PBT for new or existing functions.
  • mutation-testing validates 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-forge pass — 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:

  1. Resolves scope.
  2. Runs go test -cover -covermode=atomic to capture per-function statement+branch coverage.
  3. Optionally calls ~/.claude/skills/mutation-testing/scripts/unleash.sh for LIVED mutant data.
  4. Runs the AST analyzers (detect-smells.go, detect-duplicates.go, domain-checks.go).
  5. Scores findings via score.go (composite priority — see below).
  6. 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 rapid for 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
Полный SKILL.md на GitHub

Установить test-refine в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

assets/refinement-report.md.tmplnotes/apply-fixes-capability-matrix.mdnotes/apply-fixes-smoke-2026-05-08.mdnotes/improvements-2026-05-06.mdnotes/improvements-2026-05-08.mdnotes/mutation-track-2026-05-08.mdreferences/coverage-pitfalls.mdreferences/domain-checks.mdreferences/reshape-to-invariants.mdreferences/smell-catalog.mdreferences/strengthening-patterns.mdreferences/workflow.mdscripts/analyze-coverage.shscripts/apply-fixes.shscripts/detect-duplicates.goscripts/detect-smells.goscripts/domain-checks.goscripts/render-report.shscripts/score.goscripts/triage.sh

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 запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить test-refine с