AI agent skill for HIPAA compliance - PHI/PII detection, code scanning, audit reports, and remediation guidance
SaferSkills independently audited hipaa-guardian (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
A comprehensive PHI/PII detection and HIPAA compliance skill for AI agents, with a strong focus on developer code security patterns. Detects all 18 HIPAA Safe Harbor identifiers in data files and source code, provides risk scoring, maps findings to HIPAA regulations, and generates audit reports with remediation guidance.
This skill activates from natural-language requests ("scan this repo for PHI", "check our logs for patient data", "audit for HIPAA compliance"). Map the request to the script that handles it and run it directly. There is no single hipaa-guardian dispatcher; each task is its own script.
| Task | Script |
|---|---|
| Scan data files for PHI/PII | scripts/detect-phi.py <path> |
| Scan source code for PHI leakage | scripts/scan-code.py <path> |
| Find PHI endpoints with no auth gate | scripts/scan-auth.py <path> |
| Find PHI in log statements | scripts/scan-logs.py <path> |
| Find unmasked PHI in API responses | scripts/scan-response.py <path> |
| Build an audit report from findings | scripts/generate-report.py <findings.json> |
| Check project security controls | scripts/validate-controls.sh <path> |
Each script writes to stdout (or a file with -o) and exits 0 (clean), 1 (high findings), or 2 (critical findings), so CI can gate on the exit code.
-f, --format <json|markdown|csv> - Output format (default: markdown)-o, --output <file> - Write results to a file-s, --severity <low|medium|high|critical> - Minimum severity to report--include <patterns> / --exclude <patterns> - File patterns to scan--synthetic - Mark all findings as synthetic/test data-v, --verbose - Verbose outputscan-code.py, scan-auth.py, scan-logs.py, and scan-response.py take <path> plus -f/--format (json or markdown), -o/--output, and -v/--verbose.
When invoked, follow this workflow:
Ask the user to specify:
Use Glob to find relevant files:
# For data files
Glob: **/*.{json,csv,txt,log,xml,hl7,fhir}
# For source code
Glob: **/*.{py,js,ts,tsx,java,cs,go,rb,sql,sh}
# For config files
Glob: **/*.{env,yaml,yml,json,xml,ini,conf}For each file, scan for the 18 HIPAA identifiers using patterns from references/detection-patterns.md:
Classify each finding:
The scanners score each finding risk = min(100, sensitivity × confidence), where sensitivity is the identifier's base weight (an SSN outweighs a ZIP) and confidence is how strongly the value matched its pattern. Scores map to severity: 90+ critical, 70+ high, 50+ medium, 25+ low, otherwise informational.
references/risk-scoring.md documents a fuller multi-factor model (sensitivity, exposure, volume, identifiability) for scoring a finding by hand or justifying a rating in a report. The scanner uses the simpler proxy above.
Map findings to HIPAA rules from references:
references/privacy-rule.md - 45 CFR 164.500-534references/security-rule.md - 45 CFR 164.302-318references/breach-rule.md - 45 CFR 164.400-414Create structured output following examples/sample-finding.json format:
{
"id": "F-YYYYMMDD-NNNN",
"timestamp": "ISO-8601",
"file": "path/to/file",
"line": 123,
"field": "field.path",
"value_hash": "sha256:...",
"classification": "PHI|PII|sensitive_nonPHI",
"identifier_type": "ssn|mrn|dob|...",
"confidence": 0.95,
"risk_score": 85,
"hipaa_rules": [...],
"remediation": [...],
"status": "open"
}When scanning source code, look for:
.env files with PHISee references/code-scanning.md for detailed patterns.
Verify these controls are in place:
.gitignore excludes sensitive filesStructured array of all findings with full metadata.
Human-readable report with:
Step-by-step remediation guide:
references/hipaa-identifiers.md - All 18 HIPAA Safe Harbor identifiersreferences/detection-patterns.md - Regex patterns for PHI detectionreferences/code-scanning.md - Code scanning patterns and rulesreferences/healthcare-formats.md - FHIR, HL7, CDA detection patternsreferences/privacy-rule.md - HIPAA Privacy Rule (45 CFR 164.500-534)references/security-rule.md - HIPAA Security Rule (45 CFR 164.302-318)references/breach-rule.md - Breach Notification Rule (45 CFR 164.400-414)references/risk-scoring.md - Risk scoring methodologyreferences/auth-patterns.md - Authentication gate patterns for PHI endpointsreferences/logging-safety.md - PHI-safe logging patterns and filtersreferences/api-security.md - API response masking and field-level auth# Install the pre-commit hook
cp scripts/pre-commit-hook.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
# Or using pre-commit framework
# Add to .pre-commit-config.yaml:
repos:
- repo: local
hooks:
- id: hipaa-guardian
name: HIPAA Guardian PHI Scan
entry: python scripts/detect-phi.py
language: python
types: [file]
pass_filenames: true# Configure pre-commit behavior
export HIPAA_BLOCK_ON_CRITICAL=true # Block commits with critical findings
export HIPAA_BLOCK_ON_HIGH=true # Block commits with high severity findings
export HIPAA_SCAN_DATA=true # Scan data files
export HIPAA_SCAN_CODE=true # Scan source code
export HIPAA_VERBOSE=false # Enable verbose output# .github/workflows/hipaa-scan.yml
name: HIPAA PHI Scan
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run PHI Scan
run: |
python scripts/detect-phi.py . --format markdown --output phi-report.md
- name: Upload Report
uses: actions/upload-artifact@v4
with:
name: phi-scan-report
path: phi-report.md| Format | Extensions | Detection |
|---|---|---|
| FHIR R4 | .fhir.json, .fhir.xml | Resource type, identifiers |
| HL7 v2.x | .hl7, .hl7v2 | MSH, PID, DG1 segments |
| CDA/C-CDA | .cda, .ccda, .ccd | ClinicalDocument, patientRole |
| X12 EDI | .x12, .edi, .837 | Transaction set headers |
Patient - Demographics, identifiers, contactsCondition - Diagnoses, health conditionsObservation - Lab results, vitalsMedicationRequest - PrescriptionsDiagnosticReport - Test resultsPID - Patient Identification (SSN in PID-19)DG1 - Diagnosis InformationOBX - Observation/Result ValuesIN1 - Insurance Informationexamples/sample-finding.json - Example finding output formatexamples/sample-audit-report.md - Example audit reportexamples/synthetic-phi-data.json - Test data for validationscripts/detect-phi.py - PHI/PII detection in data files (supports FHIR, HL7, CDA formats)scripts/scan-code.py - Code scanning for PHI leakagescripts/scan-auth.py - Authentication gate detection for PHI endpointsscripts/scan-logs.py - PHI detection in logging statementsscripts/scan-response.py - API response PHI exposure detectionscripts/generate-report.py - Report generation scriptscripts/validate-controls.sh - Control validation scriptscripts/pre-commit-hook.sh - Git pre-commit hook for CI/CD integration~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.