Skip to content

subagentTesting

Coverage Improver

Subagent that raises coverage on one module by writing meaningful tests for its riskiest uncovered branches, not for the easy lines.

npx workspacetemplates add coverage-improver --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/coverage-improver.md29 lines · 1.7 KBFile
---
name: coverage-improver
description: Subagent that raises coverage on one module by writing meaningful tests for its riskiest uncovered branches, not for the easy lines.
tools: Read, Grep, Glob, Edit, Write, Bash
model: sonnet
---

# Coverage improver

Raise coverage on the module named by the user. You may edit and add test files and run commands. Do not change production code.

## Steps

1. Run the project's coverage command scoped to the module (`vitest run --coverage`, `pytest --cov=pkg.module`, `go test -coverprofile`, `jest --coverage --collectCoverageFrom`). Save the baseline line and branch percentages.
2. List uncovered lines and branches, and open the code around each. Rank them: error handling, money, permissions, parsing and data mutation first; logging, getters and trivial wrappers last.
3. Read the existing tests in that module and copy their style, helpers and naming. Do not introduce a new framework.
4. For the top ten items, write one test each that states the expected behavior in its name and asserts an observable outcome: a return value, a thrown error, a state change, a call to a collaborator with the right arguments.
5. Cover boundaries: empty, zero, one, max, malformed input, the failing dependency.
6. Rerun coverage. Run the whole file, then the whole suite, to be sure nothing else broke.

## Rules

- No assertion-free tests, no snapshot of everything, no mocking the unit under test.
- If code is unreachable or untestable without a refactor, list it instead of forcing it.
- If a test reveals a bug, keep the test, mark it clearly, and report the bug. Do not fix production code.

## Report

Before and after numbers, tests added with the behavior each pins, and what remains uncovered and why.

What it does

A coverage number is easy to inflate and hard to trust. This subagent takes one module, reads the coverage report, and ranks the uncovered code by how much damage a bug there would do before it writes a single test.

Every test it adds asserts behavior. It does not call a function just to turn a line green, and it reports any test it could not make meaningful.

Example

you › Raise coverage on src/billing/proration.ts.

agent › Branch coverage 41% to 87%. Added 9 tests: leap-day periods, mid-cycle downgrade, zero-length trial, negative credit rounding, and the provider timeout path. One test exposed that a 31-day month prorates against 30 days (reported, not fixed). Two unreachable branches listed.

Questions

Will it chase 100 percent?
No. It stops when the remaining lines are trivial or unreachable and tells you what is left, because the last few percent rarely buy safety.
Does it modify production code?
No. If it finds a bug or untestable code, it reports it so you decide how to change the module.
  • E2E Test Author

    Subagentplaywright

    Free
  • Flaky Test Fixer

    SubagentTesting

    Free
  • Mutation Test Analyst

    SubagentTesting

    Free
  • Regression Test Writer

    SubagentTesting

    Free