test-coverage-guardian

Enforces 95% test coverage on modified TypeScript and Rust source files using Vitest and cargo-llvm-cov.

3|Updated Jun 23, 2026
One-click install
npx skills add https://github.com/Tlahey/git-manager --skill test-coverage-guardian-tlahey
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-coverage-guardian
Source: https://github.com/Tlahey/git-manager/tree/main/.claude/skills/test-coverage-guardian
Command: npx skills add https://github.com/Tlahey/git-manager --skill test-coverage-guardian-tlahey

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @vitest/coverage-v8, cargo-llvm-cov, and includes scripts (resource) and references (resource) components.

What problem does it solve? New or modified source files often ship without tests, leaving error paths, boundary conditions, and confirmation-gated destructive actions unexercised — the exact lines that break in production. This Skill ensures every .ts/.tsx/.rs file you create or modify gets a co-located test driving its own coverage to at least 95% on lines, branches, functions, and statements. ## Core Features & Use Cases - Per-file coverage checks: Scoped scripts report exact uncovered line numbers, branches, and functions for only the files you touched, avoiding slow and noisy repo-wide runs. - Edge-case guidance: A checklist helps you pick which categories genuinely apply — empty inputs, error paths, destructive-action confirmations, async states — instead of padding coverage with hollow tests. - Repo-specific gotcha references: Documents known Vitest/jsdom quirks (query-cache bleed, missing PointerEvent, Monaco fakes) and Rust test conventions (tempdir git2 repos, --lib scoping, nightly branch coverage). - Use Case: After adding a new React hook or a Rust service function, run the coverage script on that file, see it reports 82% with uncovered lines 45-52, add tests targeting those branches, and rerun until all metrics pass 95%. ## Quick Start Ask the AI to add a feature or fix a bug in a source file and require that the changed files reach 95% test coverage with real edge-case tests before finishing.

Frequently Asked Questions about test-coverage-guardian

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check test coverage for a single file with Vitest?▼

Run the check_ts_coverage.mjs script with the source file path; it uses vitest related to find tests exercising that file via the module graph, then reports per-file percentages for lines, branches, functions, and statements plus exact uncovered line numbers.

How do I measure Rust code coverage with cargo-llvm-cov?▼

Use the check_rust_coverage.sh script with the target .rs file paths. It runs cargo llvm-cov --lib with lcov output and parses per-file line, function, and branch coverage, listing uncovered lines so you can target tests precisely.

Why does cargo llvm-cov show low function coverage for tested functions?▼

Without the --lib flag, cargo-llvm-cov also instruments the test-less binary target in src/main.rs, giving every pub fn a second zero-hit entry and halving reported coverage. The script restricts instrumentation to --lib to avoid this.

Why does my Vitest test show 0 mock calls even though the query ran?▼

Components importing the singleton queryClient leak cache between tests because of its staleTime setting, so the mocked queryFn is never called again. Call queryClient.clear() in beforeEach to reset the cache per test.

Does Rust branch coverage work on the stable toolchain?▼

No, cargo llvm-cov --branch requires a nightly Rust toolchain. Without nightly installed, the script falls back to line and function coverage and reports branch coverage as unavailable rather than failing.

What if a file genuinely cannot reach 95% coverage?▼

State the actual percentage and the reason explicitly instead of shipping silently under threshold or writing hollow tests. A common legitimate case is a thin Tauri command shelling out to network or filesystem with no service-layer extraction yet.