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
CODEBLOCK0
Parse Requirements from Code (pre-generation)
CODEBLOCK1
Auto Environment Setup
This skill automatically handles environment setup:
- 1. First run: Automatically creates
.venv virtual 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:
CODEBLOCK2
AI agents should guide users to select the appropriate category based on GAMP 5 Second Edition principles.
Available Commands
| Command | Description | Output Format |
|---|
| INLINECODE2 | Validation Plan | .docx |
| INLINECODE3 |
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 |
|---|
| INLINECODE15 | Project name | Yes |
| INLINECODE16 |
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 | INLINECODE24 | VPXX系统.docx |
| User Requirements |
{TYPE}_{PROJECT}.{ext} | URSXX系统.docx |
| Functional Specification |
{TYPE}_{PROJECT}.{ext} | FS_XX系统.docx |
| Traceability Matrix |
RTM_{PROJECT}.{ext} | RTM_XX系统.xlsx |
Output Directory Structure
CODEBLOCK3
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 |
|---|
| INLINECODE28 | Project name | 临床试验系统 |
| INLINECODE29 |
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
- Attributable
- Legible
- Contemporaneous
- Original
- Accurate (+ Complete, Consistent, Enduring)
Semantic Action Graph
This skill encapsulates the following semantic actions for GxP document generation:
Action Graph
CODEBLOCK4
Semantic Actions
| Action | Description | Pre-conditions |
|---|
| INLINECODE37 | Parse @URS, @FS, @TEST markers from source code | Source code available |
| INLINECODE38 |
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 prompts.md.
Reference Documents
Reference materials included in references/ folder:
| File | Description |
|---|
| INLINECODE50 | GAMP 5 quick reference guide |
| INLINECODE51 |
21 CFR Part 11 key requirements |
|
annex-11.md | EU Annex 11 requirements |
|
data-integrity.md | ALCOA+ data integrity principles |
Example Templates
Complete fill examples are provided in templates/examples/ directory:
| Example File | Description |
|---|
| INLINECODE55 | URS with complete requirement examples |
| INLINECODE56 |
FS with traceability examples |
|
ra-example.md | RA with hierarchical risk examples |
|
iq-example.md | IQ with qualification check examples |
AI agents SHOULD reference these examples for content style guidance when filling templates.
Bilingual Format
All templates support Smart Bilingual output controlled by --bilingual and --language flags:
| INLINECODE61 | INLINECODE62 | Behavior |
|---|
| INLINECODE63 (default) | INLINECODE64 | Headers bilingual, content in Chinese |
| INLINECODE65 (default) |
en | Headers bilingual, content in English |
|
false |
zh | Pure Chinese output |
|
false |
en | Pure English output |
Bilingual Template Format
Templates use dual-language format for headers:
CODEBLOCK5
Tables use dual-language headers:
| 中文 | English |
|---|
| 验证计划 | Validation Plan |
| 用户需求 |
User Requirements |
Content cells use format like 中文 / English:
| 模块 / Module | 描述 / Description |
|---|
| 用户管理 / User Management | 系统应... / System should... |
Requirements Traceability
This skill supports GAMP 5 compliant requirements traceability across the entire validation lifecycle.
Automated Traceability Chain
CODEBLOCK6
Code Comment Standards (AI Agent Must Follow)
When generating code, AI agents MUST include requirement markers for automatic traceability. Use the standardized @REQ format:
CODEBLOCK7
Standard comment formats:
| Pattern | Example | Description |
|---|
| INLINECODE73 | INLINECODE74 | Requirement with ID and description |
| INLINECODE75 |
# @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-001 | FS reference |
|
// @TS |
// @TS TS-001 | TS reference |
|
// @RISK [H/M/L] |
// @RISK H | Risk level (High/Medium/Low) |
Risk levels:
- -
H (High): Security, compliance, electronic signature, audit trail related - INLINECODE88 (Medium): Default for most requirements
- INLINECODE89 (Low): Simple features, documentation, reports
Standard Modules
| Module ID | 中文名 | English Name | Test Prefix |
|---|
| INLINECODE90 | 用户管理 | User Management | UM |
| INLINECODE91 |
审计追踪 | Audit Trail | AT |
|
data_mgmt | 数据管理 | Data Management | DM |
|
business_func | 业务功能 | Business Functions | BF |
|
reporting | 报告功能 | Reporting | RP |
|
integration | 接口集成 | Integration | INT |
|
security | 安全 | Security | SEC |
|
compliance | 合规 | Compliance | CMP |
注意: 章节号(4.X)是动态分配的,基于模板中已有的章节。同步时会自动为新模块分配下一个可用编号。
System Prompt Integration (Manual Configuration Required)
⛔ 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:
CODEBLOCK8
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 ID Format
Test case IDs follow the format: {IQ|OQ|PQ}-{ModulePrefix}-{Number}
| Type | Example | Description |
|---|
| IQ | INLINECODE101 | Installation Qualification test |
| OQ |
OQ-UM-001 | Operational Qualification test |
| PQ |
PQ-UM-001 | Performance Qualification test |
Auto-Sync Feature
Before generating documents, use --sync to automatically update templates with new requirements:
CODEBLOCK9
What --sync does:
- 1. Reads
requirements.json for all requirements - Groups requirements by module
- Checks if each module section exists in template
- Auto-appends new module sections if missing
- Backs up original template before modification
Sync Template to Database
Use --sync-template-to-db to extract requirements from templates and add them to requirements.json:
CODEBLOCK10
What --sync-template-to-db does:
- 1. Reads the template (e.g., urs.md)
- Extracts all requirements in
| URS-xxx | description | format - Loads existing requirements.json (if exists)
- Adds new requirements that don't already exist
- Preserves existing requirements and test results
Interactive Mode
For interactive step-by-step document generation with confirmation prompts:
CODEBLOCK11
Interactive workflow:
CODEBLOCK12
Options:
- -
Enter - Execute this step - INLINECODE112 - Skip this step
- INLINECODE113 - Quit (already generated files are preserved)
Compliance Check
Run GAMP 5 compliance validation to check requirements coverage and test coverage:
CODEBLOCK13
Compliance checks performed:
- - Requirement coverage (ensures all code requirements are documented)
- High-risk module verification (IQ/OQ/PQ tests for critical modules)
- Test coverage threshold (default 80%)
Exit codes:
- -
0 - All checks passed - INLINECODE115 - Warnings present
- INLINECODE116 - Errors found
Incremental Update (Smart Rebuild)
Use --diff-only to skip regeneration when requirements haven't changed:
CODEBLOCK14
How it works:
- 1. Computes SHA256 hash of requirements after each generation
- Stores hash in
.requirements.hash in output directory - On subsequent runs, compares current hash against stored hash
- Skips generation if hash matches (requirements unchanged)
Git Hooks (Automated Compliance)
Install post-commit hooks to automatically run compliance checks after code commits:
CODEBLOCK15
What the hook does:
- - Detects commits with code or requirements changes
- Runs compliance check (non-blocking)
- Outputs warnings to stderr without blocking commit
Bidirectional Sync
Use --sync for bidirectional sync between template and requirements.json:
CODEBLOCK16
Conflict resolution:
CODEBLOCK17
Section numbering behavior:
- - Sync automatically creates module sections with
### 4.X headers - Section numbers are dynamically assigned based on existing sections in the template
- Only modules with requirements in
requirements.json will have sections created - Custom modules (e.g.,
pm_query, multi_lock) are supported and will be assigned the next available section number
Monorepo Support
For projects with multiple subprojects (monorepo structure):
CODEBLOCK18
Detected monorepo layouts:
- -
apps/, packages/, projects/, modules/, services/ directories - Each subproject with its own INLINECODE129
Template Versioning
Templates are versioned for compatibility tracking:
CODEBLOCK19
Automatic migrations:
- - Templates are automatically migrated to current version
- Version checks prevent incompatible generator/template combinations
CI/CD Integration
Use provided CI/CD templates for automated documentation generation:
GitHub Actions (templates/ci/github-actions.yml):
CODEBLOCK20
GitLab CI (templates/ci/gitlab-ci.yml):
CODEBLOCK21
Important Notes
Template Requirements Are Examples
The URS/FS/TS IDs and descriptions in templates are
examples only. For actual projects:
- 1. Review and modify template requirements based on real system needs
- Delete or replace example requirements as appropriate
- Use
--sync-template-to-db to populate initial requirements, then customize
Change-Driven Risk Assessment (GxP)
Per GxP requirements, any system change requires a risk assessment. When generating RA documents, include the change description:
CODEBLOCK22
Parsing Requirements from Code
CODEBLOCK23
Troubleshooting
Common Issues
| Issue | Solution |
|---|
| python-docx not installed | Run: INLINECODE133 |
| Encoding errors |
Ensure UTF-8 encoding in your terminal |
| Template not found | Check you are in the correct directory |
Getting Help
Run with verbose output:
CODEBLOCK24
Examples
AI Agent (Non-Interactive Mode)
For AI agents running in non-interactive mode, use --auto-add to automatically add all parsed requirements:
CODEBLOCK25
Example 1: Generate URS for CTMS
CODEBLOCK26
Example 2: Generate Risk Assessment
CODEBLOCK27
Example 3: Generate Traceability Matrix
CODEBLOCK28