This skill should be used when the user asks to "UIのテストカバレッジを分析して", "テスト数が足りているか確認して", "最低限必要なテスト数を計算して", "UIコンポーネントのテスト不足を調べて", "analyze UI test coverage", "check if tests are enough", "calculate minimum tests". Runs a Python static analysis script against the project, calculates the Cartesian product of UI component features, and reports the gap between required and actual test counts as JSON.
From ui-test-coveragenpx claudepluginhub utakatakyosui/c2lab --plugin ui-test-coverageThis skill is limited to using the following tools:
Implements structured self-debugging workflow for AI agent failures: capture errors, diagnose patterns like loops or context overflow, apply contained recoveries, and generate introspection reports.
Designs and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
UIコンポーネントを静的解析して最低限必要なテスト数を計算し、既存テスト数と比較してギャップをJSONレポートとして出力するスキル。
計算式: product(各propの値数) × product(各stateの値数) = コンポーネントごとの最低テスト数
SCRIPT="${CLAUDE_PLUGIN_ROOT}/scripts/ui_test_coverage.py"
# 基本(カレントディレクトリ)
python "$SCRIPT" .
# プロジェクトディレクトリ指定
python "$SCRIPT" /path/to/project
# サマリーのみ(詳細コンポーネントリストを除く)
python "$SCRIPT" . --summary-only
# JSONファイルに保存
python "$SCRIPT" . --output coverage-report.json
# 特定コンポーネントのみ
python "$SCRIPT" . --component "*/components/**/*.tsx"
スクリプトが出力するJSONの構造:
{
"components": [
{
"file": "Button.tsx",
"minTests": {
"count": 72,
"normalTests": 9,
"errorTests": 63,
"normalFactors": [
{ "name": "variant", "values": 3 },
{ "name": "size", "values": 3 }
],
"errorFactors": [
{ "name": "disabled", "values": 2 },
{ "name": "onClick", "values": 2 },
{ "name": "isLoading", "values": 2 }
],
"calculation": "正常系: variant(3) × size(3) = 9 | 異常系パターン: disabled(2) × onClick(2) × isLoading(2) = 8 | 合計: 9 × 8 = 72 (純正常系 9 + 異常系含む 63)"
}
}
],
"summary": {
"minTests": { "total": 485 },
"actualTests": { "unit": 120, "e2e": 15, "total": 135 },
"gap": { "delta": -350, "coveragePercent": 27.8, "status": "insufficient" }
}
}
正常系 vs 異常系の見方:
normalTests: 「全パラメーターが正常値」のパターン数 = 最低限の正常系テスト数errorTests: disabled・loading・エラー等の異常系パターンを含むテスト数normalFactors: required enum/union props(variant, size 等)= 正常系バリアント軸errorFactors: boolean props, optional, states, event handlers = 異常系の軸JSONレポートを受け取ったら、以下の情報をサマリーとして伝える:
gap.status が sufficient / insufficientgap.coveragePercent %normalTests / errorTests)actualTests.totaltopComplexComponents の上位5件normalTests 分の正常系テストを作成するerrorFactors の各軸(disabled, loading, error等)を網羅する異常系テストを追加する| 種別 | 拡張子 |
|---|---|
| コンポーネント | .tsx .jsx .vue .svelte |
| Unit テスト | .test.tsx .test.ts .spec.tsx .spec.ts 等 |
| E2E テスト | e2e/ cypress/ playwright/ ディレクトリ内のテスト |
node_modules, .git, dist, build, .next, .nuxt, coverage, out
| TypeScript型 | 推定値数 |
|---|---|
boolean | 2 |
'a' | 'b' | 'c' (Union) | 3 |
string | 2 (正常値/空) |
number | 2 (正常値/境界値) |
T | undefined | count_type_values(T) + 1 |
T[] / Array<T> | 2 (空/非空) |
ReactNode | 2 |
children, className, style, id, key, ref は汎用的すぎるため除外。
props: { name: String } 形式(Options API)は解析されない。Composition API の defineProps() のみ対応。Options API を使うコンポーネントは minTests: 1 と報告される。*.stories.tsx / *.story.tsx などはコンポーネントとして解析されない。it() / test() 以外のカスタムテスト関数を使っている場合、テスト数が過少評価される。python3 "$SCRIPT" .
node_modules にコンポーネントが混入していないか確認find . -name "*.tsx" -not -path "*/node_modules/*" | head -20
スクリプトは it( / test( / describe( のパターンでカウントするため、カスタムテストヘルパーを使っているプロジェクトでは過少評価になる場合がある。
formula スキル(「テスト数の計算式を説明して」で起動)${CLAUDE_PLUGIN_ROOT}/scripts/ui_test_coverage.py