Testing R Packages
Automates R package testing workflows, ensuring code quality and reproducibility using posit-dev's best practices.
Install on your platform
We auto-selected Claude Code based on this skill’s supported platforms.
Run in terminal (recommended)
claude mcp add testing-r-packages npx -- -y @trustedskills/testing-r-packages
Or manually add to ~/.claude/settings.json
{
"mcpServers": {
"testing-r-packages": {
"command": "npx",
"args": [
"-y",
"@trustedskills/testing-r-packages"
]
}
}
}Requires Claude Code (claude CLI). Run claude --version to verify your install.
About This Skill
What it does
This skill automates R package testing workflows using the testthat framework, following modern best practices for ensuring code quality and reproducibility. It streamlines the process of setting up tests, organizing test files, and running different levels of tests (micro, mezzo, and macro) within an R package development environment. The skill helps developers write robust and well-documented tests for their R packages.
When to use it
- When initializing a new R package and wanting to set up testing infrastructure from the start.
- During R package development to ensure individual functions or components behave as expected.
- Before submitting an R package for publication, to verify its overall functionality and adherence to coding standards.
- For behavior-driven development (BDD) workflows using
describe()andit()blocks.
Key capabilities
- Initializes a
testthattesting environment with the commandusethis::use_testthat(3). - Organizes test files mirroring the package's source code structure.
- Supports helper functions (
helper-*.R), setup scripts (setup-*.R), and static data fixtures (fixtures/). - Provides both standard
test_that()syntax and behavior-driven development (BDD) withdescribe()andit(). - Offers different testing scales: micro (interactive), mezzo (single file), and macro (full suite).
- Includes core expectations for equality, errors, warnings, messages, and pattern matching.
Example prompts
- "Initialize a testthat environment in my R package."
- "Create a test file for the 'foofy' function."
- "Run the full test suite for this R package."
Tips & gotchas
- This skill is specifically designed for testing R packages using
testthatversion 3 or higher. - Test descriptions should focus on describing expected behavior, not implementation details.
- Use
devtools::load_all()for interactive development and testing of individual components.
Tags
TrustedSkills Verification
Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.
Security Audits
| Gen Agent Trust Hub | Pass |
| Socket | Pass |
| Snyk | Pass |
🌐 Community
Passed automated security scans.