Skip to main content

GitHub

Scan files for PHI (Protected Health Information) patterns and replace them with deterministic pseudonyms. Integrates seamlessly with pre-commit hooks.

Installation

pip install shred-guard
# or with uv
uv add shred-guard

Quick Start

Run the interactive setup wizard:

shredguard init

This walks you through:

  • Selecting PHI patterns to detect (SSNs, emails, MRNs, custom patterns)
  • Configuring file restrictions
  • Setting up pre-commit hooks

Commands

shredguard init

Interactive setup wizard. Creates your configuration and optionally sets up pre-commit integration.

shredguard check

Scan for PHI patterns:

shredguard check .                    # Scan current directory
shredguard check data/ notes.txt     # Scan specific paths

Output uses ruff-style formatting:

patient_notes.txt:1:9: SG001 Subject ID [SUB-1234]
patient_notes.txt:2:6: SG002 SSN [123-45-6789]

shredguard fix

Replace PHI with pseudonyms:

shredguard fix .                                    # Replace with REDACTED-0, REDACTED-1, ...
shredguard fix --prefix ANON .                     # Custom prefix: ANON-0, ANON-1, ...
shredguard fix --output-map mapping.json .         # Save original -> pseudonym mapping

Replacements are deterministic: the same value always gets the same pseudonym within a run.

shredguard audit

Scan every commit on every local branch for PHI patterns:

shredguard audit                          # Audit all local branches
shredguard audit --include-remotes        # Also scan remote-tracking branches
shredguard audit --output report.json     # Custom output file path

Configuration and .gitignore are locked to the current working-tree state so results are reproducible. The config and .gitignore files must have no uncommitted changes before running. Output is written to a timestamped JSON file (shredguard-audit-<timestamp>.json).

Configuration

Configuration lives in pyproject.toml (or a standalone shredguard.toml):

[tool.shredguard]

[[tool.shredguard.patterns]]
regex = "SUB-\\d{4,6}"
description = "Subject ID"

[[tool.shredguard.patterns]]
regex = "\\b\\d{3}-\\d{2}-\\d{4}\\b"
description = "SSN"

Each pattern can optionally include files and exclude_files globs to control which files are scanned.

Pre-commit

Add to .pre-commit-config.yaml:

repos:
  - repo: local
    hooks:
      - id: shredguard-check
        name: shredguard check
        entry: shredguard check
        language: system
        types: [text]

Or let shredguard init set this up for you.

CLI Reference

shredguard check [OPTIONS] [FILES]...

Option Description
--all-files Scan all files recursively
--no-gitignore Don't respect .gitignore patterns
--config PATH Path to config file
-v, --verbose Show verbose output (skipped files, etc.)

shredguard fix [OPTIONS] [FILES]...

Option Description
--prefix TEXT Prefix for pseudonyms (default: REDACTED)
--output-map PATH Write JSON mapping of originals to pseudonyms
--all-files Scan all files recursively
--no-gitignore Don't respect .gitignore patterns
--config PATH Path to config file
-v, --verbose Show verbose output

shredguard audit [OPTIONS]

Option Description
--include-remotes Also scan remote-tracking branches
--output PATH Path for audit JSON output (default: shredguard-audit-<timestamp>.json)
--no-gitignore Don't respect .gitignore patterns
--config PATH Path to config file
-v, --verbose Show verbose output (skipped binary files, etc.)

Exit Codes

Code Meaning
0 Success (no matches found)
1 Matches found or error

License

MIT

Metadata

Release files for shred-guard 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shred-guard 1.1.0
File Size Uploaded Provenance
shred_guard-1.1.0.tar.gz 795.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for shred-guard 1.1.0
File Interpreter ABI Platform
shred_guard-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 819.6 kB

Release files / shred_guard-1.1.0.tar.gz

Download URL shred_guard-1.1.0.tar.gz
Size 795.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ef618030f7275e566ae51f071a470620656a3c6aeb48ed81d09be3d9a34cae66
BLAKE2b-256 checksum
How to use checksums
bbe7ed7dc67ec3fb503a1f8a75f768c56c0011c8dfc35314dd014bbc97db1104
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 13, 2026.

Transparency log

Release files / shred_guard-1.1.0-py3-none-any.whl

Download URL shred_guard-1.1.0-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b4a10b335fc13ed800d2f26720373f3a4a1875985d4d889fc9e7fdc5c9b8351
BLAKE2b-256 checksum
How to use checksums
78ce26aeb40edea3f8dcbad3ba41aec82e07943fe7f3bf84a74b966fbeae0f48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 13, 2026.

Transparency log

Security for shred-guard 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for shred_guard-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page