create-r-package
について
このClaude Skillは、usethisの規約とtidyverseスタイルに従い、完全でプロダクションレディなRパッケージ構造をゼロから構築します。DESCRIPTIONファイル、ドキュメント、テスト、依存関係管理(renv)、バージョン管理、およびGitHub ActionsによるCI/CDのための必須ファイルを自動生成します。新規パッケージの初期化、散在するスクリプトの構造化プロジェクトへの変換、または共同作業用のパッケージ骨格の作成にご利用ください。
クイックインストール
Claude Code
推奨npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/create-r-packageこのコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします
ドキュメント
Create R Package
Scaffold fully configured R package with modern tooling and best practices.
When Use
- Starting new R package from scratch
- Converting loose R scripts into package
- Setting up package skeleton for collaborative development
Inputs
- Required: Package name (lowercase, no special chars except
.) - Required: One-line description of package purpose
- Optional: License type (default: MIT)
- Optional: Author info (name, email, ORCID)
- Optional: Whether to init renv (default: yes)
Steps
Step 1: Create Package Skeleton
usethis::create_package("packagename")
setwd("packagename")
Got: Directory created with DESCRIPTION, NAMESPACE, R/, man/ subdirectories.
If fail: Confirm usethis installed (install.packages("usethis")). Check directory does not already exist.
Step 2: Configure DESCRIPTION
Edit DESCRIPTION with accurate metadata:
Package: packagename
Title: What the Package Does (Title Case)
Version: 0.1.0
Authors@R:
person("First", "Last", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0000-0000-0000"))
Description: One paragraph describing what the package does. Must be more
than one sentence. Avoid starting with "This package".
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
URL: https://github.com/username/packagename
BugReports: https://github.com/username/packagename/issues
Got: Valid DESCRIPTION passing R CMD check with no metadata warnings.
If fail: R CMD check warns about DESCRIPTION fields? Verify Title in Title Case, Description more than one sentence, Authors@R uses valid person() syntax.
Step 3: Set Up Infrastructure
usethis::use_mit_license()
usethis::use_readme_md()
usethis::use_news_md()
usethis::use_testthat(edition = 3)
usethis::use_git()
usethis::use_github_action("check-standard")
Got: LICENSE, README.md, NEWS.md, tests/ directory, .git/ initialized, .github/workflows/ created.
If fail: Any usethis::use_*() function fails? Install missing dependency, rerun. .git/ already exists? use_git() skips init.
Step 4: Create Development Configuration
Create .Rprofile:
if (file.exists("renv/activate.R")) {
source("renv/activate.R")
}
if (requireNamespace("mcptools", quietly = TRUE)) {
mcptools::mcp_session()
}
Create .Renviron.example:
RSTUDIO_PANDOC="C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools"
# GITHUB_PAT=your_github_token_here
Create .Rbuildignore entries:
^\.Rprofile$
^\.Renviron$
^\.Renviron\.example$
^renv$
^renv\.lock$
^CLAUDE\.md$
^\.github$
^.*\.Rproj$
Got: .Rprofile, .Renviron.example, .Rbuildignore created. Development files dropped from built package.
If fail: .Rprofile causes startup errors? Check syntax. Confirm requireNamespace() guards stop failures when optional packages missing.
Step 5: Initialize renv
renv::init()
Got: renv/ directory and renv.lock created. Project-local library active.
If fail: Install renv with install.packages("renv"). renv hangs during init? Check network. Set options(timeout = 600).
Step 6: Create Package Documentation File
Create R/packagename-package.R:
#' @keywords internal
"_PACKAGE"
## usethis namespace: start
## usethis namespace: end
NULL
Got: R/packagename-package.R exists with "_PACKAGE" sentinel. Running devtools::document() generates package-level help.
If fail: Confirm filename matches pattern R/<packagename>-package.R. "_PACKAGE" string must be standalone expression, not inside function.
Step 7: Create CLAUDE.md
Create CLAUDE.md in project root with project-specific instructions for AI assistants.
Got: CLAUDE.md exists in project root with project-specific editing conventions, build commands, architecture notes.
If fail: Unsure what to include? Start with package name, one-line description, common dev commands (devtools::check(), devtools::test()), any non-obvious conventions.
Checks
-
devtools::check()returns 0 errors, 0 warnings - Package structure matches expected layout
-
.Rprofileloads without errors -
renv::status()shows no issues - Git repo initialized with right
.gitignore - GitHub Actions workflow file present
Pitfalls
- Package name conflicts: Check CRAN with
available::available("packagename")before committing to a name - Missing .Rbuildignore entries: Development files (
.Rprofile,.Renviron,renv/) must drop from built package - Forgetting Encoding: Always include
Encoding: UTF-8in DESCRIPTION - RoxygenNote mismatch: Version in DESCRIPTION must match installed roxygen2
Examples
# Minimal creation
usethis::create_package("myanalysis")
# Full setup in one session
usethis::create_package("myanalysis")
usethis::use_mit_license()
usethis::use_testthat(edition = 3)
usethis::use_readme_md()
usethis::use_git()
usethis::use_github_action("check-standard")
renv::init()
See Also
write-roxygen-docs- document functions you createwrite-testthat-tests- add tests for packagesetup-github-actions-ci- detailed CI/CD configurationmanage-renv-dependencies- manage package dependencieswrite-claude-md- create effective AI assistant instructions
GitHub リポジトリ
関連スキル
content-collections
メタこのスキルは、Content Collections(Markdown/MDXファイルを型安全なデータコレクションに変換するTypeScriptファーストのツール)の本番環境でテストされた設定を提供します。Zodバリデーションによる型安全性を実現し、ブログ、ドキュメントサイト、コンテンツ重視のVite + Reactアプリケーション構築時にご利用ください。Viteプラグインの設定、MDXコンパイルから、デプロイ最適化、スキーマバリデーションまで、すべてを網羅しています。
polymarket
メタこのスキルは、開発者がPolymarket予測市場プラットフォームを活用したアプリケーション構築を可能にします。API統合による取引や市場データの取得に加え、WebSocketを介したリアルタイムデータストリーミングにより、ライブ取引や市場活動を監視できます。取引戦略の実装や、ライブ市場更新を処理するツールの作成にご利用ください。
creating-opencode-plugins
メタこのスキルは、開発者がコマンド、ファイル、LSP操作など25種類以上のイベントタイプにフックするOpenCodeプラグインを作成することを支援します。JavaScript/TypeScriptモジュール向けに、プラグイン構造、イベントAPI仕様、および実装パターンを提供します。カスタムイベント駆動ロジックでOpenCode AIアシスタントのライフサイクルをインターセプト、監視、または拡張する必要がある場合にご利用ください。
sglang
メタSGLangは、高性能なLLMサービングフレームワークであり、RadixAttentionプレフィックスキャッシュを活用したJSON、正規表現、エージェントワークフロー向けの高速で構造化された生成を特長とします。特にプレフィックスが繰り返されるタスクにおいて、大幅に高速な推論を実現し、複雑な構造化出力やマルチターン対話に最適です。制約付きデコードが必要な場合や、広範なプレフィックス共有を伴うアプリケーションを構築する場合は、vLLMなどの代替案ではなくSGLangを選択してください。
