manage-renv-dependencies
について
このスキルは、renvを使用して再現可能な環境を作成することで、開発者がRパッケージの依存関係を管理するのに役立ちます。プロジェクトの初期化、依存関係のスナップショット/復元、問題のトラブルシューティング、CI/CD統合について説明しています。新しいRプロジェクトのセットアップ時、パッケージの追加/更新時、または異なるマシン間で環境を復元する際にご利用ください。
クイックインストール
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/manage-renv-dependenciesこのコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします
ドキュメント
Manage renv Dependencies
Set up and maintain reproducible R package environments using renv.
When Use
- Initializing dependency management for new R project
- Adding or updating package dependencies
- Restoring project environment on new machine
- Troubleshooting renv restore failures
- Integrating renv with CI/CD pipelines
Inputs
- Required: R project directory
- Optional: Existing
renv.lockfile (for restore) - Optional: GitHub PAT for private packages
Steps
Step 1: Initialize renv
renv::init()
This creates:
renv/directory (library, settings, activation script)renv.lock(dependency snapshot)- Updates
.Rprofileto activate renv on load
Got: Project-local library created. renv/ directory and renv.lock present. .Rprofile updated with activation script.
If fail: Hangs? Check network connectivity. Fails on specific package? Install that package manually first with install.packages() then rerun renv::init().
Step 2: Add Dependencies
Install packages as usual:
install.packages("dplyr")
renv::install("github-user/private-pkg")
Then snapshot to record state:
renv::snapshot()
Got: renv.lock updated with new packages and versions. renv::status() shows no out-of-sync packages.
If fail: renv::snapshot() reports validation errors? Run renv::dependencies() to check which packages actually used, then renv::snapshot(force = TRUE) to bypass validation.
Step 3: Restore on Another Machine
renv::restore()
Got: All packages installed at exact versions in renv.lock.
If fail: Common issues: GitHub packages fail (set GITHUB_PAT in .Renviron), system dependencies missing (install with apt-get on Linux), timeouts on large packages (set options(timeout = 600) before restore), binaries not available (renv compiles from source. Ensure build tools installed).
Step 4: Update Dependencies
# Update a specific package
renv::update("dplyr")
# Update all packages
renv::update()
# Snapshot after updates
renv::snapshot()
Got: Target packages updated to latest compatible versions. renv.lock reflects new versions after snapshot.
If fail: renv::update() fails for specific package? Try installing directly with renv::install("package@version") then snapshot.
Step 5: Check Status
renv::status()
Got: "No issues found" or clear list of out-of-sync packages with actionable guidance.
If fail: Status reports packages used but not recorded? Run renv::snapshot(). Packages recorded but not installed? Run renv::restore().
Step 6: Configure .Rprofile for Conditional Activation
if (file.exists("renv/activate.R")) {
source("renv/activate.R")
}
Ensures project works even if renv isn't installed (CI environments, collaborators).
Got: R sessions activate renv automatically when starting in project directory. Sessions without renv installed still start without errors.
If fail: .Rprofile causes errors? Ensure file.exists() guard present. Never call source("renv/activate.R") unconditionally.
Step 7: Git Configuration
Track these files:
renv.lock # Always commit
renv/activate.R # Always commit
renv/settings.json # Always commit
.Rprofile # Commit (contains renv activation)
Ignore these (already in renv's .gitignore):
renv/library/ # Machine-specific
renv/staging/ # Temporary
renv/cache/ # Machine-specific cache
Got: renv.lock, renv/activate.R, renv/settings.json tracked by Git. Machine-specific directories (renv/library/, renv/cache/) ignored.
If fail: renv/library/ accidentally gets committed? Remove with git rm -r --cached renv/library/ and add to .gitignore.
Step 8: CI/CD Integration
In GitHub Actions, use renv cache action:
- uses: r-lib/actions/setup-renv@v2
Automatically restores from renv.lock with caching.
Got: CI pipeline restores packages from renv.lock with caching enabled. Subsequent runs faster due to cached packages.
If fail: CI restore fails? Check renv.lock is committed and up to date. For private GitHub packages, ensure GITHUB_PAT set as repository secret.
Checks
-
renv::status()reports no issues -
renv.lockcommitted to version control -
renv::restore()works on clean checkout -
.Rprofileconditionally activates renv - CI/CD uses
renv.lockfor dependency resolution
Pitfalls
- Running
renv::init()in wrong directory: Always verifygetwd()first - Mixing renv and system library: After
renv::init(), only use project library - Forgetting to snapshot: After installing packages, always run
renv::snapshot() --vanillaflag:Rscript --vanillaskips.Rprofile, so renv won't activate- Large lock files in diffs: Normal —
renv.lockdesigned to be diffable JSON - Bioconductor packages: Use
renv::install("bioc::PackageName")and ensure BiocManager configured
See Also
create-r-package- includes renv initializationsetup-github-actions-ci- CI integration with renvsubmit-to-cran- dependency management for CRAN packages
GitHub リポジトリ
関連スキル
llamaguard
その他LlamaGuardは、暴力やヘイトスピーチなど6つの安全性カテゴリーにおいて、LLMの入力と出力をモデレートするMetaの70-80億パラメータモデルです。94〜95%の精度を提供し、vLLM、Hugging Face、Amazon SageMakerを使用してデプロイ可能です。このスキルを使用して、AIアプリケーションにコンテンツフィルタリングと安全策を簡単に統合できます。
cost-optimization
その他このClaudeスキルは、リソースの適正サイジング、タグ付け戦略、支出分析を通じて、開発者がクラウドコストを最適化することを支援します。AWS、Azure、GCPにわたるクラウド支出の削減とコストガバナンスの実施のためのフレームワークを提供します。インフラコストの分析、リソースの適正サイジング、または予算制約への対応が必要な際にご利用ください。
quantizing-models-bitsandbytes
その他このスキルは、bitsandbytesを使用してLLMを8ビットまたは4ビット精度に量子化し、精度の低下を最小限に抑えつつ50〜75%のメモリ削減を実現します。限られたGPUメモリでより大規模なモデルを実行したり、推論を高速化するのに理想的で、INT8、NF4、FP4などのフォーマットをサポートしています。HuggingFace Transformersと統合され、QLoRAトレーニングや8ビットオプティマイザーを可能にします。
dispatching-parallel-agents
その他このClaudeスキルは、複数のエージェントを配備し、3つ以上の独立した問題を並行して調査・修正します。共有状態や依存関係がなく解決可能な、無関係な障害が発生するシナリオ向けに設計されています。中核となる機能は並列問題解決であり、効率を最大化するために独立した問題領域ごとに1つのエージェントを割り当てます。
