healthcare-phi-compliance

Implements PHI and PII protection patterns for healthcare applications using RLS, audit trails, and encryption.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill healthcare-phi-compliance-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: healthcare-phi-compliance
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/healthcare-phi-compliance
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill healthcare-phi-compliance-freedom909

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Healthcare applications routinely leak patient data through error messages, logs, URLs, and weak access control. This Skill provides concrete patterns to classify sensitive data, enforce row-level access, and maintain tamper-proof audit trails so patient and clinician information stays protected. ## Core Features & Use Cases - Data Classification: Defines what counts as PHI and PII, including patient identifiers, medical records, clinician payout data, and financial details. - Row-Level Security Policies: Provides SQL policies for multi-facility isolation and insert-only audit logs that cannot be modified or deleted. - Leak Vector Prevention: Covers common exposure points such as error messages, console output, URL parameters, browser storage, and service role keys. - Use Case: When building a multi-tenant hospital system, apply the facility isolation RLS policy so a doctor at Facility A querying Facility B patients receives zero rows, and verify it with the included test pattern. ## Quick Start Review my patient records API code and database schema for PHI exposure risks and apply the appropriate compliance patterns.

Frequently Asked Questions about healthcare-phi-compliance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement row-level security for patient data?▼

Enable RLS on the patients table and create policies scoping access by facility through a staff_assignments lookup. The policy checks that the authenticated user's facility_id matches the patient's facility, restricting reads to authorized roles like doctor, nurse, or admin.

What data counts as PHI in a healthcare application?▼

PHI is any data that identifies a patient and relates to their health: name, date of birth, address, phone, national ID numbers, medical record numbers, diagnoses, medications, lab results, insurance details, and appointment records, or any combination of these.

How do I make an audit log tamper-proof in SQL?▼

Create an insert-only policy on the audit_log table tied to the authenticated user, then add UPDATE and DELETE policies that always evaluate to false. This ensures audit entries can be written but never modified or removed.

Can I store patient data in localStorage or sessionStorage?▼

No, PHI must never be stored in browser storage. Keep patient data in memory only and fetch it on demand, since localStorage and sessionStorage persist data that can be exposed through scripts or browser inspection.

Why should service role keys never appear in client-side code?▼

Service role keys bypass Row-Level Security entirely, exposing all patient records to anyone who extracts the key from client code. Always use the anon or publishable key so RLS policies enforce per-user access control.

What are the limitations of RLS-based access control?▼

RLS enforces database-level isolation but does not protect against leaks in application layers like error messages, logs, or URL parameters. It must be combined with safe logging practices, opaque UUIDs, and server-side error sanitization.