返回技能列表

manage-renv-dependencies

pjt222
更新于 2 days ago
5 次查看
17
2
17
在 GitHub 上查看
其他aiapiautomation

关于

This skill helps developers manage R package dependencies using renv to create reproducible environments. It handles initialization, snapshot/restore workflows, troubleshooting, and CI/CD integration for R projects. Use it when setting up new projects, restoring environments on different machines, or resolving dependency issues.

快速安装

Claude Code

推荐
主要方式
npx skills add pjt222/agent-almanac -a claude-code
插件命令备选方式
/plugin add https://github.com/pjt222/agent-almanac
Git 克隆备选方式
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/manage-renv-dependencies

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Manage renv Dependencies

Setup + maintain reproducible R pkg envs via renv.

Use When

  • Init dep mgmt for new R project
  • Add / update pkg deps
  • Restore env on new machine
  • Troubleshoot renv restore fails
  • Integrate renv w/ CI/CD

In

  • Req: R project dir
  • Opt: Existing renv.lock (for restore)
  • Opt: GitHub PAT for private pkgs

Do

Step 1: Init renv

renv::init()

Creates:

  • renv/ dir (library, settings, activation script)
  • renv.lock (dep snapshot)
  • Updates .Rprofile → activate renv on load

→ Project-local lib created. renv/ dir + renv.lock present. .Rprofile updated w/ activation.

If err: Hangs → check network. Fails on specific pkg → install manually first w/ install.packages() + rerun renv::init().

Step 2: Add Deps

Install pkgs as usual:

install.packages("dplyr")
renv::install("github-user/private-pkg")

Snapshot to record state:

renv::snapshot()

renv.lock updated w/ new pkgs + vers. renv::status() shows no out-of-sync.

If err: Snapshot reports validation errs → renv::dependencies() to check which pkgs actually used → renv::snapshot(force = TRUE) to bypass validation.

Step 3: Restore on Another Machine

renv::restore()

→ All pkgs installed at exact vers in renv.lock.

If err: Common issues: GitHub pkgs fail (set GITHUB_PAT in .Renviron), sys deps missing (install w/ apt-get on Linux), timeouts on large pkgs (options(timeout = 600) before restore), or binaries not avail (renv compiles from source → ensure build tools installed).

Step 4: Update Deps

# Update a specific package
renv::update("dplyr")

# Update all packages
renv::update()

# Snapshot after updates
renv::snapshot()

→ Target pkgs updated to latest compatible vers. renv.lock reflects new vers after snapshot.

If err: Update fails for specific pkg → install directly w/ renv::install("package@version") + snapshot.

Step 5: Check Status

renv::status()

→ "No issues found" or clear list of out-of-sync pkgs w/ actionable guidance.

If err: Status reports pkgs used but not recorded → renv::snapshot(). Recorded but not installed → renv::restore().

Step 6: Config .Rprofile for Conditional Activation

if (file.exists("renv/activate.R")) {
  source("renv/activate.R")
}

Ensures project works even if renv not installed (CI envs, collaborators).

→ R sessions activate renv auto when starting in project dir. Sessions w/o renv still start w/o errs.

If err: .Rprofile causes errs → ensure file.exists() guard present. Never call source("renv/activate.R") unconditionally.

Step 7: Git Config

Track:

renv.lock           # Always commit
renv/activate.R     # Always commit
renv/settings.json  # Always commit
.Rprofile           # Commit (contains renv activation)

Ignore (already in renv's .gitignore):

renv/library/       # Machine-specific
renv/staging/       # Temporary
renv/cache/         # Machine-specific cache

renv.lock, renv/activate.R, renv/settings.json tracked by Git. Machine-specific dirs (renv/library/, renv/cache/) ignored.

If err: renv/library/ accidentally committed → remove w/ git rm -r --cached renv/library/ + add to .gitignore.

Step 8: CI/CD Integration

GitHub Actions → renv cache action:

- uses: r-lib/actions/setup-renv@v2

Automatically restores from renv.lock w/ caching.

→ CI pipeline restores pkgs from renv.lock w/ caching. Subsequent runs faster due to cached pkgs.

If err: CI restore fails → check renv.lock committed + up to date. Private GitHub pkgs → ensure GITHUB_PAT set as repo secret.

Check

  • renv::status() reports no issues
  • renv.lock committed to VC
  • renv::restore() works on clean checkout
  • .Rprofile conditionally activates renv
  • CI/CD uses renv.lock for dep resolution

Traps

  • Run renv::init() in wrong dir: Always verify getwd() first
  • Mix renv + sys library: After init, only use project library
  • Forget to snapshot: After installing, always renv::snapshot()
  • --vanilla flag: Rscript --vanilla skips .Rprofile → renv won't activate
  • Large lock files in diffs: Normal — renv.lock designed to be diffable JSON
  • Bioconductor pkgs: Use renv::install("bioc::PackageName") + ensure BiocManager configured

  • create-r-package — includes renv init
  • setup-github-actions-ci — CI integration w/ renv
  • submit-to-cran — dep mgmt for CRAN pkgs

GitHub 仓库

pjt222/agent-almanac
路径: i18n/caveman-ultra/skills/manage-renv-dependencies
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

相关推荐技能

llamaguard

其他

LlamaGuard是Meta推出的7-8B参数内容审核模型,专门用于过滤LLM的输入和输出内容。它能检测六大安全风险类别(暴力/仇恨、性内容、武器、违禁品、自残、犯罪计划),准确率达94-95%。开发者可通过HuggingFace、vLLM或Sagemaker快速部署,并能与NeMo Guardrails集成实现自动化安全防护。

查看技能

cost-optimization

其他

这个Claude Skill帮助开发者优化云成本,通过资源调整、标记策略和预留实例来降低AWS、Azure和GCP的开支。它适用于减少云支出、分析基础设施成本或实施成本治理策略的场景。关键功能包括提供成本可视化、资源规模调整指导和定价模型优化建议。

查看技能

quantizing-models-bitsandbytes

其他

这个Skill使用bitsandbytes库量化大语言模型,能在GPU内存有限时通过8位或4位量化减少50-75%内存占用,同时保持精度损失最小。它支持INT8、NF4、FP4等多种量化格式,可与HuggingFace Transformers无缝集成,适用于需要部署更大模型或加速推理的场景。还提供QLoRA训练和8位优化器支持,让开发者能轻松实现高效模型压缩。

查看技能

dispatching-parallel-agents

其他

该Skill用于并行处理3个以上无依赖关系的独立故障,可为每个问题域分派专属Claude代理同时执行调查修复。它通过并发处理多个独立问题显著提升故障排查效率,特别适用于测试文件、子系统等无共享状态的场景。

查看技能