Agent skill
cargo-coverage
Generate per-file coverage reports using cargo llvm-cov with formatted output. Requires tests to run first with coverage enabled. Trigger when asked for code coverage metrics or reports.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/cargo-coverage
SKILL.md
Cargo Coverage
Overview
Generate detailed, per-file coverage reports using cargo llvm-cov with JSON output formatted into readable tables. Provides function, line, and region coverage percentages.
Quick Start
- Run tests with coverage enabled first (see
cargo-testskill). - Execute
skills/cargo-coverage/scripts/run_coverage.shfrom repository root. - Review the coverage table output showing per-file statistics.
Workflow
- Generate coverage data: Run tests with
cargo llvm-cov nextestorcargo llvm-cov test. - Extract report:
cargo llvm-cov report --json --summary-onlyoutputs coverage in JSON format. - Format output: Pipe through
jqandxanto create readable tables. - Environment:
NO_COLOR=1- Disables color outputCARGO_TERM_COLOR=never- Ensures cargo output is colorless
Coverage Metrics
- Functions: Percentage of functions executed during tests
- Lines: Percentage of code lines covered
- Regions: Percentage of code regions (branches, conditionals) covered
Best Practices
- Run tests first: Coverage data is generated by running tests with instrumentation.
- Use colorless output: Keep
NO_COLOR=1for CI/log parsing. - Workspace scope: Report includes all workspace members.
- Run from root: Execute from repository root for correct file path resolution.
- Rerun after changes: Regenerate coverage after modifying tests or source code.
Common Commands
Generate and view coverage report
cargo llvm-cov nextest --workspace --all-features
cargo llvm-cov report --json --summary-only | jq
Coverage with specific format
cargo llvm-cov report --lcov --output-path coverage.lcov
cargo llvm-cov report --html
Failure Handling
- No coverage data: Run tests with coverage enabled first.
- Missing tools: Install
jqandxanvia package manager or cargo. - Path errors: Ensure running from repository root directory.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?