Command Palette

Search for a command to run...

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

test-coverage-targeter

БесплатноБез исполняемых скриптовНе проверен

Use when a team can write only a handful of new tests and must pick which uncovered code matters most, or when some modules lose coverage while the total…

testlandот testland★ 18 звёзд на GitHub

Об этом скилле

test-coverage-targeter

Overview

100% coverage isn't the goal; risk-adjusted coverage is. A 50-line uncovered helper that hasn't been changed in 4 years is lower priority than a 10-line uncovered branch on an access-control function that gets edited every week.

This skill builds a ranked list of uncovered branches, scoring each by:

  • Risk weight - McCabe cyclomatic complexity (cyclomatic)
    • git churn frequency (commits in last N days) + PR-touch (was the file changed in this PR?).
  • Cost weight - Per the test pyramid (test-pyramid), unit tests are cheap, integration tests are medium, UI tests are expensive. The recommendation includes the layer.

The output is 5 - 10 specific test targets the team can take in one PR - not a 200-line "everything uncovered" dump.

When to use

  • A coverage report shows 60 - 80% - adding 5 tests should target the highest-impact uncovered code, not random low-hanging fruit.
  • A PR's coverage gate is failing on new files; the team needs to know which uncovered branches actually matter.
  • A test-debt sprint is upcoming and the team needs a 10-test budget allocated to the right places.
  • Pair with coverage-diff-reporter for the "what regressed" + "what to add" combo.

Step 1 - Inputs

Two required + two optional inputs:

Input Required Source
Coverage report ✓ LCOV / Cobertura / Jest JSON / coverage.py JSON / JaCoCo XML
Source tree ✓ Project root checkout
git log history opt For churn weighting (Step 3).
PR diff opt For PR-touch weighting (Step 4).

Step 2 - Extract uncovered branches

The shape (after parsing per upstream parser):

{
  'path': 'src/checkout/cart.ts',
  'uncovered_branches': [
    { 'line': 42, 'condition': 'if (item.stock < quantity)', 'arms_uncovered': 1, 'arms_total': 2 },
    { 'line': 78, 'condition': 'switch (status)', 'arms_uncovered': 3, 'arms_total': 5 },
  ],
  'uncovered_lines': [33, 34, 35, 92, 93],
  'covered_pct': 65.4,
}

Per language tool:

  • LCOV: parse BRDA:<line>,<block>,<branch>,<taken> records; taken == '-' is uncovered. Use lcov-analysis.
  • Cobertura: parse <line branch="true" condition-coverage="50% (1/2)"/>; use the Cobertura reference in lcov-analysis.
  • Jest JSON b field: arrays of arm hit counts; uncovered = 0. Use js-unit-tests (qa-unit-tests-js).
  • JaCoCo XML: parse <counter type="BRANCH" missed="N" covered="M"/> per method, then read source lines for context. Use jacoco-analysis.

Step 3 - Compute the risk weight

def risk_weight(file_path, branch):
    cyclomatic = mccabe_complexity(file_path, branch.line)
    churn      = git_churn(file_path, days=90)
    return (
        normalize(cyclomatic, 1, 20) * 0.5     # 50% complexity weight
        + normalize(churn,    0, 50) * 0.5     # 50% churn weight
    )

McCabe cyclomatic complexity

Per cyclomatic: McCabe's formula is M = E - N + 2 (edges − nodes + 2). The threshold convention:

"1 - 10: Simple procedure, little risk" "11 - 20: More complex, moderate risk" "21 - 50: Complex, high risk" ">50: Untestable code, very high risk" (cyclomatic)

Compute via per-language tools:

# Python
radon cc src/ -a

# JavaScript / TypeScript
npx complexity-report src/ -f json

# Java
# JaCoCo's COMPLEXITY counter (already in jacoco.xml per jacoco-analysis)

Function with cyclomatic >10 + uncovered branch = strong target.

Git churn

# Commits in the last 90 days touching this file
git log --since='90 days ago' --format= -- src/checkout/cart.ts | wc -l

High-churn files are where bugs accumulate; uncovered branches in high-churn files are the highest-priority targets.

Per cyclomatic: "reducing the cyclomatic complexity of code is not proven to reduce the number of errors or bugs in that code." Use complexity as a risk indicator, not a goal.

Step 4 - PR-touch boost

If the PR diff (Step 1 optional input) changed a file, boost its risk weight by 1.5×. Newly-edited code is strictly higher regression risk than untouched code.

def pr_boost(file_path, pr_changed_files):
    return 1.5 if file_path in pr_changed_files else 1.0

final_risk = risk_weight(...) * pr_boost(...)

Step 5 - Cost weight (test pyramid layer)

Per test-pyramid, the canonical layers (Cohn 2009):

Layer Cost (relative) Recommend for
Полный SKILL.md на GitHub

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

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

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

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

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

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

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

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

.tessl-plugin/plugin.json

FAQ

Что делает скилл test-coverage-targeter?

Use when a team can write only a handful of new tests and must pick which uncovered code matters most, or when some modules lose coverage while the total looks fine. Ranks uncovered branches in the diff by complexity, churn and test cost, and tracks per-file coverage drift.

Как установить скилл test-coverage-targeter?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл test-coverage-targeter запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

Сравнить test-coverage-targeter с