返回技能列表

setup-gxp-r-project

pjt222
更新于 6 days ago
20 次查看
17
2
17
在 GitHub 上查看
worddesign

关于

This skill sets up an R project structure compliant with GxP regulations like 21 CFR Part 11. It establishes a validated environment with documentation, change control, and electronic records handling for regulatory submissions. Use it when starting R analysis projects in regulated pharma, biotech, or clinical trial environments.

快速安装

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/setup-gxp-r-project

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

技能文档

設 GxP R 項

建合 GxP 規之 R 項結構為驗算。

  • 規境(藥、生技、醫器)始 R 析項→用
  • 為臨試析設 R→用
  • 為規呈建驗算境→用
  • 行 21 CFR Part 11 或 EU Annex 11 需→用

  • :項範與規框(FDA、EMA、二)
  • :所驗 R 本與包本
  • :驗策(險導法)
  • :既電腦系 SOP
  • :質管系接需

一:建驗項結構

gxp-project/
├── R/
│   ├── 01_data_import.R
│   ├── 02_data_processing.R
│   └── 03_analysis.R
├── validation/
│   ├── validation_plan.md
│   ├── risk_assessment.md
│   ├── iq/
│   │   ├── iq_protocol.md
│   │   └── iq_report.md
│   ├── oq/
│   │   ├── oq_protocol.md
│   │   └── oq_report.md
│   ├── pq/
│   │   ├── pq_protocol.md
│   │   └── pq_report.md
│   └── traceability_matrix.md
├── tests/
│   ├── testthat.R
│   └── testthat/
│       ├── test-data_import.R
│       └── test-analysis.R
├── data/
│   ├── raw/
│   └── derived/
├── output/
├── docs/
│   ├── sop_references.md
│   └── change_log.md
├── renv.lock
├── DESCRIPTION
├── .Rprofile
└── CLAUDE.md

得:完目結構含 R/validation/(含 iq/oq/pq/)、tests/testthat/data/raw/data/derived/output/docs/

敗:目缺→mkdir -p 建。驗於正項根。既項僅建缺目、勿覆既結構。

二:建驗計

validation/validation_plan.md

# Validation Plan

## 1. Purpose
This plan defines the validation strategy for [Project Name] using R [version].

## 2. Scope
- R version: 4.5.0
- Packages: [list with versions]
- Analysis: [description]
- Regulatory framework: 21 CFR Part 11 / EU Annex 11

## 3. Risk Assessment Approach
Using GAMP 5 risk-based categories:
- Category 3: Non-configured products (R base)
- Category 4: Configured products (R packages with default settings)
- Category 5: Custom applications (custom R scripts)

## 4. Validation Activities
| Activity | Category 3 | Category 4 | Category 5 |
|----------|-----------|-----------|-----------|
| IQ | Required | Required | Required |
| OQ | Reduced | Standard | Enhanced |
| PQ | N/A | Standard | Enhanced |

## 5. Roles and Responsibilities
- Validation Lead: [Name]
- Developer: [Name]
- QA Reviewer: [Name]
- Approver: [Name]

## 6. Acceptance Criteria
All tests must pass with documented evidence.

得:validation/validation_plan.md 完含範、GAMP 5 險類、驗動陣、職責、接準。引特 R 本與規框。

敗:規框不明→諮組 QA 部為適 SOP。計未審准前勿進驗動。

三:用 renv 鎖依

renv::init()

renv::install("[email protected]")
renv::install("[email protected]")

renv::snapshot()

renv.lock 為控包冊。

得:renv.lock 存含諸需包準本。renv::status() 報無問題。每包本釘(如 [email protected])非浮。

敗:renv::install() 特本敗→察本存於 CRAN 檔。用 renv::install("package@version", repos = "https://packagemanager.posit.co/cran/latest") 為檔本。

四:行版控

git init
git add .
git commit -m "Initial validated project structure"

git config user.signingkey YOUR_GPG_KEY
git config commit.gpgsign true

得:項於 git 控含署名提啟。首提含驗結構與 renv.lock

敗:GPG 署敗→gpg --list-secret-keys 驗 GPG 鑰配。無 GPG 境→文錄偏、用無署提含 docs/change_log.md 之手審跡。

五:建 IQ 議

validation/iq/iq_protocol.md

# Installation Qualification Protocol

## Objective
Verify that R and required packages are correctly installed.

## Test Cases

### IQ-001: R Version Verification
- **Requirement**: R 4.5.0 installed
- **Procedure**: Execute `R.version.string`
- **Expected:** "R version 4.5.0 (date)"
- **Result**: [ PASS / FAIL ]

### IQ-002: Package Installation Verification
- **Requirement**: All packages in renv.lock installed
- **Procedure**: Execute `renv::status()`
- **Expected:** "No issues found"
- **Result**: [ PASS / FAIL ]

### IQ-003: Package Version Verification
- **Procedure**: Execute `installed.packages()[, c("Package", "Version")]`
- **Expected:** Versions match renv.lock exactly
- **Result**: [ PASS / FAIL ]

得:validation/iq/iq_protocol.md 含 R 本驗、包裝驗、包本驗之測例、各含明期果與過/敗欄。

敗:IQ 議板不合組 SOP→保需欄(需、程、期果、實果、過/敗)改式。諮 QA 為准板。

六:書自動 OQ/PQ 測

test_that("primary analysis produces validated results", {
  test_data <- read.csv(test_path("fixtures", "validation_dataset.csv"))

  result <- primary_analysis(test_data)

  expect_equal(result$estimate, 2.345, tolerance = 1e-3)
  expect_equal(result$p_value, 0.012, tolerance = 1e-3)
  expect_equal(result$ci_lower, 1.234, tolerance = 1e-3)
})

得:自測檔於 tests/testthat/ 覆 OQ(各函操驗)與 PQ(端對端對獨算參值驗)。測用顯數忍。

敗:獨算之參值未備(如 SAS)→建占測含 skip("Awaiting independent reference values") 並文錄於追陣。

七:建追陣

# Traceability Matrix

| Req ID | Requirement | Test ID | Test Description | Status |
|--------|-------------|---------|------------------|--------|
| REQ-001 | Import CSV data correctly | OQ-001 | Verify data dimensions and types | PASS |
| REQ-002 | Calculate primary endpoint | PQ-001 | Compare against reference results | PASS |
| REQ-003 | Generate report output | PQ-002 | Verify report contains all sections | PASS |

得:validation/traceability_matrix.md 連各需於 ≥ 1 測例、各測例連於需。無孤需或測。

敗:需未測→建測例或文錄險導排除。測無連需→連既需或除為範外。

  • 項結構循文錄板
  • renv.lock 含諸依準本
  • 驗計完准
  • IQ 議成行
  • OQ 測例覆諸配功
  • PQ 測對獨算果驗
  • 追陣連需於測
  • 變控程文錄

  • install.packages() 無本釘:恆用 renv 含鎖本
  • 缺審跡:諸變必文錄。用 git 署提
  • 過驗:施險導法。非每 CRAN 包需類 5 驗
  • 忘系級驗:OS 與 R 裝亦需 IQ
  • 無獨驗:PQ 宜對獨算果(SAS、手算)較

  • write-validation-documentation
  • implement-audit-trail
  • validate-statistical-output
  • manage-renv-dependencies

GitHub 仓库

pjt222/agent-almanac
路径: i18n/wenyan-ultra/skills/setup-gxp-r-project
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

相关推荐技能

content-collections

Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。

查看技能

polymarket

这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。

查看技能

creating-opencode-plugins

该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。

查看技能

sglang

SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。

查看技能