analyze-coverage

A test-coverage analysis command that shows which parts of the code are exercised by tests and where important gaps remain. It supports Jest, pytest, Go, and Rust test setups.

In plain words
What is it for?
Use it to analyze all code or only changed files, update a baseline, enforce a minimum percentage, and output results as text, JSON, Markdown, or a GitHub pull-request comment.
Why use it?
It finds untested critical paths instead of relying only on an overall coverage percentage. It can compare results with a saved baseline and suggest tests for uncovered code.

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/parkerm2/create-claude-workflow/analyze-coverage
Clone the repo
git clone --depth 1 https://github.com/ParkerM2/create-claude-workflow

Made for: Claude Code.

Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,418 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00016 $0.04418
Opus 5 $0.00008 $0.02209
Sonnet 5 $0.00003 $0.00884
Haiku 4.5 $0.00002 $0.00442

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

Security

Grade A, and why

analyze-coverage scanned grade A with 1 finding 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 2d 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

import { execSync } from "child_process";
.claude/commands/analyze-coverage.md · 628 lines

How it starts

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

Test Coverage Analysis with Gap Detection

Runs test coverage suite, compares against baseline, flags untested critical paths, and generates specific test suggestions for uncovered code. Supports Jest, pytest, Go, and Rust test frameworks.

Usage

/analyze-coverage [--update-baseline] [--pr] [--changed-only] [--min <percent>] [--format json|markdown]
  • --update-baseline: Save current coverage as new baseline for comparison
  • --pr: Post results as GitHub PR comment
  • --changed-only: Only analyze files changed in current branch
  • --min <percent>: Fail if coverage below threshold (default: 50)
  • --format: Output format (markdown, json, text)

Workflow

Phase 1: Framework Detection

Automatically detects test framework and coverage tooling.

import { execSync } from "child_process";
import * as fs from "fs";
import * as path from "path";

class CoverageAnalyzer {
  constructor() {
    this.framework = null;
    this.coverageTool = null;
    this.config = null;
    this.reportPath = null;
  }

  detectFramework() {
    // Check package.json for test scripts and dependencies
    let packageJson = {};
    try {
      const pkg = fs.readFileSync("package.json", "utf-8");
      packageJson = JSON.parse(pkg);
    } catch (err) {
      console.log("ℹ No package.json found; checking for other frameworks");
    }

    // Jest detection
    if (packageJson.devDependencies?.jest || fs.existsSync("jest.config.js")) {
      this.framework = "jest";
      this.coverageTool = "jest";
      this.reportPath = "coverage/coverage-final.json";
      return this;
    }

    // Check for pytest (Python)
    if (fs.existsSync("pyproject.toml") || fs.existsSync("setup.cfg")) {
      try {
        execSync("python -m pytest --version", { stdio: "pipe" });
        this.framework = "pytest";
        this.coverageTool = "pytest-cov";
        this.reportPath = ".coverage";
        return this;
      } catch (err) {
        console.log("ℹ pytest not found");
      }
    }

    // Go coverage detection
    if (fs.existsSync("go.mod")) {
      this.framework = "go";
      this.coverageTool = "go test";
      this.reportPath = "coverage.out";
      return this;
    }

    // Rust coverage detection
    if (fs.existsSync("Cargo.toml")) {
      this.framework = "rust";
      this.coverageTool = "cargo tarpaulin";
      this.reportPath = "cobertura.xml";
      return this;
    }

    throw new Error("Could not detect test framework. Supported: Jest, pytest, Go, Rust");
  }

  loadBaselineIfExists() {
    const baselinePath = ".coverage-baseline.json";
    try {
      const baseline = JSON.parse(fs.readFileSync(baselinePath, "utf-8"));
      console.log(`✓ Loaded baseline coverage: ${baseline.summary.lines.pct}%`);
      return baseline;
    } catch (err) {
      console.log("ℹ No baseline found; creating fresh baseline");
      return null;
    }
  }
}

const analyzer = new CoverageAnalyzer();
analyzer.detectFramework();
const baseline = analyzer.loadBaselineIfExists();

console.log(`✓ Detected framework: ${analyzer.framework}`);
console.log(`✓ Coverage tool: ${analyzer.coverageTool}`);

Read the full file on GitHub · 628 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. 2d ago First seen · 628 lines · 16 tokens per session scan A b71354529c13

Subscribe to this mod's changes

analyze-coverage is a command published in the GitHub repository ParkerM2/create-claude-workflow (4 stars, last pushed 5mo ago), licensed MIT. It adds 16 tokens to every session and 4,418 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.