home / skills / redisearch / redisearch / check-rust-coverage

check-rust-coverage skill

/.skills/check-rust-coverage

This skill identifies uncovered Rust test lines by executing cargo llvm-cov and reports per-file gaps to guide targeted testing.

npx playbooks add skill redisearch/redisearch --skill check-rust-coverage

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
960 B
---
name: check-rust-coverage
description: Check which Rust lines are not covered by Rust tests.
---

# Check Rust Coverage

Determine which Rust lines are not covered by Rust tests.

## Arguments
- `<path>`: Path to a Rust crate.
- `<path 1> <path 2>`: Multiple crate paths.

If a path doesn't include `src/`, assume it to be in the `src/redisearch_rs` directory. E.g. `numeric_range_tree` becomes `src/redisearch_rs/numeric_range_tree`.
If a path points to a directory, consider all Rust crates in that directory.

## Instructions 

Run

```bash
cargo llvm-cov test --manifest-path <crate_directory>/Cargo.toml --quiet --json 2>/dev/null | jq -r '"Uncovered Lines:",
(.data[0].files[] |
  select(.summary.lines.percent < 100) |
  .filename as $f |
  [.segments[] | select(.[2] == 0 and .[4] == true) | .[0]] |
  unique |
  if length > 0 then "\($f): \(join(", "))" else empty end
)'
```

to get the list of uncovered lines for each file in the target crate.

Overview

This skill finds which Rust source lines are not exercised by your Rust tests. It targets crates or folders and returns per-file lists of uncovered line numbers so you can prioritize test writing and improve coverage. It is designed for Rust projects embedded in larger C-based codebases or modules.

How this skill works

It runs cargo llvm-cov test for the specified crate manifest and parses the JSON report, filtering files whose line coverage is below 100%. For each such file it extracts segment start positions where execution count is zero and reports unique line numbers for uncovered segments. It supports single or multiple crate paths and a path-mapping convention for src/redisearch_rs subpaths.

When to use it

  • After running tests when you want to identify missing test coverage
  • Before merging a feature to ensure new code is covered
  • When hardening critical code paths in a Rust crate
  • When auditing third-party Rust crates included in your project

Best practices

  • Provide the exact crate path or manifest directory to avoid false negatives
  • Use the path convention: omit src/ if referring to crates under src/redisearch_rs (e.g., numeric_range_tree)
  • Run in a controlled environment where cargo llvm-cov and jq are installed
  • Pipe stderr to /dev/null to suppress non-JSON output and ensure jq can parse the report

Example use cases

  • Scan a single crate: point the skill to the crate directory containing Cargo.toml to list uncovered lines
  • Batch-scan multiple crates: pass multiple paths to get uncovered lines across crates in one run
  • Map short names to src/redisearch_rs: use crate short names to check nested crates without typing full paths
  • Triage tests after refactoring: quickly see which lines lost coverage after code changes

FAQ

What prerequisites are required to run this check?

Install cargo-llvm-cov and jq. The command relies on cargo llvm-cov producing JSON and jq to extract uncovered line numbers.

How are paths resolved when I pass a directory or short name?

If the argument lacks src/ it is treated as src/redisearch_rs/<name>. If you pass a directory, the tool inspects all Rust crates it finds in that directory and uses each crate's Cargo.toml manifest.