R Package Skill Creation
Overview
Generates a new r-{package} skill from an R package's documentation. Core loop: capture intent → gather docs → draft skill → run test cases (with-skill + baseline in parallel) → grade → iterate until pass_rate >= 90% and no improvement for 2 iterations → optimize description.
When NOT to Use
- Package is simple/well-known (tidyverse core, base R)
- One-off usage -- just read the help
- A skill already exists that references this package
Ask Where to Install
Always ask before creating files. No silent defaults. If the user already specified a path, use it. See references/installation-paths.md for the prompt and agent-specific paths.
R-Specific Skill Structure
{install-path}/r-{package}/
SKILL.md # <500 words
references/
API.md # REQUIRED: Complete CRAN reference manual
vignette-name.md # Include all CRAN vignettes
references/API.md is required for every package skill.
- Include every CRAN vignette as
references/{vignette}.md.
- Each generated SKILL.md must tell its reader: "Read
references/API.md before writing code."
- Quick Reference table must show ALL important parameters, including optional/advanced. Mark tiers: required (no mark),
(opt) optional, (adv) advanced. Never hide parameters that affect performance or output size (zoom levels, batch sizes, etc.).
Workflow
- Capture intent. Ask what the user needs the skill to do, edge cases, input/output formats, and what makes it a success. Don't fetch docs until this is clear.
- Gather docs. Fetch CRAN reference, vignettes, and (if available) btw tools. See
references/doc-gathering.md.
- Draft. Write SKILL.md,
references/API.md, and vignettes.
- Test. Spawn with-skill and baseline subagents in the same turn (parallel, not sequential). Grade outputs. Aggregate into
benchmark.json. See references/testing.md.
- Iterate. If
pass_rate < 90% or it's still improving, analyze failures, edit the skill, rerun. Remove guidance transcripts show agents ignoring (YAGNI). Stop when pass_rate >= 90% AND no improvement for 2 iterations.
- Optimize the description last. See
references/description-optimization.md.
Description Recognition Tokens
Descriptions MUST include library({pkg}) and {pkg}:: tokens plus file-extension and domain triggers. Without the package-name tokens, descriptions that read as action-oriented ("Use when creating interactive maps") miss user prompts that contain library(mapgl) or mapgl::.
# Good
description: Use when code loads or uses freestiler, working with .pmtiles files, or preparing tiles for mapgl/MapLibre in R
# Bad: no recognition tokens
description: Use when creating PMTiles vector tilesets from large spatial datasets
See references/description-optimization.md for the train/held-out test method.
R Validators
Domain assertions call R validators in lib/r-validators/ at repo root via Rscript:
plot-validator.R -- ggplot2/mapgl visualizations
spatial-validator.R -- sf/spatial operations
html-validator.R -- flextable/Shiny outputs
numerical-validator.R -- collapse/regression results
Each returns JSON (valid, message, domain fields) for use as grading evidence.
R Execution Patterns
- Default:
Rscript -e "code" or mcptools MCP.
- Create script files only if code is long-running or the user asks.
- If unavoidable: prefix
temp_*.R or use tempfile(), clean up with on.exit(unlink(...)) or file.remove().
Common Mistakes
| Mistake |
Fix |
Missing references/API.md |
REQUIRED. Extract from CRAN reference manual. |
| Missing vignettes |
Include every CRAN vignette as references/*.md. |
| Quick Reference hides parameters |
Show ALL params that affect performance/output. Mark optional with (opt). |
| Running with-skill first, baseline later |
Spawn both in the same turn so timing is comparable. |
| Assertion schema drift |
Use text / passed / evidence in grading.json, not name / met / details. |
| Description too generic |
Include library({pkg}) and {pkg}:: tokens. |
| Skipping baseline |
Without a baseline, you can't tell whether the skill helped. |
| Optimizing description before skill works |
Fix functionality first; tune triggering last. |
1---2name: r-package-skill3description: Use when creating, editing, or validating R package skills (library(pkg), pkg::), or gathering R package documentation (CRAN, pkgdown, vignettes) to generate a skill4---56# R Package Skill Creation78## Overview910Generates a new `r-{package}` skill from an R package's documentation. Core loop: capture intent → gather docs → draft skill → run test cases (with-skill + baseline in parallel) → grade → iterate until pass_rate >= 90% and no improvement for 2 iterations → optimize description.1112## When NOT to Use1314- Package is simple/well-known (tidyverse core, base R)15- One-off usage -- just read the help16- A skill already exists that references this package1718## Ask Where to Install1920Always ask before creating files. No silent defaults. If the user already specified a path, use it. See `references/installation-paths.md` for the prompt and agent-specific paths.2122## R-Specific Skill Structure2324```25{install-path}/r-{package}/26 SKILL.md # <500 words27 references/28 API.md # REQUIRED: Complete CRAN reference manual29 vignette-name.md # Include all CRAN vignettes30```3132- `references/API.md` is required for every package skill.33- Include every CRAN vignette as `references/{vignette}.md`.34- Each generated SKILL.md must tell its reader: "Read `references/API.md` before writing code."35- Quick Reference table must show ALL important parameters, including optional/advanced. Mark tiers: required (no mark), `(opt)` optional, `(adv)` advanced. Never hide parameters that affect performance or output size (zoom levels, batch sizes, etc.).3637## Workflow38391. **Capture intent.** Ask what the user needs the skill to do, edge cases, input/output formats, and what makes it a success. Don't fetch docs until this is clear.402. **Gather docs.** Fetch CRAN reference, vignettes, and (if available) btw tools. See `references/doc-gathering.md`.413. **Draft.** Write SKILL.md, `references/API.md`, and vignettes.424. **Test.** Spawn with-skill and baseline subagents **in the same turn** (parallel, not sequential). Grade outputs. Aggregate into `benchmark.json`. See `references/testing.md`.435. **Iterate.** If `pass_rate < 90%` or it's still improving, analyze failures, edit the skill, rerun. Remove guidance transcripts show agents ignoring (YAGNI). Stop when `pass_rate >= 90%` AND no improvement for 2 iterations.446. **Optimize the description last.** See `references/description-optimization.md`.4546## Description Recognition Tokens4748Descriptions MUST include `library({pkg})` and `{pkg}::` tokens plus file-extension and domain triggers. Without the package-name tokens, descriptions that read as action-oriented ("Use when creating interactive maps") miss user prompts that contain `library(mapgl)` or `mapgl::`.4950```yaml51# Good52description: Use when code loads or uses freestiler, working with .pmtiles files, or preparing tiles for mapgl/MapLibre in R5354# Bad: no recognition tokens55description: Use when creating PMTiles vector tilesets from large spatial datasets56```5758See `references/description-optimization.md` for the train/held-out test method.5960## R Validators6162Domain assertions call R validators in `lib/r-validators/` at repo root via `Rscript`:6364- `plot-validator.R` -- ggplot2/mapgl visualizations65- `spatial-validator.R` -- sf/spatial operations66- `html-validator.R` -- flextable/Shiny outputs67- `numerical-validator.R` -- collapse/regression results6869Each returns JSON (`valid`, `message`, domain fields) for use as grading evidence.7071## R Execution Patterns7273- Default: `Rscript -e "code"` or mcptools MCP.74- Create script files only if code is long-running or the user asks.75- If unavoidable: prefix `temp_*.R` or use `tempfile()`, clean up with `on.exit(unlink(...))` or `file.remove()`.7677## Common Mistakes7879| Mistake | Fix |80|---------|-----|81| Missing `references/API.md` | REQUIRED. Extract from CRAN reference manual. |82| Missing vignettes | Include every CRAN vignette as `references/*.md`. |83| Quick Reference hides parameters | Show ALL params that affect performance/output. Mark optional with `(opt)`. |84| Running with-skill first, baseline later | Spawn both in the same turn so timing is comparable. |85| Assertion schema drift | Use `text` / `passed` / `evidence` in `grading.json`, not `name` / `met` / `details`. |86| Description too generic | Include `library({pkg})` and `{pkg}::` tokens. |87| Skipping baseline | Without a baseline, you can't tell whether the skill helped. |88| Optimizing description before skill works | Fix functionality first; tune triggering last. |