home / skills / codyswanngt / lisa / plan-add-test-coverage

plan-add-test-coverage skill

/.claude/skills/plan-add-test-coverage

This skill helps you increase test coverage by running reports, identifying gaps, and generating a concrete plan to add tests.

npx playbooks add skill codyswanngt/lisa --skill plan-add-test-coverage

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.4 KB
---
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"]

---

# 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: Compile Brief and Delegate

Compile the gathered information into a structured brief:

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

Files needing coverage (ordered by coverage gap):
1. [file] - [current]% coverage (target: $ARGUMENTS%)
   - Uncovered: [lines]
   - Missing branch coverage: [lines]
2. ...

Configuration: [config file path], update thresholds to $ARGUMENTS%

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

Invoke `/plan-execute` with this brief to create the implementation plan.

Overview

This skill plans and organizes work to raise a TypeScript codebase test coverage to a specified threshold. It runs the coverage report, finds the files with the lowest coverage, and produces a concise brief that highlights gaps and required tests. The brief is formatted to feed into an execution planner that creates concrete tasks to add missing tests.

How this skill works

First, it locates the project coverage configuration (jest, vitest, .nycrc, etc.) and runs the coverage command to capture current metrics. It then identifies the 20 files with the lowest coverage, extracting per-file line, branch, and function percentages and listing uncovered lines/branches. Finally, it compiles a structured brief that states current vs target coverage and enumerates tasks to add tests and update thresholds.

When to use it

  • You need to raise overall project coverage to a concrete percentage (e.g., 80%).
  • Before a release where coverage gates must be enforced by CI.
  • When onboarding stakeholders who need a clear remediation plan for coverage gaps.
  • After refactors that may have reduced test surface and you want to restore coverage.
  • When coverage thresholds in config files need to be updated and validated.

Best practices

  • Provide the target percentage as the argument; otherwise the skill will prompt for it.
  • Run tests locally (bun run test:cov) before relying on CI results to ensure repeatability.
  • Prioritize files by risk and coverage gap, not only by lowest percentage.
  • List uncovered lines and branches so tests can be written to exercise specific cases.
  • Include the coverage config file path in the brief and propose threshold updates explicitly.

Example use cases

  • Increase repo coverage from 62% to 80% ahead of a security audit.
  • Identify top 20 low-coverage utility files and produce tasks to add unit tests.
  • Create a verification plan for CI: update thresholds to 85% and confirm bun run test:cov passes.
  • Turn coverage output into a handoff brief for a test-writing contractor or team.

FAQ

What coverage command does the skill run?

It runs the repository's coverage command (example: bun run test:cov) and captures the report output for analysis.

How are files selected for remediation?

Files are ordered by coverage gap and the 20 files with the lowest coverage are selected, including per-file uncovered lines and branch details.