CSV Documentation Generator
Generate Computerized System Validation (CSV) documentation for pharmaceutical and medical device industries. Supports bilingual (Chinese/English) templates and multiple output formats (Word/Excel).
When to Use
Use this skill when:
- Creating validation documentation for GMP-regulated systems
- Generating User Requirements Specification (URS) with regulatory compliance checks
- Preparing IQ/OQ/PQ protocols for system qualification
- Creating traceability matrices linking requirements to test cases
- Conducting risk assessments for computerised systems
- Need documentation templates that comply with GAMP 5, 21 CFR Part 11, EU Annex 11
Supported Systems
| System Type | GAMP Category | Documents |
|-------------|---------------|-----------|
| EDC (Electronic Data Capture) | Category 4/5 | All 12 documents |
| CTMS (Clinical Trial Management) | Category 4 | VP, URS, FS, RA, IQ, OQ, RTM |
| LIMS (Laboratory Information Management) | Category 4/5 | All 12 documents |
| MES (Manufacturing Execution System) | Category 4 | All 12 documents |
| ERP (Enterprise Resource Planning) | Category 4 | VP, URS, RA, IQ, OQ |
| SCADA/DCS | Category 2/3 | VP, URS, IQ, OQ, PQ |
| Custom Software | Category 3/4 | VP, URS, RA, IQ, OQ |
Quick Start
# 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/
Parse Requirements from Code (pre-generation)
# 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
Auto Environment Setup
This skill automatically handles environment setup:
- First run: Automatically creates
.venvvirtual environment in skill directory - Dependencies: Automatically installs required packages (python-docx, openpyxl, etc.)
- Subsequent runs: Use the already-created virtual environment
This ensures consistent behavior and avoids dependency conflicts.
Interactive GAMP Category Selection
If --category is not specified, the script will prompt with bilingual (Chinese/English) guidance:
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.
Available Commands
| Command | Description | Output Format |
|---------|-------------|---------------|
| generate.py vp | Validation Plan | .docx |
| generate.py urs | User Requirements Specification | .docx |
| generate.py fs | Functional Specification | .docx |
| generate.py ts | Technical Specification | .docx |
| generate.py ra | Risk Assessment (FMEA) | .docx |
| generate.py iq | Installation Qualification | .docx |
| generate.py oq | Operational Qualification | .docx |
| generate.py pq | Performance Qualification | .docx |
| generate.py rtm | Traceability Matrix | .xlsx |
| generate.py vsr | Validation Summary Report | .docx |
| generate.py checklist | Validation Checklist | .xlsx |
| generate.py test-case | Test Case Template | .xlsx |
| generate.py all | Full validation package | .docx / .xlsx |
Command Options
| Option | Description | Required |
|--------|-------------|----------|
| --project | Project name | Yes |
| --system | System name and version | Yes |
| --category | GAMP category (1-5). If not specified, interactive selection will be prompted with bilingual GAMP 5 guidance. | No (will prompt) |
| --bilingual | Enable bilingual mode: 'true' or 'false' (default: true). When true, headers remain bilingual and content follows --language. | No |
| --language | Primary language for content: 'zh' (Chinese) or 'en' (English) (default: zh). Used when bilingual=false or for content in bilingual mode. | No |
| --verbose / -v | Show detailed progress information (default: simplified output) | No |
| --output | Output directory | Yes |
| --format | Output format: docx, xlsx, or both (default: both) | No |
Output Format Standards
All generated documents follow consistent naming and formatting rules:
Document Naming Convention
| Document Type | Format | Example |
|--------------|--------|---------|
| Validation Plan | {TYPE}_{PROJECT}.{ext} | VP_XX系统.docx |
| User Requirements | {TYPE}_{PROJECT}.{ext} | URS_XX系统.docx |
| Functional Specification | {TYPE}_{PROJECT}.{ext} | FS_XX系统.docx |
| Traceability Matrix | RTM_{PROJECT}.{ext} | RTM_XX系统.xlsx |
Output Directory Structure
{output_dir}/
├── VP_项目名.docx
├── URS_项目名.docx
├── FS_项目名.docx
├── TS_项目名.docx
├── RA_项目名.docx
├── IQ_项目名.docx
├── OQ_项目名.docx
├── PQ_项目名.docx
├── VSR_项目名.docx
├── RTM_项目名.xlsx
└── CHECKLIST_项目名.xlsx
Document Styling Standards
Fonts:
- Chinese text: SimSun (宋体)
- English text: Arial
Colors:
- Table headers: #2563EB (Royal Blue) with white text
- Priority markers: [必须] (red), [应该] (amber), [可以] (green)
- Test results: [通过] (green), [失败] (red), [待测] (amber)
Template Variables
Common variables used in templates:
| Variable | Description | Example |
|----------|-------------|---------|
| {PROJECT_NAME} | Project name | 临床试验系统 |
| {SYSTEM_NAME} | System name | EDC v1.0 |
| {SYSTEM_VERSION} | System version | 1.0 |
| {GAMP_CATEGORY} | GAMP category | 4 |
| {DOC_ID} | Document ID | URS-001 |
| {DATE} | Document date | 2024-01-01 |
| {AUTHOR} | Document author | 张三 |
| {REVIEWER} | Reviewer name | 李四 |
| {APPROVER} | Approver name | 王五 |
Regulatory Compliance
GAMP 5 Categories
| Category | Description | Validation Approach |
|----------|-------------|-------------------|
| 1 | Operating System | Legacy |
| 2 | Firmware | Simplified |
| 3 | Commercial-off-the-shelf (COTS) | Risk-based |
| 4 | Configured COTS | Risk-based |
| 5 | Custom/Critical | Full validation |
Key Regulatory Requirements
This skill includes compliance checks for:
- 21 CFR Part 11: Electronic Records and Signatures
- Audit trail requirements
- Electronic signature requirements
- System access controls
- EU Annex 11: Computerised Systems
- Validation requirements
- Data integrity
- Change control
- ALCOA+: Data Integrity
- Attributable
- Legible
- Contemporaneous
- Original
- Accurate (+ Complete, Consistent, Enduring)
Semantic Action Graph
This skill encapsulates the following semantic actions for GxP document generation:
Action Graph
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
Semantic Actions
| Action | Description | Pre-conditions |
|--------|-------------|---------------|
| parse_requirements() | Parse @URS, @FS, @TEST markers from source code | Source code available |
| generate_vp() | Create Validation Plan | Project name, system name, GAMP category |
| generate_urs() | Create User Requirements Specification | System context, GxP scope |
| generate_fs() | Create Functional Specification | URS requirements linked |
| generate_ra() | Create Risk Assessment | URS priorities, GxP scope |
| generate_iq_oq_pq() | Create Qualification Protocols | RA risk levels, TS config |
| generate_rtm() | Create Traceability Matrix | URS, FS, test cases linked |
| generate_vsr() | Create Validation Summary Report | All test results, deviations |
| sync_bidirectional() | Sync requirements ↔ templates | Templates and requirements.json exist |
| run_compliance_check() | Verify GxP compliance | Requirements and test results |
Data Flow Semantics
| Flow | Semantic Meaning |
|------|-----------------|
| VP → URS | Business process analysis defines GxP scope for requirements |
| URS → FS | Functional requirements trace to design specifications |
| URS → RA | Requirement priority determines risk severity |
| RA → Test | Risk level scales testing rigor (IQ/OQ/PQ scope) |
| All → RTM | Complete traceability matrix for regulatory audit |
Prompt Library
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