cran-audit
Audit an R package against CRAN Repository Policy and submission requirements. Produces a gap report with Critical (must fix), Warnings (should fix), and pass/fail assessment per requirement type. Offers automated fixes where possible.
- License 许可
- MIT
- 最近更新
- 2026-10-23
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- cran-audit
- description
- Audit an R package against CRAN Repository Policy and submission requirements. Produces a gap report with Critical (must fix), Warnings (should fix), and pass/fail assessment per requirement type. Offers automated fixes where possible.
- argument-hint
- [package path]
03 SKILL.md 正文
CRAN Submission Audit
Audit an R package against CRAN Repository Policy requirements and produce a structured gap report. This skill evaluates package structure, DESCRIPTION metadata, documentation, code quality, and test coverage against the full CRAN checklist.
Workflow
1. Locate the Package
Identify the R package to audit. Look for DESCRIPTION file in the current working directory or a specified path. If no R package is found, ask the user which package to audit.
1b. Load User Config
Read .claude/pub-pipeline.local.md if it exists (Read tool). Extract author metadata and package context from YAML frontmatter. If the file is missing, inform the user and offer to create one from the template at ${CLAUDE_PLUGIN_ROOT}/docs/user-config-template.md.
1c. Verify Dependency Availability
Before running the full audit, check that all dependencies are available on CRAN (Bash tool):
- Parse
Imports,Depends, andLinkingTofields fromDESCRIPTION - For each dependency that is not a base or recommended package, verify it exists on CRAN:
Rscript -e 'ap <- available.packages(); cat("PKG_NAME" %in% rownames(ap))'
- For dependencies with version requirements (e.g.,
pkg (>= 2.0)), verify the requirement is satisfiable:
Rscript -e 'ap <- available.packages(); cat(ap["PKG_NAME", "Version"])'
Compare the available version against the minimum required version.
If any dependency is not on CRAN, flag it as a hard blocker in the gap report and stop here: the package cannot pass R CMD check --as-cran until all dependencies are available. Recommend the user publish the missing dependency first or switch to a CRAN-available alternative.
2. Gather Package State
Run these checks in parallel where possible:
Regenerate documentation (Bash tool):
Run Rscript -e 'devtools::document()' to ensure NAMESPACE and man/ files are current before auditing them. This prevents false negatives from stale roxygen output.
Package metadata (Read tool):
- Read
DESCRIPTION: check all required fields - Read
NAMESPACE: verify auto-generation by roxygen2 - Read
LICENSEorLICENSE.md: verify OSI-approved license - Check for
NEWS.md,cran-comments.md,README.md
Code quality (Grep/Glob tools):
- Search for
q()calls in R code - Search for
.Internal(),:::accessing base internals - Search for writes outside
tempdir()/tools::R_user_dir() - Check that Suggested packages are used conditionally (
if (requireNamespace(...))) - Verify no binary executables in source
- Search for
options()orpar()calls that don't restore state viaon.exit()orwithr - Run
urlchecker::url_check()to verify all URLs are valid and HTTPS
Documentation (Grep/Glob tools):
- Check all exported functions have
@returnsroxygen tag - Check all exported functions have
@examplesroxygen tag - Verify
man/directory exists with.Rdfiles
R CMD check (Bash tool):
cd /path/to/package && Rscript -e 'devtools::check(args = "--as-cran")'
Test coverage (Bash tool):
cd /path/to/package && Rscript -e 'covr::package_coverage()'
3. Evaluate Against Checklist
Score each item from the CRAN checklist as PASS, FAIL, or WARN. Consult the full checklist in ${CLAUDE_PLUGIN_ROOT}/docs/cran-reference.md for detailed requirements.
Key categories to evaluate:
| Category | Key Checks |
|---|---|
| DESCRIPTION | Title case, no period, informative Description, Authors@R with roles, valid License |
| Dependencies | Imports from CRAN/Bioconductor only, conditional Suggests usage |
| Code behavior | No q(), no .Internal, no writing outside tempdir, no global env modification |
| Documentation | All exports have @returns and @examples, vignettes build |
| Examples | \dontrun{} only for truly non-runnable code; prefer \donttest{} for slow examples (still run by --as-cran since R 4.0.0, so they must pass) |
| Side effects | options()/par() restored via on.exit() or withr; no persistent state changes |
| Size | Tarball ideally <10MB ("if possible"), data and docs each <5MB as a general rule, examples run in seconds |
| Cross-platform | Portable code, no OS-specific assumptions |
| Testing | R CMD check clean (0E/0W), notes explained |
| URLs | All URLs valid and using HTTPS |
4. Produce Gap Report
Format the report as:
# CRAN Audit Report: {package name} v{version}
## Summary
- **Status**: READY / NEEDS WORK / NOT READY
- **Score**: X/Y checks passed
- **Blockers**: N critical issues
## Critical (Must Fix)
1. [Issue description] ([file:line]): [how to fix]
## Warnings (Should Fix)
1. [Issue description] ([file:line]): [recommendation]
## Passed
- [Check name] ✓
## R CMD Check Results
[Paste relevant output]
## Recommended Next Steps
1. [Ordered list of actions]
5. Offer to Fix
After presenting the report, offer to fix issues that can be automated:
- Add missing
@returnstags - Add
cran-comments.mdif missing - Fix Title/Description formatting
- Add conditional
requireNamespace()checks - Create
NEWS.mdif missing - Replace
\dontrun{}with\donttest{}where appropriate
Reference Files
For the complete CRAN policy checklist and submission workflow, consult:
${CLAUDE_PLUGIN_ROOT}/docs/cran-reference.md: Full CRAN Repository Policy reference with pre-submission checklist, submission workflow, and common rejection reasons
Important Notes
- NAMESPACE is auto-generated by roxygen2: never edit manually. Run
devtools::document()after any roxygen changes. R CMD check --as-cranis the gold standard. If it passes with 0E/0W/0N, the package is very likely to be accepted.- First-time submissions face heightened scrutiny. The Description field is especially important.
- CRAN reviewers are volunteers. Respect their time by fixing all automated issues before submission.
04 同仓库更多 Skills
worldsmith-methodology
Use when working in a project with a worldbuilding documentation ecosystem (docs/ or lore/ directory). Provides the documentation-first methodology: canonical hierarchy, doc roles (timeline, lore, characters, systems), propagation discipline, and the dual canonical and exploratory workflow.
prose-craft
Use when writing fiction, editing fiction prose, reviewing chapters, or drafting scenes. Covers prose craft, dialogue mechanics, scene structure, and common failure modes in AI-assisted fiction. Trigger phrases: "write fiction", "edit chapter", "prose review", "scene draft", "dialogue check", "fiction craft", "edit this scene", "review my prose".
vista
This skill should be used when the user asks about research directions, open problems, future work, or follow-up research from the academic literature. Trigger phrases include "open problems in X", "what's next for Y", "future work for paper Z", "research directions on T", "salient follow-up research", "what should I work on next in", "find me follow-up research unrelated to my prior work", "broad survey of W", "neglected directions in V". Routes the request to the right Vista MCP tool, reads back the structured paper sections, and synthesizes research directions in the conversation.
synthesize
Make a research-agent run conclude and write synthesis.md (outcome, key findings, failed approaches, open questions, recommendations). Signals a live researcher to wrap up, or launches one in synthesis mode when none is running. Use when results are good enough or the agent is stalling.
status
Show the current state of a research-agent run from .research/: liveness, cycles and budget, sub-problem and hypothesis statuses, eval trend, current focus, and branches. Read-only.
resume
Resume an interrupted research-agent run from .research/. Re-launches the researcher to reload its structured state and continue from the current focus, optionally on a named branch or with a new budget. Use after a session restart, crash, or explicit pause.