This file defines conventions and instructions to guide OpenAI Codex and other agents in contributing to this R package. It standardises formatting, documentation, testing, and pull request workflows.
| Folder | Purpose |
| ------------------ | ------------------------------------------------ |
| /R/
| R function scripts |
| /man/
| Auto-generated documentation from roxygen2 |
| /tests/testthat/
| Unit tests (testthat framework) |
| /vignettes/
| Tutorials and worked examples (built with knitr) |
| /data/
| Data objects for examples (.rda
, .rds
) |
| /inst/
| Miscellaneous files (e.g. extdata, configs) |
| /docs/
| Site output (e.g., pkgdown) |
Use snake_case
for object and function names.
Use 2-space indentation, no tabs.
Include roxygen2 documentation for every exported function.
Function structure:
r
#' Title of the function
#'
#' Description of what it does.
#'
#' @param arg1 Description of arg1
#' @return Description of return value
#' @export
my_function <- function(arg1) {
# main logic
}
Use styler::style_pkg()
and lintr::lint_package()
to enforce style.
Avoid <<-
, assign()
, and hidden state unless strictly necessary.
All new functions must include unit tests in /tests/testthat/
.
Run tests locally before committing:
Rscript -e "devtools::test(reporter = 'summary')"
Use covr
to monitor test coverage:
Rscript -e "covr::report()"
Ensure test coverage does not decrease for existing functions.
Always update documentation and verify build integrity before PRs.
# Regenerate documentation
Rscript -e "devtools::document()"
# Build the package tarball
R CMD build . --no-resave-data --compact-vignettes=gs+qpdf
# Run CRAN-like checks
R CMD check --no-manual --as-cran
Optional: rebuild vignettes manually
Rscript -e "devtools::build_vignettes()"
There is no package website
feature/<desc>
for new featuresbugfix/<desc>
for bug fixesrefactor/<desc>
for internal refactoring[Type] Summary of change
Examples:
[Fix] Handle NA inputs in calculate_rate()
[Feature] Add export_to_parquet() utility
Run all checks before requesting a review:
Rscript -e "styler::style_pkg()"
Rscript -e "lintr::lint_package()"
Rscript -e "devtools::check(manual = FALSE)"
Rscript -e "covr::report()"
All of the above must pass before merging.
DESCRIPTION
(Imports
or Suggests
)remotes::install_deps(dependencies = TRUE)
The repo uses GitHub Actions to:
R CMD check
pkgdown
siteIf modifying .github/workflows/
, test using:
act -j check # if act is installed for local testing
This AGENTS.md should be respected by OpenAI Codex or other automated agents when:
devtools::document()
)Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.