AgentSkillsCN

plan-add-test-coverage

在将测试覆盖率提升至指定百分比阈值时,可优先选用此技能。它会运行覆盖率报告,识别覆盖率最低的文件,生成包含覆盖空白的简报,并制定计划,列出补充缺失测试的任务。

SKILL.md
--- frontmatter
name: plan-add-test-coverage
description: This skill should be used when increasing test coverage to a specified threshold percentage. It runs the coverage report, identifies files with the lowest coverage, generates a brief with coverage gaps, and creates a plan with tasks to add the missing tests.
allowed-tools: ["Read", "Bash", "Glob", "Grep"]
argument-hint: "<threshold-percentage>"

Increase Test Coverage

Target threshold: $ARGUMENTS%

If no argument provided, prompt the user for a target.

Step 1: Gather Requirements

  1. Find coverage config (jest.config.js, vitest.config.ts, .nycrc, etc.)
  2. Run coverage report to get current state:
    bash
    bun run test:cov 2>&1 | head -100
    
  3. Identify the 20 files with lowest coverage, noting:
    • File path
    • Current coverage % (lines, branches, functions)
    • Which lines/branches are uncovered

Step 2: Create Plan

In plan mode, create a plan that includes the following details:

markdown
Increase test coverage from [current]% to $ARGUMENTS%.

## Files Needing Coverage (ordered by coverage gap)

1. src/services/user.ts - 23% coverage (target: $ARGUMENTS%)
   - Uncovered: lines 45-67, 89-102
   - Missing branch coverage: lines 34, 56
2. src/utils/helpers.ts - 34% coverage (target: $ARGUMENTS%)
   - Uncovered: lines 12-45
...

## Configuration
- Config file: [path to coverage config]
- Update thresholds to $ARGUMENTS% for: lines, branches, functions, statements

## Acceptance Criteria
- All files meet $ARGUMENTS% coverage threshold
- `bun run test:cov` passes with no threshold violations

## Verification
Command: `bun run test:cov`
Expected: All thresholds pass at $ARGUMENTS%