agentleFS
wboayuewboayue/rust-ibapi/.claude/skills/coverage/SKILL.md

coverage

Skill400 starsChanged 7 days agoMITView on GitHub

Measure and raise test coverage for a module — toolchain check, baseline against main, a fast per-file llvm-cov loop, reading the numbers without chasing instrumentation noise, and the tactics that close the last gap. Use for "improve coverage of src/X.rs" or a pre-PR coverage check.

  • Installs packages

28 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use scan, lint and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • rajnavakotiSkill

    scan

    Run the AI dashboard scanner and generate the HTML report.

    Also in 4 projects that use this

  • Microsoft AzureSkill

    lint

    Run all linting and spell checking for TypeScript and Rust code. Run this before committing to catch style issues, clippy warnings, and misspellings.

    Also in 4 projects that use this

  • julienamorganSkill

    profile

    Researches the user's market, competitors, and competitive positioning to build a complete ICP profile. Shows findings for user approval before proceeding. Triggers: /profile, "research my market", "who are my competitors". Reads: ./gtm/company.md, ./gtm/icp.md. Writes: updates ./gtm/icp.md with competitive positioning. Standalone: yes (asks for domain if company.md missing).

    Also in 3 projects that use this

  • asterkinSkill

    adr

    Create Architecture Decision Records (ADRs) following project standards. Guides template usage, process, and best practices for documenting architecturally significant decisions.

    Also in 4 projects that use this

  • anombyte93Skill

    discover

    Phase 1 of the prd-taskmaster pipeline: brainstorm-driven discovery. Delegates to superpowers:brainstorming in Interactive Mode (one adaptive question at a time), or self-brainstorms in Autonomous Mode when no user is present. Intercepts before the brainstorming chain hands off to writing-plans — this skill owns the exit. Extracts constraints, calibrates scale (Solo / Team / Enterprise), and advances the pipeline to GENERATE.

    Also in 3 projects that use this

  • MicrosoftSkill

    worktree

    Create, reuse or clean up a dedicated git worktree for working on a pull request or a private branch. Use from any PR-scoped workflow that needs an isolated checkout to keep current code and build output untouched.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 25 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Like for like: run §3 on main in a detached worktree so your branch stays untouched.

    line 32
  2. Very specific:

    Test behavior through production code first (exercise production code): the impl Client method with a stubbed bus, the decoder with a …

    line 98
  3. Distinctive:

    Every added test asserts something a reader would care about.

    line 111

“Common” is measured: kept by at least 6 in 10 of the 25 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Coverage

Target: $ARGUMENTS. The floor is 90% lines per touched module, and every new pub / pub(crate) fn has a test (coverage floor). $S is your scratchpad directory.

1. Toolchain

Coverage runs on nightly (doc-tests only instrument there); build and test stay on the pinned stable toolchain. Two version couplings break it:

SymptomCauseFix
rustc …-nightly is not supported by the following packagesNightly older than a dependency's MSRV (often after a Dependabot bump)rustup update nightly
0% for every file while tests pass; or raw profile version mismatchcargo-llvm-cov older than nightlycargo install cargo-llvm-cov --locked, then cargo +nightly llvm-cov clean --profraw-only

0% everywhere is never a real result. Cross-check with stable cargo llvm-cov --lib --all-features (undercounts doc-tests, but sane).

2. Baseline

A percentage means nothing without main's number for the same file.

  • Quick: Coveralls has main's per-file numbers (https://coveralls.io/github/wboayue/rust-ibapi, measured as in §3's CI recipe).
  • Like for like: run §3 on main in a detached worktree so your branch stays untouched. A fresh worktree is a cold build, several minutes.

    git worktree add --detach $S/cov-main origin/main
    # run §3 there, note the numbers
    git worktree remove $S/cov-main

(src/proto/decoders.rs once read 85% on a branch, which looked low until main read 41.7%.)

3. Per-file loop

just cover instruments everything and opens a browser. For one file:

# profiles pile up across --no-report runs; start each iteration clean
cargo +nightly llvm-cov clean --profraw-only

# instrument + test, no report (~1 min with a warm build cache)
cargo +nightly llvm-cov --all-features --doctests --no-report --quiet

# summary for the target file
F=src/contracts/types.rs
cargo +nightly llvm-cov report --json | jq -r --arg f "$F" '.data[0].files[]
  | select(.filename | endswith($f)) | .summary | to_entries[]
  | select(.key | IN("lines","functions","regions"))
  | "\(.key): \(.value.percent | floor)% (\(.value.covered)/\(.value.count))"'

# which lines are uncovered
cargo +nightly llvm-cov report --summary-only --show-missing-lines | grep "$F"

Feature-gated code. --all-features never compiles #[cfg(not(feature = "async"))] / not(feature = "sync") blocks, so they read as absent, not uncovered. CI (Coveralls) merges a sync-only and an async-only run instead; use that when the file has such blocks, or to match Coveralls:

cargo +nightly llvm-cov clean --workspace
cargo +nightly llvm-cov --no-report --doctests --no-default-features --features sync
cargo +nightly llvm-cov --no-report --doctests --no-default-features --features async
# then the same report commands

For the line-by-line view, cargo +nightly llvm-cov report --html --output-dir $S/cov and open $S/cov/html/coverage/<absolute path>.html; red lines carry uncovered-line.

Without the clean step, each run adds to the last: a deleted test still counts, and switching between the two recipes mixes configurations. After each batch of tests, re-run the clean and instrument steps of whichever recipe you used; the report commands (~15s) read what they left.

4. Read the numbers

  • Track functions and regions, not lines. lines.count is instrumented sites: generics, derives and macro expansions move it without the file changing (one module went 241 → 343 → 245 sites across a refactor while its source stayed ~545 lines).
  • Find gaps in the HTML, not the JSON. The JSON lists per-monomorphization sub-regions as uncovered where the HTML shows the line covered.
  • Noise, not gaps (on stable or --lib runs): ..Default::default() and doc-comment fence lines. Nightly + --doctests removes them.
  • Not coverage at all: a const fn called only from const initializers reads 0%; llvm-cov sees runtime paths only.

5. Close the gap

Test behavior through production code first (exercise production code): the impl Client method with a stubbed bus, the decoder with a fixture builder, the error branch with the frame that triggers it. Then, for what's left:

UncoveredTactic
derive(Serialize, Deserialize) linesOne serde round-trip per type, through a generic helper (check_serde_round_trip in src/contracts/types_tests.rs), not a macro
fn new(s: impl Into<String>)Call it with both &str and String: each argument type is a separate function to llvm-cov. Same for any impl Trait parameter
A const fn constructorOne runtime call with an assertion
A branch on the current timeA clock seam, not a sleep
A sync or async side onlyThe mirror test on the other side; parity gaps hide here

Every added test asserts something a reader would care about. A test that only executes a line to move a number gets cut in review.

6. Report

In the PR body, per touched file: main's number → yours, for lines and functions, and the command that produced them. target/llvm-cov-target/ grows large; delete it when done if disk is tight.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.