Zurück zu Fähigkeiten

setup-gxp-r-project

pjt222
Aktualisiert 5 days ago
7 Ansichten
17
2
17
Auf GitHub ansehen
Metaworddesign

Über

Diese Fähigkeit erstellt eine R-Projektstruktur, die mit GxP-Vorschriften wie 21 CFR Part 11 konform ist. Sie richtet eine validierte Umgebung für die Analyse klinischer Studien und regulatorische Einreichungen ein und behandelt Qualifizierung, Änderungskontrolle und elektronische Aufzeichnungen. Nutzen Sie diese Fähigkeit bei Beginn eines R-Analyseprojekts in einer regulierten pharmazeutischen, biotechnologischen oder Medizinprodukte-Umgebung.

Schnellinstallation

Claude Code

Empfohlen
Primär
npx skills add pjt222/agent-almanac -a claude-code
Plugin-BefehlAlternativ
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternativ
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/setup-gxp-r-project

Kopieren Sie diesen Befehl und fügen Sie ihn in Claude Code ein, um diese Fähigkeit zu installieren

Dokumentation

設置 GxP R 項目

建立符合 GxP 法規之 R 項目結構,以滿足驗證計算之要求。

適用時機

  • 於受監管環境(製藥、生物技術、醫療設備)啟動 R 分析項目
  • 設置 R 用於臨床試驗分析
  • 為法規送件建立驗證之計算環境
  • 實作 21 CFR Part 11 或 EU Annex 11 要求

輸入

  • 必要:項目範圍與法規框架(FDA、EMA 或兩者)
  • 必要:欲驗證之 R 版本與套件版本
  • 必要:驗證策略(基於風險之方法)
  • 選擇性:電腦化系統之既有 SOP
  • 選擇性:品質管理系統整合要求

步驟

步驟一:建立驗證項目結構

gxp-project/
├── R/                          # Analysis scripts
│   ├── 01_data_import.R
│   ├── 02_data_processing.R
│   └── 03_analysis.R
├── validation/                 # Validation documentation
│   ├── validation_plan.md      # VP: scope, strategy, roles
│   ├── risk_assessment.md      # Risk categorization
│   ├── iq/                     # Installation Qualification
│   │   ├── iq_protocol.md
│   │   └── iq_report.md
│   ├── oq/                     # Operational Qualification
│   │   ├── oq_protocol.md
│   │   └── oq_report.md
│   ├── pq/                     # Performance Qualification
│   │   ├── pq_protocol.md
│   │   └── pq_report.md
│   └── traceability_matrix.md  # Requirements to tests mapping
├── tests/                      # Automated test suite
│   ├── testthat.R
│   └── testthat/
│       ├── test-data_import.R
│       └── test-analysis.R
├── data/                       # Input data (controlled)
│   ├── raw/                    # Immutable raw data
│   └── derived/                # Processed datasets
├── output/                     # Analysis outputs
├── docs/                       # Supporting documentation
│   ├── sop_references.md       # Links to relevant SOPs
│   └── change_log.md           # Manual change documentation
├── renv.lock                   # Locked dependencies
├── DESCRIPTION                 # Project metadata
├── .Rprofile                   # Session configuration
└── CLAUDE.md                   # AI assistant instructions

預期: 完整目錄結構已存,含 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 鎖定依賴

# Initialize renv with exact versions
renv::init()

# Install specific validated versions
renv::install("[email protected]")
renv::install("[email protected]")

# Snapshot
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"

# Use signed commits for traceability
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 測試

# tests/testthat/test-analysis.R
test_that("primary analysis produces validated results", {
  # Known input -> known output (double programming validation)
  test_data <- read.csv(test_path("fixtures", "validation_dataset.csv"))

  result <- primary_analysis(test_data)

  # Compare against independently calculated expected values
  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 將每要求連至至少一測試案例,且每測試案例連至一要求。無孤立要求或測試。

失敗時: 若要求未測試,為其建立測試案例或記錄基於風險之排除理由。若測試無連結之要求,連至既有要求或將其移除作範圍外。

驗證

  • 項目結構遵循書面範本
  • renv.lock 含所有依賴附精確版本
  • 驗證計劃完整並已批准
  • IQ 協議成功執行
  • OQ 測試案例涵蓋所有已配置功能
  • PQ 測試對獨立計算之結果驗證
  • 追溯矩陣將要求連至測試
  • 變更控制流程已記錄

常見陷阱

  • 未鎖定版本之 install.packages():應始終用 renv 配鎖定版本
  • 缺審計軌跡:每變更須記錄。用 git 簽署提交。
  • 過度驗證:套用基於風險之方法。非每 CRAN 套件皆需 Category 5 驗證。
  • 遺忘系統級資格認證:OS 與 R 安裝亦需 IQ
  • 無獨立驗證:PQ 應對照獨立計算之結果(SAS、手算)

相關技能

  • write-validation-documentation - 詳細驗證文件建立
  • implement-audit-trail - 電子記錄與審計軌跡
  • validate-statistical-output - 雙重編程與輸出驗證
  • manage-renv-dependencies - 受驗證環境之依賴鎖定

GitHub Repository

pjt222/agent-almanac
Pfad: i18n/wenyan-lite/skills/setup-gxp-r-project
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Verwandte Skills

content-collections

Meta

Diese Skill bietet eine produktionsgetestete Einrichtung für Content Collections – ein TypeScript-first-Tool, das Markdown/MDX-Dateien in typsichere Datensammlungen mit Zod-Validierung umwandelt. Verwenden Sie ihn beim Erstellen von Blogs, Dokumentationsseiten oder inhaltsstarken Vite + React-Anwendungen, um Typsicherheit und automatische Inhaltsvalidierung zu gewährleisten. Er behandelt alles von der Vite-Plugin-Konfiguration und MDX-Kompilierung bis hin zur Deployment-Optimierung und Schema-Validierung.

Skill ansehen

polymarket

Meta

Diese Fähigkeit ermöglicht es Entwicklern, Anwendungen mit der Polymarket-Prognosemärkte-Plattform zu erstellen, einschließlich API-Integration für Handel und Marktdaten. Sie bietet außerdem Echtzeit-Datenstreaming über WebSocket, um Live-Trades und Marktaktivitäten zu überwachen. Nutzen Sie sie zur Implementierung von Handelsstrategien oder zur Erstellung von Tools, die Live-Marktaktualisierungen verarbeiten.

Skill ansehen

creating-opencode-plugins

Meta

Diese Fähigkeit unterstützt Entwickler dabei, OpenCode-Plugins zu erstellen, die in über 25 Ereignistypen wie Befehle, Dateien und LSP-Operationen eingreifen. Sie bietet die Plugin-Struktur, Event-API-Spezifikationen und Implementierungsmuster für JavaScript/TypeScript-Module. Nutzen Sie sie, wenn Sie den Lebenszyklus des OpenCode KI-Assistenten mit benutzerdefinierter ereignisgesteuerter Logik abfangen, überwachen oder erweitern müssen.

Skill ansehen

sglang

Meta

SGLang ist ein hochperformantes LLM-Serving-Framework, das sich auf schnelle, strukturierte Generierung für JSON, Regex und agentenbasierte Workflows unter Verwendung seines RadixAttention-Prefix-Cachings spezialisiert. Es bietet deutlich schnellere Inferenz, insbesondere für Aufgaben mit wiederholten Präfixen, was es ideal für komplexe, strukturierte Ausgaben und Mehrfachdialoge macht. Wählen Sie SGLang gegenüber Alternativen wie vLLM, wenn Sie constrained decoding benötigen oder Anwendungen mit umfangreicher Präfix-Weitergabe entwickeln.

Skill ansehen