r-tidyverse-style
Installation
SKILL.md
Tidyverse style for R package code
Prefer the package's established conventions over the tidyverse guide unless the user requests a migration. Style is not proof of correctness; keep public behavior unchanged during cleanup.
Work through the task
- Set scope and mode. For a review, inspect the requested files or diff without editing. For cleanup, change only the agreed scope. When writing new code, inspect neighboring
R/files, tests, and style configuration before choosing conventions. CheckDESCRIPTIONfor supported R versions and dependencies when relevant. - Protect interfaces. Before renaming or reorganizing code, check exports, roxygen/NAMESPACE, S3/S4 methods, callers, tests, and user-visible conditions. Don't treat a public rename, changed default, error, return value, dependency, or supported R version as cosmetic.
- Triage observations. Distinguish style, maintainability, and possible bugs. For generated-looking code, investigate comments that restate code, duplicate checks or helpers, pointless wrappers, speculative
tryCatch()fallbacks, and docs or tests that contradict behavior. Confirm against callers and tests before removing anything; code provenance alone proves nothing. These are review heuristics, not tidyverse rules. - Change in risk order. Format scoped files first. Then simplify only verified redundancy, retaining comments about intent or constraints. Propose behavior-sensitive changes (pipe conversions, evaluation order, control flow, public names, error text) separately; make them only if the user has authorized that scope, with focused tests. Don't turn a style pass into an unrequested refactor.
- Verify and report. Inspect the diff; run relevant focused tests and broader package checks when warranted. For review-only work, give prioritized findings with file/line references and suggested edits, without modifying files. For edits, state what changed, what was deferred, and which checks actually ran. Don't claim a style pass is a correctness or security review.
Style rules
The rules below selectively paraphrase the tidyverse style guide (source, consulted at commit 2aed77e); this is not an official tidyverse skill. The links are citations, not required reading. Open a relevant chapter only when a rule needs clarification or the user requests verification, never all chapters by default.
Syntax and names
Source: Syntax.