From rap
Scaffold a new RAP-compliant R project following UK Government Analysis Function methodology
How this skill is triggered — by the user, by Claude, or both
Slash command
/rap:rap-initThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
```text
$ARGUMENTS
You are scaffolding a new R project that follows the UK Government Reproducible Analytical Pipelines (RAP) methodology. The generated project will immediately satisfy all Baseline RAP requirements and provide scaffolding toward Silver.
Extract the project name from $ARGUMENTS.
PROJECT_NAME.Inspect the current working directory for existing files:
ls -A
DESCRIPTION, or renv.lock, warn the user that files exist and ask for confirmation before proceeding..git/ already exists, note this — skip git init later.Create the RAP project directories:
mkdir -p R data output tests/testthat reports
For each template file listed below, read the template from the plugin's template directory, replace all occurrences of {{PROJECT_NAME}} with the actual project name, and write the result to the target path.
| Template Source | Target Path |
|---|---|
plugins/rap/templates/r-project/DESCRIPTION.template | DESCRIPTION |
plugins/rap/templates/r-project/README.md.template | README.md |
plugins/rap/templates/r-project/.gitignore.template | .gitignore |
plugins/rap/templates/r-project/R/01_read_data.R.template | R/01_read_data.R |
plugins/rap/templates/r-project/R/02_process_data.R.template | R/02_process_data.R |
plugins/rap/templates/r-project/R/03_analyse_data.R.template | R/03_analyse_data.R |
plugins/rap/templates/r-project/R/04_create_output.R.template | R/04_create_output.R |
plugins/rap/templates/r-project/data/README.md.template | data/README.md |
Additionally, create the RStudio project file:
File: PROJECT_NAME.Rproj
Version: 1.0
RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: No
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
Run the following commands to initialise the project environment:
Git initialisation (only if .git/ does not already exist):
git init
renv initialisation (only if renv.lock does not already exist):
Rscript -e "renv::init(bare = TRUE)"
Use
bare = TRUEso renv creates the infrastructure without trying to discover and install packages from the skeleton scripts. The user will add packages incrementally.
If R is not available on the system, skip renv::init() and inform the user they should run it manually when R is available.
After all files are created, display a summary:
## RAP Project Created: PROJECT_NAME
### Files created
- `DESCRIPTION` — R package metadata
- `README.md` — Project documentation with reproduction steps
- `.gitignore` — Version control exclusions (protects sensitive data)
- `PROJECT_NAME.Rproj` — RStudio project file
- `R/01_read_data.R` — Data ingestion functions
- `R/02_process_data.R` — Data cleaning and transformation
- `R/03_analyse_data.R` — Statistical analysis
- `R/04_create_output.R` — Output generation
- `data/README.md` — Data provenance documentation
### Directories created
- `R/` — Analysis functions (numbered for pipeline order)
- `data/` — Input data (excluded from Git)
- `output/` — Generated outputs (excluded from Git)
- `tests/testthat/` — Unit tests
- `reports/` — R Markdown reports
### RAP Compliance
Your project now satisfies these **Baseline RAP** requirements:
- ✓ **B1**: Code in an open-source language (R)
- ✓ **B2**: Version controlled with Git
- ✓ **B3**: README with reproduction steps
To complete Baseline, you also need:
- ○ **B4**: Peer review (open a PR for review)
- ○ **B5**: Publish openly (push to GitHub/GitLab)
### Next steps
1. Edit `data/README.md` to document your data sources
2. Update `R/01_read_data.R` with your actual data ingestion code
3. Run `/rap-check` to audit your RAP compliance level
4. Run `/rap-test` to set up unit testing (Silver requirement)
5. Run `/rap-pipeline` to configure {targets} build automation
Handle these situations gracefully:
Git not installed: If git init fails with "command not found", display:
Git is not installed. Install Git from https://git-scm.com/ then run `git init` manually.
Your project files have been created successfully — Git can be added later.
R not installed: If Rscript is not available, skip renv::init() and display:
R is not installed or not on PATH. Install R from https://cran.r-project.org/
After installing R, run: Rscript -e "renv::init(bare = TRUE)"
renv not installed: If renv::init() fails with "there is no package called 'renv'", display:
The {renv} package is not installed. Run in R:
install.packages("renv")
renv::init(bare = TRUE)
Permission errors: If file creation fails, display the specific error and suggest checking directory permissions: ls -la .
packrat detected: If packrat/ directory exists, warn:
This project uses {packrat} for dependency management. Consider migrating
to {renv} which is its successor: https://rstudio.github.io/renv/articles/packrat.html
Skipping renv::init() to avoid conflicts.
Non-empty directory with conflicts: If existing files would be overwritten, list them and ask for confirmation before proceeding. Never silently overwrite.
Include this brief context at the end of your response:
What is RAP? Reproducible Analytical Pipelines apply software engineering practices to statistical production. Developed by the UK Government Analysis Function, RAP ensures official statistics are produced transparently, reproducibly, and efficiently.
Learn more:
npx claudepluginhub ivyleavedtoadflax/rapskill --plugin rapScaffolds a new R package with DESCRIPTION, NAMESPACE, testthat, roxygen2, renv, Git, and GitHub Actions CI. Follows usethis conventions. For starting packages from scratch or converting scripts.
Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.