healthcare-phi-compliance — Claude Code skill: what it does
PHI and PII security patterns for healthcare systems under HIPAA, GDPR, and DISHA. Helps configure RLS, audit logging, and stop data leaks in URLs or logs.
npx skills add affaan-m/ECC --skill healthcare-phi-compliance -a claude-codeWhat healthcare-phi-compliance does
This skill guides AI coding assistants through data classification, row-level access control, and audit trail implementation for medical software. It covers sensitive patient information (PHI) alongside clinician personal data (PII), giving concrete SQL patterns for Row-Level Security in multi-facility setups.
It also enforces checks against routine leak vectors. The rules flag patient identifiers in query strings, stack traces, console logging, and browser storage like localStorage. Instead, the skill requires opaque internal UUIDs, server-side-only logging, and explicit schema tagging with SQL comments.
Install this whenever building clinical workflows or APIs handling patient records. If your codebase does not touch healthcare records or strict regulatory data, these constraints will just add unnecessary friction.
What it helps with
- configure Row-Level Security policies to isolate patient records by facility
- build an insert-only, tamper-proof audit trail for record access
- sanitize API error messages and logs to prevent PHI exposure
- tag database schema columns with PHI and PII classifications
Example prompts for the agent
- Check this API endpoint for potential PHI leaks in error responses
- Generate an RLS policy in PostgreSQL to restrict patient access by facility
- Run the pre-deployment healthcare compliance checklist on this pull request
How to install healthcare-phi-compliance
1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill healthcare-phi-compliance -a claude-code2Manually: put the files in place
~/.claude/skills/healthcare-phi-compliance/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/healthcare-phi-compliance/
1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill healthcare-phi-compliance -a codex2Manually: put the files in place
.agents/skills/healthcare-phi-compliance/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill healthcare-phi-compliance -a cursor2Manually: put the files in place
.cursor/skills/healthcare-phi-compliance/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install affaan-m/ECC healthcare-phi-compliance2Manually: put the files in place
.github/skills/healthcare-phi-compliance/SKILL.md1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill healthcare-phi-compliance -a gemini-cli2Platform CLI
gemini skills install https://github.com/affaan-m/ECC --path skills/healthcare-phi-complianceManually: put the files in place
.devin/skills/healthcare-phi-compliance/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill healthcare-phi-compliance -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set146
The whole set →Similar
Questions about healthcare-phi-compliance
How to install healthcare-phi-compliance in Claude Code?
Run npx skills add affaan-m/ECC --skill healthcare-phi-compliance -a claude-code. The rule is placed into ~/.claude/skills/healthcare-phi-compliance/SKILL.md.
What healthcare regulations does this skill cover?
The rules address HIPAA in the US, DISHA in India, GDPR in the EU, and general clinical data governance practices.
How does the skill handle data leaks in front-end code?
It forbids storing PHI in localStorage or sessionStorage and bans clinical IDs in URL parameters, requiring in-memory state and opaque UUIDs.
Source text
SKILL.md · MIT
---
name: healthcare-phi-compliance
description: "Protected Health Information (PHI) and PII compliance patterns for healthcare applications: data classification, row-level access control, tamper-proof audit trails, schema tagging, and common leak vectors such as logs, URLs, and browser storage. Use when code touches patient or clinician data, when implementing HIPAA or GDPR access controls, or when auditing a healthcare system for data exposure."
metadata:
version: "1.0.0"
origin: Health1 Super Speciality Hospitals — contributed by Dr. Keyur Patel
---
# Healthcare PHI/PII Compliance Patterns
Patterns for protecting patient data, clinician data, and financial data in healthcare applications. Applicable to HIPAA (US), DISHA (India), GDPR (EU), and general healthcare data protection.
## When to Use
- Building any feature that touches patient records
- Implementing access control or authentication for clinical systems
- Designing database schemas for healthcare data
- Building APIs that return patient or clinician data
- Implementing audit trails or logging
- Reviewing code for data exposure vulnerabilities
- Setting up Row-Level Security (RLS) for multi-tenant healthcare systems
## How It Works
Healthcare data protection operates on three layers: **classification** (what is sensitive), **access control** (who can see it), and **audit** (who did see it).
### Data Classification
**PHI (Protected Health Information)** — any data that can identify a patient AND relates to their health: patient name, date of birth, address, phone, email, national ID numbers (SSN, Aadhaar, NHS number), medical record numbers, diagnoses, medications, lab results, imaging, insurance policy and claim details, appointment and admission records, or any combination of the above.
**PII (Non-patient-sensitive data)** in healthcare systems: clinician/staff personal details, doctor fee structures and payout amounts, employee salary and bank details, vendor payment information.
### Access Control: Row-Level Security
```sql
ALTER TABLE patients ENABLE ROW LEVEL SECURITY;
-- Scope access by facility
CREATE POLICY "staff_read_own_facility"
ON patients FOR SELECT TO authenticated
USING (facility_id IN (
SELECT facility_id FROM staff_assignments
WHERE user_id = auth.uid() AND role IN ('doctor','nurse','lab_tech','admin')
));
-- Audit log: insert-only (tamper-proof)
CREATE POLICY "audit_insert_only" ON audit_log FOR INSERT
TO authenticated WITH CHECK (user_id = auth.uid());
CREATE POLICY "audit_no_modify" ON audit_log FOR UPDATE USING (false);
CREATE POLICY "audit_no_delete" ON audit_log FOR DELETE USING (false);
```
### Audit Trail
Every PHI access or modification must be logged:
```typescript
interface AuditEntry {
timestamp: string;
user_id: string;
patient_id: string;
action: 'create' | 'read' | 'update' | 'delete' | 'print' | 'export';
resource_type: string;
resource_id: string;
changes?: { before: object; after: object };
ip_address: string;
session_id: string;
}
```
### Common Leak Vectors
**Error messages:** Never include patient-identifying data in error messages thrown to the client. Log details server-side only.
**Console output:** Never log full patient objects. Use opaque internal record IDs (UUIDs) — not medical record numbers, national IDs, or names.
**URL parameters:** Never put patient-identifying data in query strings or path segments that could appear in logs or browser history. Use opaque UUIDs only.
**Browser storage:** Never store PHI in localStorage or sessionStorage. Keep PHI in memory only, fetch on demand.
**Service role keys:** Never use the service_role key in client-side code. Always use the anon/publishable key and let RLS enforce access.
**Logs and monitoring:** Never log full patient records. Use opaque record IDs only (not medical record numbers). Sanitize stack traces before sending to error tracking services.
### Database Schema Tagging
Mark PHI/PII columns at the schema level:
```sql
COMMENT ON COLUMN patients.name IS 'PHI: patient_name';
COMMENT ON COLUMN patients.dob IS 'PHI: date_of_birth';
COMMENT ON COLUMN patients.aadhaar IS 'PHI: national_id';
COMMENT ON COLUMN doctor_payouts.amount IS 'PII: financial';
```
### Deployment Checklist
Before every deployment:
- No PHI in error messages or stack traces
- No PHI in console.log/console.error
- No PHI in URL parameters
- No PHI in browser storage
- No service_role key in client code
- RLS enabled on all PHI/PII tables
- Audit trail for all data modifications
- Session timeout configured
- API authentication on all PHI endpoints
- Cross-facility data isolation verified
## Examples
### Example 1: Safe vs Unsafe Error Handling
```typescript
// BAD — leaks PHI in error
throw new Error(`Patient ${patient.name} not found in ${patient.facility}`);
// GOOD — generic error, details logged server-side with opaque IDs only
logger.error('Patient lookup failed', { recordId: patient.id, facilityId });
throw new Error('Record not found');
```
### Example 2: RLS Policy for Multi-Facility Isolation
```sql
-- Doctor at Facility A cannot see Facility B patients
CREATE POLICY "facility_isolation"
ON patients FOR SELECT TO authenticated
USING (facility_id IN (
SELECT facility_id FROM staff_assignments WHERE user_id = auth.uid()
));
-- Test: login as doctor-facility-a, query facility-b patients
-- Expected: 0 rows returned
```
### Example 3: Safe Logging
```typescript
// BAD — logs identifiable patient data
console.log('Processing patient:', patient);
// GOOD — logs only opaque internal record ID
console.log('Processing record:', patient.id);
// Note: even patient.id should be an opaque UUID, not a medical record number
```
© affaan-m · MIT · affaan-m/ECC