Academic Dataset Sanitization and Scrubbing Script
Automate data scrubbing, PII redaction, and schema validation for sensitive academic research datasets.
Use this template when preparing raw experimental, educational, or survey data for public release or multi-institution collaboration. It generates a robust, standalone data sanitization script ensuring strict privacy compliance.
Role: Senior Research Software Engineer specializing in reproducible data pipelines.
Context
- Raw survey and experimental data format: {{source_data_format}}
- Explicit direct and indirect identifiers requiring removal: {{pii_fields_to_redact}}
- Target execution runtime and language: {{target_environment}}
- Institutional governance and compliance threshold: {{retention_policy_rules}}
- Volume and record batch size: {{dataset_size_scale}}
- Quality assurance and statistical integrity standards: {{validation_criteria}}
Task
Construct a standalone, idempotent data sanitization and anonymization script that ingests raw participant records, strips restricted attributes according to research governance standards, and outputs clean analytical datasets ready for peer-reviewed distribution.
Method
- Parse input flags and configure stream buffers for {{dataset_size_scale}} processing.
- Inspect record schemas to verify structural compatibility with {{source_data_format}}.
- Apply deterministic hashing or zeroing functions to all targets identified in {{pii_fields_to_redact}}.
- Implement pseudo-identifier generalization aligned with {{retention_policy_rules}} without distorting variance.
- Execute pre-write validation checks against {{validation_criteria}} to guarantee schema completeness.
- Generate an immutable cryptographic manifest containing input hashes and output record counts.
- Write sanitized records safely to target destination using atomic write operations.
Constraints
- MUST implement zero-dependency standard libraries where feasible in {{target_environment}}.
- MUST NOT log or expose plaintext entries from {{pii_fields_to_redact}} in stdout, stderr, or debug logs.
- Include structured error handling with non-zero exit codes on integrity failure.
- The script must be fully self-contained and ready to execute via CLI.
Output format
Provide the response in two distinct sections:
- Executable Script: Clean, fully commented script code with robust CLI parameter handling.
- Operational Runbook: Markdown block detailing installation, execution syntax, exit codes, and verify instructions (maximum 200 words).
Self-review
- Verify every variable from {{source_data_format}} to {{validation_criteria}} is explicitly referenced.
- Check that no PII leakage paths exist in error stack traces or verbose logging flags.
- Confirm all code syntax is syntactically valid for {{target_environment}}.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.