/skills:test-coveragefrom skills
Measures R package test coverage using covr, exports standard Cobertura XML format, and identifies untested lines or low-coverage functions.
Ships in skills. 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.
None: SKILL.md is the whole skill.
Use this skill to evaluate code coverage for R packages. It executes covr::package_coverage() in a subprocess, converts the output to Cobertura XML using covr::to_cobertura(), and parses the results to evaluate package quality against target coverage thresholds.
Run the following R code from the package root directory:
suppressPackageStartupMessages(library(covr));
cov <- package_coverage();
to_cobertura(cov, filename = "coverage.xml");
cat(sprintf("Overall Coverage: %.2f%%\n", percent_coverage(cov)))
How to run it: Prefer Posit Assistant's live R session (its built-in R tool) so it reuses your active console. Coverage is the one exception where a fresh, isolated process is often preferable — running package_coverage() in a clean R process avoids stale loaded objects skewing results. So if you are outside Positron/RStudio, or want an isolated run, fall back to the terminal:
Rscript -e 'covr::to_cobertura(covr::package_coverage(), filename = "coverage.xml")'
Note: For large packages or slow test suites, run
covr::file_coverage()on modified source files rather than full package coverage during quick iterative loops.
Read coverage.xml to inspect class-level and line-level coverage.
line-rate="..." in the root <coverage> tag (e.g., line-rate="0.852" = 85.2% coverage).<line number="X" hits="0"/> under specific <class filename="..."> blocks.When summarizing results for the user or workflow:
Threshold Checks:
Exclusions & Edge Cases:
R/cpp11.R, R/RcppExports.R) or legacy C/C++ code unless explicitly requested.# nocov start ... # nocov end) are used appropriately.TDD Feedback Loop:
hits="0" added or modified in the current branch.tests/testthat/.covr::file_coverage(
source_files = "R/my_function.R",
test_files = "tests/testthat/test-my_function.R"
)
If the package requires excluding specific directories (e.g., legacy scripts):
cov <- covr::package_coverage(line_exclusions = list("R/deprecated.R"))
covr::to_cobertura(cov, filename = "coverage.xml")
Report coverage back to the user or system with the following summary structure:
XX.X%PASS / WARN / FAILR/filename.R: Lines 42-50 (function_name())R/utils.R: Lines 12, 18 (helper_fn())testthat blocks to add.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub pbulsink/skills --plugin skills16 skills in this plugin
/agent-md-refactorRefactor bloated AGENTS.md, CLAUDE.md, or similar agent instruction files to follow progressive disclosure principles. Splits monolithic files into organized, linked documentation./app-screenshotThis skill should be used when capturing screenshots of R Shiny apps for documentation — vignettes, READMEs, and app tours. Covers driving a live app with shinytest2's AppDriver, isolating demo state from real data, and producing numbered PNGs ready to embed./documentThis skill should be used when documentation for R package functions is requested or required.