Generate Computerized System Validation (CSV) documentation for pharmaceutical and medical device industries. Supports bilingual (Chinese/English) templates and multiple output formats (Word/Excel).
Use this skill when:
System TypeGAMP CategoryDocumentsEDC (Electronic Data Capture)Category 4/5All 12 documentsCTMS (Clinical Trial Management)Category 4VP, URS, FS, RA, IQ, OQ, RTMLIMS (Laboratory Information Management)Category 4/5All 12 documentsMES (Manufacturing Execution System)Category 4All 12 documentsERP (Enterprise Resource Planning)Category 4VP, URS, RA, IQ, OQSCADA/DCSCategory 2/3VP, URS, IQ, OQ, PQCustom SoftwareCategory 3/4VP, URS, RA, IQ, OQ
bash
# Navigate to skill directory
cd <SKILL_DIR>/csv-documentation-generator
# Run script - will automatically create virtual environment on first run
python3 scripts/generate.py vp --project "XX系统" --system "EDC v1.0" --output ./output/
# Note: If --category is not specified, interactive GAMP category selection will be prompted
# The script provides bilingual (Chinese/English) guidance based on GAMP 5 Second Edition
# Generate Validation Plan (with category specified)
python3 scripts/generate.py vp --project "XX系统" --system "EDC v1.0" --category 4 --output ./output/
# Generate full validation package
python3 scripts/generate.py all --project "XX系统" --system "MES" --category 4 --output ./validation/
bash
# Navigate to skill directory
cd <SKILL_DIR>/csv-documentation-generator
# Parse source code for requirements (extracts @URS, @TEST, @FS, @TS markers)
python3 scripts/cli.py parse ./src
# For AI agents (non-interactive mode), use --auto-add:
python3 scripts/cli.py parse ./src --auto-add
# Review extracted requirements
cat requirements.json
This skill automatically handles environment setup:
.venv virtual environment in skill directoryThis ensures consistent behavior and avoids dependency conflicts.
If --category is not specified, the script will prompt with bilingual (Chinese/English) guidance:
text
GAMP 5 (Second Edition) Category Selection:
[1] Infrastructure Software - 基础设施软件
[2] Firmware - 固件
[3] Commercial Off-The-Shelf (COTS) - Non-configured - 商用现货软件 (不可配置)
[4] Configured COTS - 配置型 COTS 软件 (e.g., EDC, CTMS, LIMS, MES)
[5] Custom / Critical Application - 定制/关键应用
AI agents should guide users to select the appropriate category based on GAMP 5 Second Edition principles.
CommandDescriptionOutput Formatgenerate.py vpValidation Plan.docxgenerate.py ursUser Requirements Specification.docxgenerate.py fsFunctional Specification.docxgenerate.py tsTechnical Specification.docxgenerate.py raRisk Assessment (FMEA).docxgenerate.py iqInstallation Qualification.docxgenerate.py oqOperational Qualification.docxgenerate.py pqPerformance Qualification.docxgenerate.py rtmTraceability Matrix.xlsxgenerate.py vsrValidation Summary Report.docxgenerate.py checklistValidation Checklist.xlsxgenerate.py test-caseTest Case Template.xlsxgenerate.py allFull validation package.docx / .xlsx
OptionDescriptionRequired--projectProject nameYes--systemSystem name and versionYes--categoryGAMP category (1-5). If not specified, interactive selection will be prompted with bilingual GAMP 5 guidance.No (will prompt)--bilingualEnable bilingual mode: 'true' or 'false' (default: true). When true, headers remain bilingual and content follows --language.No--languagePrimary language for content: 'zh' (Chinese) or 'en' (English) (default: zh). Used when bilingual=false or for content in bilingual mode.No--verbose / -vShow detailed progress information (default: simplified output)No--outputOutput directoryYes--formatOutput format: docx, xlsx, or both (default: both)No
All generated documents follow consistent naming and formatting rules:
Document TypeFormatExampleValidation Plan{TYPE}_{PROJECT}.{ext}VP_XX系统.docxUser Requirements{TYPE}_{PROJECT}.{ext}URS_XX系统.docxFunctional Specification{TYPE}_{PROJECT}.{ext}FS_XX系统.docxTraceability MatrixRTM_{PROJECT}.{ext}RTM_XX系统.xlsx
text
{output_dir}/
├── VP_项目名.docx
├── URS_项目名.docx
├── FS_项目名.docx
├── TS_项目名.docx
├── RA_项目名.docx
├── IQ_项目名.docx
├── OQ_项目名.docx
├── PQ_项目名.docx
├── VSR_项目名.docx
├── RTM_项目名.xlsx
└── CHECKLIST_项目名.xlsx
Fonts:
Colors:
Common variables used in templates:
VariableDescriptionExample{PROJECT_NAME}Project name临床试验系统{SYSTEM_NAME}System nameEDC v1.0{SYSTEM_VERSION}System version1.0{GAMP_CATEGORY}GAMP category4{DOC_ID}Document IDURS-001{DATE}Document date2024-01-01{AUTHOR}Document author张三{REVIEWER}Reviewer name李四{APPROVER}Approver name王五
CategoryDescriptionValidation Approach1Operating SystemLegacy2FirmwareSimplified3Commercial-off-the-shelf (COTS)Risk-based4Configured COTSRisk-based5Custom/CriticalFull validation
This skill includes compliance checks for:
This skill encapsulates the following semantic actions for GxP document generation:
text
parse_requirements(source_path) → RequirementsDB
│
▼
generate_vp(context) → Document
│ ──────────────────────► generate_urs(context) → Document
│ │
│ ◄── (URS traceability) ──────────────────┤
│ ▼
├────────────────────────────────────► generate_fs(context) → Document
│ │
│ ◄── (FS technical specs) ─────────────────┤
│ ▼
└────────────────────────────────────► generate_ra(context) → Document
│
┌───────────┴───────────┐
▼ ▼
generate_iq_oq_pq(context) generate_rtm(context)
│ │
└───────────┬───────────┘
▼
generate_vsr(context) → Document
ActionDescriptionPre-conditionsparse_requirements()Parse @URS, @FS, @TEST markers from source codeSource code availablegenerate_vp()Create Validation PlanProject name, system name, GAMP categorygenerate_urs()Create User Requirements SpecificationSystem context, GxP scopegenerate_fs()Create Functional SpecificationURS requirements linkedgenerate_ra()Create Risk AssessmentURS priorities, GxP scopegenerate_iq_oq_pq()Create Qualification ProtocolsRA risk levels, TS configgenerate_rtm()Create Traceability MatrixURS, FS, test cases linkedgenerate_vsr()Create Validation Summary ReportAll test results, deviationssync_bidirectional()Sync requirements ↔ templatesTemplates and requirements.json existrun_compliance_check()Verify GxP complianceRequirements and test results
FlowSemantic MeaningVP → URSBusiness process analysis defines GxP scope for requirementsURS → FSFunctional requirements trace to design specificationsURS → RARequirement priority determines risk severityRA → TestRisk level scales testing rigor (IQ/OQ/PQ scope)All → RTMComplete traceability matrix for regulatory audit
Critical Thinking Constraints and Content Fill Prompts are defined in prompts.md.
For GAMP 5 M12 Critical Thinking constraints, document generation triggering conditions, and content fill prompt templates, see prompts.md.
Reference materials included in references/ folder:
FileDescriptiongamp-5.mdGAMP 5 quick reference guide21cfr-part11.md21 CFR Part 11 key requirementsannex-11.mdEU Annex 11 requirementsdata-integrity.mdALCOA+ data integrity principles
Complete fill examples are provided in templates/examples/ directory:
Example FileDescriptionurs-example.mdURS with complete requirement examplesfs-example.mdFS with traceability examplesra-example.mdRA with hierarchical risk examplesiq-example.mdIQ with qualification check examples
AI agents SHOULD reference these examples for content style guidance when filling templates.
All templates support Smart Bilingual output controlled by --bilingual and --language flags:
--bilingual``--languageBehaviortrue (default)zhHeaders bilingual, content in Chinesetrue (default)enHeaders bilingual, content in Englishfalse``zhPure Chinese outputfalse``enPure English output
Templates use dual-language format for headers:
markdown
## 1. 目的 / Purpose
本文档定义了... / This document defines...
Tables use dual-language headers:
中文English验证计划Validation Plan用户需求User Requirements
Content cells use format like 中文 / English:
模块 / Module描述 / Description用户管理 / User Management系统应... / System should...
This skill supports GAMP 5 compliant requirements traceability across the entire validation lifecycle.
text
代码注释 (@URS[module])
↓
requirements.json (需求解析)
↓
URS 模板 (自动同步章节)
↓
FS/TS 文档 (引用需求ID)
↓
测试用例 (关联需求ID)
↓
测试结果 (解析需求ID)
↓
RTM (追溯矩阵自动生成)
When generating code, AI agents MUST include requirement markers for automatic traceability. Use the standardized @REQ format:
python
# @REQ URS-001 - 系统应支持基于角色的访问控制 (RBAC)
# @REQ URS-002 - 用户密码必须满足复杂度要求(至少8位)
# @FS FS-001
# @TS TS-001
# @TEST[OQ-UM-001] - 验证用户角色分配功能
# @RISK H # High risk module
def assign_role(user_id: str, role: str) -> bool:
'''
@REQ URS-001 - Role-based access control required
@TEST[OQ-UM-001] - Test role assignment
'''
# Implementation...
Standard comment formats:
PatternExampleDescription// @REQ URS-xxx``// @REQ URS-001 - 系统应支持RBACRequirement with ID and description# @REQ``# @REQ URS-001 - 描述Python-style comment/* @REQ */``/* @REQ URS-001 - 描述 */Multi-line comment// @TEST[type-id]``// @TEST[OQ-UM-001] - 验证Test case link// @FS``// @FS FS-001FS reference// @TS``// @TS TS-001TS reference// @RISK [H/M/L]``// @RISK HRisk level (High/Medium/Low)
Risk levels:
H (High): Security, compliance, electronic signature, audit trail relatedM (Medium): Default for most requirementsL (Low): Simple features, documentation, reportsModule ID中文名English NameTest Prefixuser_mgmt用户管理User ManagementUMaudit_trail审计追踪Audit TrailATdata_mgmt数据管理Data ManagementDMbusiness_func业务功能Business FunctionsBFreporting报告功能ReportingRPintegration接口集成IntegrationINTsecurity安全SecuritySECcompliance合规ComplianceCMP
注意: 章节号(4.X)是动态分配的,基于模板中已有的章节。同步时会自动为新模块分配下一个可用编号。
⛔ This step is NOT automatic. You must manually add these rules to your agent's system prompt (AGENTS.md) if you want @REQ/@TEST annotations to apply across ALL skills.
To enable cross-skill annotation enforcement, add the following to your AGENTS.md or agent system prompt:
text
Code Annotation Rules (for GxP traceability):
- When writing code that implements requirements, add @REQ markers: # @REQ URS-xxx - description
- When writing test cases, add @TEST markers: # @TEST[OQ-UM-xxx] - description
- Mark high-risk code sections with @RISK H (security, compliance, audit trail related)
- Mark medium-risk code with @RISK M
- Mark low-risk code with @RISK L
Why this is needed: OpenClaw skills only execute when active. There is no mechanism to make instructions persist across skill switches except via the system prompt.
See STANDARDS.md for full documentation and standards/code-annotations.json for the standards file.
Test case IDs follow the format: {IQ|OQ|PQ}-{ModulePrefix}-{Number}
TypeExampleDescriptionIQIQ-UM-001Installation Qualification testOQOQ-UM-001Operational Qualification testPQPQ-UM-001Performance Qualification test
Before generating documents, use --sync to automatically update templates with new requirements:
bash
# Generate URS and sync requirements to template
python3 scripts/generate.py urs --sync \
--project "临床系统" \
--system "EDC v1.0" \
--category 4 \
--output ./validation/
# Generate full validation package with sync
python3 scripts/generate.py all --sync \
--project "XX系统" \
--system "MES" \
--category 4 \
--output ./validation/
What --sync does:
requirements.json for all requirementsUse --sync-template-to-db to extract requirements from templates and add them to requirements.json:
bash
# Extract requirements from urs.md template to requirements.json
python3 scripts/generate.py urs --sync-template-to-db \
--project "临床系统" \
--system "EDC v1.0" \
--category 4 \
--output ./validation/
What --sync-template-to-db does:
| URS-xxx | description | formatFor interactive step-by-step document generation with confirmation prompts:
bash
python3 scripts/generate.py all --interactive \
--project "临床系统" \
--system "EDC v1.0" \
--category 4 \
--output ./validation/
Interactive workflow:
text
[1/11] 解析代码注释...
→ 按 Enter 继续,'s' 跳过,'q' 退出:
[2/11] 同步需求到数据库...
→ 按 Enter 继续,'s' 跳过,'q' 退出:
[3/11] 生成 URS...
→ 按 Enter 继续,'s' 跳过,'q' 退出:
✓ ./output/URS_临床系统.docx
...
Options:
Enter - Execute this steps - Skip this stepq - Quit (already generated files are preserved)Run GAMP 5 compliance validation to check requirements coverage and test coverage:
bash
# Run compliance check (text output)
python3 scripts/generate.py check \
--requirements requirements.json \
--test-results test_results.json
# Run compliance check (JSON output for CI/CD)
python3 scripts/generate.py check \
--requirements requirements.json \
--test-results test_results.json \
--output-format json
Compliance checks performed:
Exit codes:
0 - All checks passed1 - Warnings present2 - Errors foundUse --diff-only to skip regeneration when requirements haven't changed:
bash
# Only regenerate RTM if requirements changed
python3 scripts/generate.py rtm --diff-only \
--project "临床系统" \
--system "EDC v1.0" \
--category 4 \
--output ./validation/
How it works:
.requirements.hash in output directoryInstall post-commit hooks to automatically run compliance checks after code commits:
bash
# Install hooks locally (per-project)
./scripts/git-hooks/install.sh --local
# Install hooks globally (all projects)
./scripts/git-hooks/install.sh --global
# Uninstall hooks
./scripts/git-hooks/install.sh --uninstall
What the hook does:
Use --sync for bidirectional sync between template and requirements.json:
bash
# Full bidirectional sync (both directions)
python3 scripts/generate.py urs --sync \
--project "临床系统" \
--system "EDC v1.0" \
--category 4
# Only sync template → JSON
python3 scripts/generate.py urs --sync --sync-direction to-json
# Only sync JSON → template
python3 scripts/generate.py urs --sync --sync-direction to-template
Conflict resolution:
bash
# Keep template descriptions on conflict
python3 scripts/generate.py urs --sync --conflict-resolution template
# Keep JSON descriptions on conflict
python3 scripts/generate.py urs --sync --conflict-resolution json
# Keep newer version based on updated_at
python3 scripts/generate.py urs --sync --conflict-resolution newer
Section numbering behavior:
### 4.X headersrequirements.json will have sections createdpm_query, multi_lock) are supported and will be assigned the next available section numberFor projects with multiple subprojects (monorepo structure):
bash
# Auto-detect monorepo root
python3 scripts/generate.py rtm --project "临床系统" --system "EDC v1.0"
# Explicitly specify monorepo root
python3 scripts/generate.py rtm --project "临床系统" --system "EDC v1.0" \
--project-root /path/to/monorepo
Detected monorepo layouts:
apps/, packages/, projects/, modules/, services/ directoriesrequirements.jsonTemplates are versioned for compatibility tracking:
bash
# Check compatibility (automatic on generate)
python3 scripts/generate.py rtm --project "系统" --system "v1.0" --category 4
# Specify template version
python3 scripts/generate.py rtm --template-version 1.2.0 \
--project "系统" --system "v1.0" --category 4
Automatic migrations:
Use provided CI/CD templates for automated documentation generation:
GitHub Actions ( templates/ci/github-actions.yml):
yaml
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install -r requirements.txt
- run: python scripts/generate.py check --output-format json
- run: python scripts/generate.py all --diff-only
GitLab CI ( templates/ci/gitlab-ci.yml):
yaml
generate:rtm:
extends: .csv-docs-base
script:
- python scripts/generate.py rtm --diff-only
artifacts:
paths:
- validation/RTM*.xlsx
The URS/FS/TS IDs and descriptions in templates are examples only. For actual projects:
--sync-template-to-db to populate initial requirements, then customizePer GxP requirements, any system change requires a risk assessment. When generating RA documents, include the change description:
bash
python3 scripts/generate.py ra \
--project "临床系统" \
--system "EDC v1.0" \
--change-description "升级数据库从 v12 到 v14" \
--output ./validation/
bash
# Navigate to skill directory
cd <SKILL_DIR>/csv-documentation-generator
# Parse source code for requirements using csv-docs CLI
python3 scripts/cli.py parse ./src
# View extracted requirements
cat requirements.json
IssueSolutionpython-docx not installedRun: pip install -r requirements.txtEncoding errorsEnsure UTF-8 encoding in your terminalTemplate not foundCheck you are in the correct directory
Run with verbose output:
bash
python3 scripts/generate.py --help
For AI agents running in non-interactive mode, use --auto-add to automatically add all parsed requirements:
bash
# Parse and auto-add all requirements (non-interactive)
python3 scripts/cli.py parse ./src --auto-add
# Generate with verbose output
python3 scripts/generate.py all --project "XX系统" --system "System v1.0" --category 4 --verbose
bash
python3 scripts/generate.py urs \
--project "临床试验管理系统" \
--system "CTMS v2.0" \
--category 4 \
--bilingual true \
--output ./validation/
bash
python3 scripts/generate.py ra \
--project "质量管理系统" \
--system "QMS v1.5" \
--category 4 \
--critical-functions "数据录入,审计追踪,权限控制" \
--output ./validation/
bash
python3 scripts/generate.py rtm \
--project "实验室系统" \
--system "LIMS v3.0" \
--category 4 \
--urs-file ./URS-001.md \
--fs-file ./FS-001.md \
--output ./validation/