check-test-coverage
Skill486 starsChanged 15 days agoApache-2.0View on GitHub
Audit and verify test coverage for a specific file or module, ensuring all custom logic branches, state transitions, and boundary conditions are covered while strictly eliminating dependency test bloat (never testing std, third-party crates, or macro-derived boilerplate). Use via /check-test-coverage <filename>.
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 6 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
When invoked via the /check-test-coverage <file_path> command.
- Distinctive: line 15
When reviewing a file before creating a commit or finalizing a task.
- Distinctive: line 16
When evaluating whether a newly added or modified file has sufficient test coverage.
- Distinctive: line 17
When auditing existing test suites to identify missing custom logic tests or remove redundant test bloat.
- Very specific: line 28
Never write tests that merely assert standard library behavior (std::collections::HashMap, std::env, std::ffi::OsString).
- Very specific: line 29
Never write unit tests for standard compiler derives (#[derive(Default, Clone, Copy, PartialEq, Eq, Debug)]).
- Very specific: line 30
Never write unit tests for third-party derive macros (such as #[derive(Display, EnumString)] with #[strum(serialize_all = "lowercase")] or …
- Very specific: line 39
When running /check-test-coverage <path> (either directly or delegated to a background subagent via invoke_subagent with TypeName: "self", …
- Very specific: line 43
Read the entire target file using view_file or AST navigation (rust_analyzer_symbols).
- Distinctive: line 68
Create a structured audit table mapping each piece of custom logic to its test coverage:
- Distinctive: line 85
Concrete Test Code: If any custom branches are missing, provide exact, ready-to-use unit test snippets.
- Very specific: line 138
Do NOT test whether HashMap::insert stores a value or whether PathBuf::from works.
- Very specific: line 149
Do NOT: add cargo-llvm-cov to routine ./check.fish --check or --full pipelines (re-compilation with -C instrument-coverage slows down …
- Distinctive: line 194
Discard it immediately: Do NOT write a test to cover it.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
// Copyright (c) 2026 R3BL LLC. Licensed under Apache License, Version 2.0.
Skill: check-test-coverage
Audit and verify test coverage for a specific file or module. Ensure all custom logic branches, state transitions, and boundary conditions are covered while strictly eliminating dependency test bloat (never testing std, third-party crates, or macro-derived boilerplate).
When to Use
- When invoked via the
/check-test-coverage <file_path>command. - When reviewing a file before creating a commit or finalizing a task.
- When evaluating whether a newly added or modified file has sufficient test coverage.
- When auditing existing test suites to identify missing custom logic tests or remove redundant test bloat.
Core Philosophy: Zero Test Bloat ("Test OUR Code, Not Dependencies")
Traditional "code coverage" tools blindly count lines or instructions executed, encouraging developers to write low-signal tests for boilerplate, compiler derives, and third-party crates.
In this codebase, test quality is measured by branch-targeted verification of OUR custom logic:
- Test OUR Code Exclusively:
- Tests must target the unique execution paths, custom algorithms, match branches, state transitions, conversion traits (
From,TryFrom), and error conditions written by us.
- Tests must target the unique execution paths, custom algorithms, match branches, state transitions, conversion traits (
- Never Test Dependencies or Compiler Derives:
- Never write tests that merely assert standard library behavior (
std::collections::HashMap,std::env,std::ffi::OsString). - Never write unit tests for standard compiler derives (
#[derive(Default, Clone, Copy, PartialEq, Eq, Debug)]). - Never write unit tests for third-party derive macros (such as
#[derive(Display, EnumString)]with#[strum(serialize_all = "lowercase")]orclap::ValueEnum).
- Never write tests that merely assert standard library behavior (
- High Signal, Low Maintenance Overhead:
- Redundant tests slow down
cargo testandcheck.fishiteration cycles. - Redundant test failures during refactoring obscure real bugs and create maintenance friction.
- Redundant tests slow down
5-Step Audit Workflow
When running /check-test-coverage <path> (either directly or delegated to a background subagent via invoke_subagent with TypeName: "self", Model: "inherit"), follow these five steps systematically:
Step 1: Inspect the Target File
Read the entire target file using view_file or AST navigation (rust_analyzer_symbols). Catalog all items:
- Public and private functions (
fn) - Structs and Enums
- Derived traits vs custom trait implementations (
impl Trait for Type) - Match expressions,
if letblocks, and conditionals - Error handling paths (
Result,Option,unwrap_or_else,unreachable!)
Step 2: Classify Code Components (Custom Logic vs Upstream/Derives)
Separate items into two categories:
| Category | What it includes | Testing Requirement |
| OUR Custom Logic | Custom functions, custom parsers/formatters, manual trait impls (From, TryFrom, Display), business logic, state machines, boundary checks, error branches | Must be covered with targeted test cases (1 test per branch/boundary) |
| Upstream / Derives | #[derive(Default, Clone, Copy, PartialEq, Eq, Debug)], strum macro attributes, clap derive attributes, standard library forwards | Do NOT test (testing these is test bloat) |
Step 3: Discover All Test Locations
Locate all test functions covering the file:
- Inline unit tests:
mod testsinside the file itself. - Adjacent unit test modules: E.g.,
unit_tests.rsormod.rstest modules in the same directory. - Integration and conformance tests: E.g.,
tests/,conformance_tests/, or crate-level integration suites.
Step 4: Construct the Branch & Boundary Matrix
Create a structured audit table mapping each piece of custom logic to its test coverage:
| Target Symbol / Branch | Test Function | Classification | Status |
| :--- | :--- | :--- | :--- |
| `InputKind::from((Some, None))` | `test_tuple_to_input_kind_file` | Custom `From` logic | Covered |
| `InputKind::from((None, Some))` | `test_tuple_to_input_kind_command` | Custom `From` logic | Covered |
| `BaseEnv::default()` | — | Compiler `#[derive(Default)]` | Skipped (Dependency / Derive) |
| `OutputFormat` strum display | — | Strum macro derive | Skipped (Dependency / Derive) |Step 5: Deliver Actionable Verdict & Recommendations
Provide a concise, high-signal report:
- Verdict: Explicitly state whether coverage is Sufficient or Insufficient.
- Branch Coverage Breakdown: Show which custom logic branches are covered vs missing.
- Zero Bloat Verification: Confirm no tests are testing standard library or third-party macros.
- Concrete Test Code: If any custom branches are missing, provide exact, ready-to-use unit test snippets.
Detailed Classification Guide
What MUST Be Tested (Our Custom Logic)
- Manual Trait Implementations:
// MUST TEST: Custom conversion logic with 2 branches impl From<(&Option<PathBuf>, &Option<String>)> for InputKind { fn from(tuple: (&Option<PathBuf>, &Option<String>)) -> InputKind { match tuple { (Some(file), None) => InputKind::File(file.clone()), (None, Some(cmd)) => InputKind::InlineCommand(cmd.clone()), _ => unreachable!(), } } } - Custom Parsing & Formatting Logic:
- Regex parsing, state machines, ANSI code builders, diff calculators.
- Boundary & Overflow Checks:
- Off-by-one boundary cases, index-overflow conditions (see
check-bounds-safetyskill).
- Off-by-one boundary cases, index-overflow conditions (see
- Error & Fallback Branches:
Errreturns, fallback defaults when inputs are malformed.
What MUST NOT Be Tested (Test Bloat)
- Standard Derives:
// DO NOT TEST: Testing BaseEnv::default() tests the Rust compiler derive macro. #[derive(Debug, Clone, Default, PartialEq, Eq)] pub enum BaseEnv { #[default] Inherit, Explicit(EnvMap), } - Third-Party Macro Derives:
// DO NOT TEST: Testing .to_string() tests strum's macro generator. #[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum, Display, EnumString)] #[strum(serialize_all = "lowercase")] pub enum OutputFormat { Fish, Powershell, Json, Dotenv, } - Standard Library Collections / Types:
- Do NOT test whether
HashMap::insertstores a value or whetherPathBuf::fromworks.
- Do NOT test whether
Empirical Verification via cargo-llvm-cov (Semantic Filter + LLVM Runtime Truth)
While the 5-step inside-out audit maps what we intended to test based on code structure, runtime execution can occasionally diverge due to early returns, short-circuiting operators, or mock state. When deep assurance is needed on complex algorithms, state machines, or parsers, use cargo-llvm-cov as an empirical verification tool.
Never Use as a Blanket Metric
- Do NOT enforce blanket whole-project line-coverage percentages (e.g.,
80%or90%). That creates Goodhart's Law perverse incentives to test compiler derives, getters, and standard library forwards. - Do NOT add
cargo-llvm-covto routine./check.fish --checkor--fullpipelines (re-compilation with-C instrument-coverageslows down developer iteration).
Surgical Invocation Pattern
To avoid large terminal dumps from un-run files across the crate, use the cov helper in run.fish which automatically filters output:
# Filtered terminal report (table header + target file row + uncovered lines):
fish run.fish cov <package> <test_filter> [file_filter]
# Example:
fish run.fish cov r3bl_tui osc_color
# Interactive visual browser report (highlighted source lines):
fish run.fish cov r3bl_tui osc_color --htmlOr run raw cargo-llvm-cov directly:
cargo llvm-cov test -p <crate_name> --lib <test_name> --show-missing-lines | grep -E "(Filename.*Cover|<file_name>)"Filtering LLVM Coverage Data Through the AST Model
Raw cargo-llvm-cov output reports every unexecuted line, including macro expansions, derived traits, and trivial forwards. Cross-reference the output through our Step 2 classification matrix:
┌────────────────────────────┐
│ cargo-llvm-cov line report│
│ (Raw unexecuted lines) │
└─────────────┬──────────────┘
│
▼
┌────────────────────────────┐ [ INTERSECT ]
│ Inside-Out AST Model ├────────────┼───────────► 1. Uncovered Derives / Upstream
│ (Our Custom Logic Ranges) │ │ └─► DISCARD (Zero Test Bloat)
└────────────────────────────┘ │
▼
2. Uncovered Custom Logic
└─► REAL GAP DETECTED!
(Write targeted test)- Uncovered line falls within Upstream / Derives (
#[derive(...)],strum,clap,stdwrappers):- Discard it immediately. Do NOT write a test to cover it.
- Uncovered line falls within OUR Custom Logic (custom match arm, error fallback closure, boundary check):
- Actionable Gap! An intended branch was never executed at runtime. Add a targeted test case specifically exercising that branch.
Related Skills
organize-tests: Test directory taxonomy, isolation patterns, and zero test-bloat directive.check-bounds-safety: Type-safe index and length bounds verification.check-code-quality: Full quality verification suite (./check.fish --full).
In this repository30 other files it gives its agents.
- .agents/AGENTS.mdAGENTS.md
- AGENTS.mdAGENTS.md
- build-infra/AGENTS.mdAGENTS.md
- rust-analyzer-mcp-server/AGENTS.mdAGENTS.md
- task/AGENTS.mdAGENTS.md
- llms.txtllms.txt
- analyze-log-filesSkill
- analyze-performanceSkill
- audit-taskSkill
- batch-refactor-with-sub-agentsSkill
- check-bounds-safetySkill
- check-code-qualitySkill
- code-reviewSkill
- concurrency-safetySkill
- create-commit-messageSkill
- create-prSkill
- design-philosophySkill
- fast-string-allocationsSkill
- fix-issueSkill
- merge-prSkill
- organize-modulesSkill
- organize-testsSkill
- release-crateSkill
- remove-crate-prefixSkill
- review-prSkill
- run-clippySkill
- safe-renamingSkill
- test-cross-platformSkill
- write-documentationSkill
- write-structured-tracingSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

