test-coverage

A command that checks how much of the code is exercised by automated tests and identifies important untested areas.

In plain words
What is it for?
Measuring coverage in JavaScript, Python, or Go projects and asking a test-writing agent to add tests for critical gaps.
Why use it?
It reveals gaps in test coverage and uses the project's configured coverage requirement when one exists.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/sefaertunc/worclaude/test-coverage
Clone the repo
git clone --depth 1 https://github.com/sefaertunc/Worclaude

Made for: Claude Code.

Per session 10 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,193 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00010 $0.01193
Opus 5 $0.00005 $0.00596
Sonnet 5 $0.00002 $0.00239
Haiku 4.5 $0.00001 $0.00119

Measured 3d ago against content hash 13873f9c6e36, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test-coverage scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/test-coverage.md · 129 lines

How it starts

The opening of the file, as written. The whole thing — 129 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Analyze test coverage and fill gaps in the most critical areas. Delegates to the test-writer agent for test creation.

Process

  1. Read project coverage thresholds

    Before measuring, read the project's configured threshold so the gap baseline is the project's standard, not a guess. Check in this order and use the first one that exists:

    • Vitest: vitest.config.ts / vitest.config.js (test.coverage.thresholds)
    • Jest: jest.config.{ts,js,cjs} or package.json jest.coverageThreshold
    • Pytest: pytest.ini / pyproject.toml ([tool.coverage.report] fail_under)
    • Go: a // coverage: directive in Makefile or CI config
    • Fallback: 80% line coverage if no threshold is configured

    Report the threshold up front so the gap analysis has a clear bar.

  2. Measure current coverage

    Run the coverage tool for the project:

    • Node.js: npx vitest run --coverage or npx jest --coverage
    • Python: pytest --cov=src --cov-report=term-missing
    • Go: go test -coverprofile=coverage.out ./... && go tool cover -func=coverage.out
    • Read CLAUDE.md for project-specific coverage commands
  3. Identify gaps, anchored to the last release

    Focus on files with coverage below the configured threshold that contain:

    • Business logic (core domain functions)

    • Error handling paths

    • Integration points (DB, API, filesystem)

    • Recently changed code, anchored to the last release tag (not an arbitrary HEAD~10). Run the helper as a single command — do not unpack the script body:

      bash .claude/scripts/test-coverage-changed-files.sh
      

      The helper prints one filename per line — files changed since the last release tag, or the last 10 commits when no tag exists. This makes "recently changed" mean "since the last release," not "since some arbitrary cutoff," so coverage gaps reflect what actually ships next.

  4. Prioritize by risk

    Don't aim for 100% everywhere. Prioritize:

    • HIGH: untested error handling, auth logic, data validation
    • MEDIUM: untested business rules, state transitions
    • LOW: untested getters, formatters, simple delegation
    • SKIP: generated code, framework boilerplate, config files
  5. Confirm-then-delegate (do NOT write tests inline)

    Present the prioritized gap list to the user as a table:

    | # | File                  | Coverage | Risk | Suggested tests                          |
    |---|-----------------------|----------|------|------------------------------------------|
    | 1 | src/core/merger.js    | 62%      | HIGH | conflict-resolution edge cases (3 tests) |
    | 2 | src/utils/hash.js     | 45%      | HIGH | empty input + non-UTF8 encoding (2 tests)|
    | 3 | src/commands/init.js  | 78%      | MED  | scenario-C edge case (1 test)            |
    ...
    

    Then ask the user which to close. Use AskUserQuestion when the list has 2-4 candidates (its native option limit). For >4 candidates, present a numbered list and ask the user to reply with the numbers they want closed (e.g., "1, 3, 4").

    AskUserQuestion: "Which gaps should I close?"
    - <up to 4 file/test descriptions, one per option>
    

    Delegate confirmed gaps to the test-writer agent in a worktree. Do NOT write tests inline:

    Agent({
      subagent_type: "test-writer",
      description: "Close coverage gaps in <files>",
      prompt: "Coverage gaps to close:\n<confirmed list>\n
               Project threshold: <threshold>%.
               Follow existing test patterns. Name tests as specifications.
               Verify each new test passes; report any that don't and why."
    })
    

    The worktree isolation keeps the main session clean if test-writer's exploration touches many files.

  6. Report results

    After the agent returns:

    File Before After Tests Added Notes
    src/core/merger.js 62% 88% 7 Added conflict edge cases
    src/utils/hash.js 45% 91% 4 Added empty input + encoding
    src/commands/init.js 78% 78% 0 Already well-covered

Read the full file on GitHub · 129 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 129 lines · 10 tokens per session scan A 13873f9c6e36

Subscribe to this mod's changes

test-coverage is a command published in the GitHub repository sefaertunc/Worclaude (4 stars, last pushed 24d ago), licensed MIT. It adds 10 tokens to every session and 1,193 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.