No slash command · from rust-plugin
Runs Rust code coverage via LLVM instrumentation. Supports HTML, LCOV, JSON, and Cobertura reports with CI threshold enforcement.
Ships in rust-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
cargo-llvm-cov provides accurate code coverage for Rust using LLVM's instrumentation-based coverage. It supports multiple output formats and integrates seamlessly with CI platforms.
| Use this skill when... | Use sibling skill instead when... |
|---|---|
| Measuring line / branch coverage with LLVM instrumentation | Just running tests fast in parallel -- use cargo-nextest |
| Generating HTML / lcov / codecov reports | Auditing unused dependencies -- use cargo-machete |
| Enforcing coverage thresholds in CI | Configuring lint rules -- use clippy-advanced |
| Wiring codecov.io or coveralls upload | Writing the tests themselves -- use rust-development |
# Install cargo-llvm-cov
cargo install cargo-llvm-cov
# Verify installation
cargo llvm-cov --version
# Install llvm-tools-preview component (required)
rustup component add llvm-tools-preview
# Run tests and generate coverage
cargo llvm-cov
# Generate HTML report
cargo llvm-cov --html
open target/llvm-cov/html/index.html
# Generate LCOV report
cargo llvm-cov --lcov --output-path target/llvm-cov/lcov.info
# Generate JSON report
cargo llvm-cov --json --output-path target/llvm-cov/coverage.json
# Show coverage as text summary
cargo llvm-cov --text
# Show coverage for specific files
cargo llvm-cov --text -- --show-instantiations
# HTML report (interactive, line-by-line)
cargo llvm-cov --html --open
# LCOV format (compatible with many tools)
cargo llvm-cov --lcov --output-path lcov.info
# JSON format (programmatic analysis)
cargo llvm-cov --json --output-path coverage.json
# Cobertura XML (for Jenkins, GitLab)
cargo llvm-cov --cobertura --output-path cobertura.xml
# Text summary (terminal output)
cargo llvm-cov --text
# Multiple formats simultaneously
cargo llvm-cov --html --lcov --output-path lcov.info
# Fail if coverage is below threshold
cargo llvm-cov --fail-under-lines 80
# Multiple threshold types
cargo llvm-cov --fail-under-lines 80 --fail-under-functions 75
# Available threshold types
cargo llvm-cov --fail-under-lines 80 # Line coverage
cargo llvm-cov --fail-under-regions 80 # Region coverage
cargo llvm-cov --fail-under-functions 75 # Function coverage
Create a script or Makefile for consistent thresholds:
# Makefile
.PHONY: coverage coverage-ci
coverage:
cargo llvm-cov --html --open
coverage-ci:
cargo llvm-cov \
--fail-under-lines 80 \
--fail-under-functions 75 \
--lcov --output-path lcov.info
Or use a shell script:
#!/usr/bin/env bash
# scripts/coverage.sh
set -euo pipefail
COVERAGE_THRESHOLD="${COVERAGE_THRESHOLD:-80}"
cargo llvm-cov \
--fail-under-lines "$COVERAGE_THRESHOLD" \
--lcov --output-path target/llvm-cov/lcov.info \
--html
echo "Coverage threshold: $COVERAGE_THRESHOLD% (lines)"
Branch coverage requires Rust nightly:
# Install nightly toolchain
rustup toolchain install nightly
rustup component add llvm-tools-preview --toolchain nightly
# Run with branch coverage
cargo +nightly llvm-cov --branch --html
# Branch coverage with thresholds
cargo +nightly llvm-cov \
--branch \
--fail-under-lines 80 \
--fail-under-branches 70
# rust-toolchain.toml
[toolchain]
channel = "nightly"
components = ["llvm-tools-preview"]
# Allows using `cargo llvm-cov --branch` without +nightly
# Use nextest as test runner
cargo llvm-cov nextest --html
# With nextest profile
cargo llvm-cov nextest --profile ci --lcov --output-path lcov.info
# All nextest options work
cargo llvm-cov nextest -E 'not test(slow_)' --html
# .github/workflows/coverage.yml
name: Coverage
on: [push, pull_request]
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Install the pinned toolchain
run: rustup toolchain install --no-self-update
- name: Add llvm-tools to the pinned toolchain
run: rustup component add llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/[email protected]
with:
tool: cargo-llvm-cov
- name: Generate coverage
run: cargo llvm-cov --all-features --lcov --output-path lcov.info
- name: Upload to codecov
uses: codecov/[email protected]
with:
files: lcov.info
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
Same workflow as Codecov, with the upload step swapped for coverallsapp/github-action (path-to-lcov: lcov.info): REFERENCE.md.
# Exclude generated code
cargo llvm-cov --ignore-filename-regex '.*generated.*'
# Exclude test files
cargo llvm-cov --ignore-filename-regex '.*test.*'
# Multiple patterns
cargo llvm-cov \
--ignore-filename-regex '.*generated.*' \
--ignore-filename-regex '.*mock.*'
# Coverage for all workspace members
cargo llvm-cov --workspace --html
# Coverage for specific packages
cargo llvm-cov -p my_lib -p my_app --html
# Exclude specific packages
cargo llvm-cov --workspace --exclude integration_tests --html
# Coverage with all features
cargo llvm-cov --all-features --html
# Coverage with specific features
cargo llvm-cov --features async,tls --html
# Coverage without default features
cargo llvm-cov --no-default-features --html
A full coverage workflow (pinned toolchain, rust-cache, nextest, --fail-under-lines $COVERAGE_THRESHOLD, Codecov upload, HTML report artifact): REFERENCE.md.
# Clean previous coverage data
cargo llvm-cov clean
# Clean and run fresh coverage
cargo llvm-cov clean && cargo llvm-cov --html
# Include doctests in coverage
cargo llvm-cov --doc --html
# Doctests with workspace
cargo llvm-cov --workspace --doc --html
# Note: doctests run in separate context, may not integrate perfectly
| Feature | cargo-llvm-cov | cargo-tarpaulin |
|---|---|---|
| Backend | LLVM (compiler) | ptrace (runtime) |
| Accuracy | Excellent | Good |
| Performance | Fast | Slower |
| Branch coverage | Yes (nightly) | Yes |
| Stability | Stable | Sometimes unstable |
| Platform support | All Rust targets | Linux, limited macOS |
| Setup complexity | Simple | Simple |
Use with nextest for faster execution:
cargo llvm-cov nextest --all-features --html
Enforce coverage thresholds in CI:
cargo llvm-cov --fail-under-lines 80
Generate multiple formats for different tools:
cargo llvm-cov --html --lcov --output-path lcov.info
Exclude generated code from coverage:
cargo llvm-cov --ignore-filename-regex '.*generated.*'
Cache coverage dependencies in CI:
- uses: Swatinem/[email protected]
Use branch coverage on nightly for critical code:
cargo +nightly llvm-cov --branch --fail-under-branches 70
Clean coverage data between runs:
cargo llvm-cov clean
Missing llvm-tools-preview:
rustup component add llvm-tools-preview
Coverage seems inaccurate:
# Clean and regenerate
cargo llvm-cov clean
cargo clean
cargo llvm-cov --html
Nightly features not working:
rustup toolchain install nightly
rustup component add llvm-tools-preview --toolchain nightly
cargo +nightly llvm-cov --branch --html
Slow coverage generation:
# Use nextest for parallel execution
cargo llvm-cov nextest --html
Doctests not included:
# Run with --doc flag
cargo llvm-cov --doc --html
What SKILL.md sets; muted values are Claude Code's defaults
10 skills in this plugin
/cargo-distcargo-dist (dist) release binaries for a Rust CLI. Use when setting up dist-workspace.toml, pairing dist with release-please, or publishing a Homebrew formula./cargo-generatecargo-generate: scaffold a project from a git template repo. Use when bootstrapping a Rust or Bevy project from a template, or authoring one./cargo-machetecargo-machete: detect unused Rust dependencies. Use when auditing Cargo.toml, optimizing build times, or cleaning up dependency bloat.npx claudepluginhub laurigates/claude-plugins --plugin rust-pluginOther plugins' skills for the same job