RPkgAgent
R Package Development Agent -- 7 specialized agents, 6 workflow commands, and 12 methodology skills for building production-quality R packages

A Claude Code plugin that guides you through the entire R package lifecycle -- from usethis::create_package() to devtools::submit_cran(). Built on best practices from R Packages (2e) by Hadley Wickham & Jenny Bryan.
Quick Start
1. Install the Plugin
/plugin marketplace add choxos/RPkgAgent
/plugin install r-package-development
2. Create a Package
/create-package
The agent will ask for your package name, purpose, author info, license, and dependencies, then scaffold the entire structure.
3. Add Functions, Tests, and Docs
/add-function
/run-check
/setup-website
/prepare-release
What It Does
| Stage | What the Agent Handles |
|---|
| Scaffold | DESCRIPTION, NAMESPACE, LICENSE, .Rbuildignore, .gitignore, test infrastructure |
| Code | R/ functions with roxygen2 docs, pkg::fun() imports, state management, ASCII-only source |
| Test | testthat 3e suites with fixtures, edge cases, error conditions, snapshots, skip patterns |
| Document | README with badges, vignettes (html_vignette), pkgdown site (Bootstrap 5), hex logo, NEWS.md, CITATION |
| Check | Systematic diagnosis and fix of all R CMD check errors, warnings, and notes toward 0/0/0 |
| Release | Version bumping, cran-comments.md, multi-platform checks (win-builder, R-hub, GHA), CRAN/Bioconductor submission |
Commands
| Command | Description | Agents Involved |
|---|
/create-package | Full package creation workflow: gather requirements, scaffold structure, add code, tests, docs, and run check | package-architect, scaffold-engineer, code-engineer, test-engineer, docs-engineer, check-doctor |
/add-function | Add a new exported or internal function with roxygen2 documentation, testthat tests, and working examples | code-engineer, test-engineer |
/add-data | Bundle a dataset: create data-raw/ preparation script, generate .rda file, write R/data.R documentation | code-engineer, docs-engineer |
/setup-website | Configure pkgdown with _pkgdown.yml (Bootstrap 5, light/dark toggle, organized reference), hex logo, and GitHub Actions deployment workflow | docs-engineer |
/run-check | Run devtools::check(), categorize issues (errors > warnings > notes), apply targeted fixes, re-check until 0/0/0 | check-doctor |
/prepare-release | Pre-submission checklist, version bump, NEWS.md update, cran-comments.md, multi-platform validation, submission guidance | release-manager |
Agents
package-architect (haiku) -- Router
Entry point for all tasks. Gathers requirements through structured questions (package name, purpose, author info, license, dependencies, target repository) and delegates to the right specialist. Coordinates multi-step workflows across agents.
scaffold-engineer (sonnet) -- Package Skeleton
Creates the complete package structure from scratch:
DESCRIPTION with proper Authors@R (person()), Title Case title, formatted Description
LICENSE + LICENSE.md (MIT, GPL-3, Apache-2.0, CC0)
R/pkgname-package.R with "_PACKAGE" documentation and globalVariables()
.Rbuildignore, .gitignore with standard patterns
tests/testthat.R + tests/testthat/helper-data.R
- Git initialization
code-engineer (sonnet) -- R Code
Writes R functions following strict package rules:
- No
library(), require(), source(), :::, T/F, non-ASCII, setwd()
pkg::fun() for Imports, requireNamespace() for Suggests
- Complete roxygen2:
@param for every argument, @returns, @export, @examples
- State management with
withr::local_*() or on.exit()
utils::globalVariables() for data.table/ggplot2 NSE
test-engineer (sonnet) -- Testing
Creates testthat 3rd edition test suites:
test-*.R files mirroring R/ structure
- Happy path, edge cases (empty, single, large, all-NA), error conditions
expect_equal(), expect_error(), expect_snapshot(), expect_s3_class()
skip_if_not_installed(), skip_on_cran() for conditional tests
- Shared fixtures in
helper-data.R
docs-engineer (sonnet) -- Documentation
Produces all package documentation: