Skip to main content

Privacy bridge for LLMs — mask PII before it leaves your machine.

Project description

ShieldPrompt

Stop leaking personal data to LLMs.

pip install shieldprompt

ShieldPrompt sits between your app and any Large Language Model (ChatGPT, Claude, Gemini, a local model — doesn't matter which). Before your text leaves the machine, it swaps real emails, phone numbers, names, credit cards, and other sensitive values for reversible placeholders. When the model's answer comes back, the placeholders are swapped back so your users still see the real values.

The model never sees the real data. Your users never see placeholders.


How it works

  Your text:         "Email alice@example.com about the invoice."
                                ↓ ShieldPrompt masks
  Sent to the LLM:   "Email [EMAIL_ADDRESS_1] about the invoice."
                                ↓ LLM answers
  Model reply:       "I'll draft an email to [EMAIL_ADDRESS_1]."
                                ↓ ShieldPrompt unmasks
  User sees:         "I'll draft an email to alice@example.com."

Under the hood:

  1. Detection — a hybrid engine combines deterministic regex patterns (emails, phones, credit cards with Luhn validation, SSNs, IPs, IBANs, URLs, AWS/API keys) with Microsoft Presidio + spaCy NER for contextual entities (people, organizations, locations).
  2. Masking — each detected value is stored in an in-memory vault and replaced with a stable token like [PERSON_1] or [EMAIL_ADDRESS_2].
  3. Unmasking — after the LLM responds, tokens are mapped back to the real values using the same vault. The vault is scoped to the request (or session) so data never leaks between users.

ShieldPrompt ships as:

  • a Python library (Shield, @mask_pii decorator),
  • a FastAPI middleware for automatic protection of chat endpoints,
  • a CLI (pii, retrace, shieldprompt) for one-off file masking,
  • an MCP server for Claude Code, Cursor, and other MCP-aware tools.

Getting started

See SETUP.md for installation, Claude Code integration, CLI usage, the Python API, and troubleshooting.

Contributing

See CONTRIBUTING.md. All changes land through pull requests reviewed by the project owner.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shieldprompt-0.1.3.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shieldprompt-0.1.3-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file shieldprompt-0.1.3.tar.gz.

File metadata

  • Download URL: shieldprompt-0.1.3.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for shieldprompt-0.1.3.tar.gz
Algorithm Hash digest
SHA256 581a5170d79a396452d01b20c0ac52e5a1518e51860f78f0363b4ca110f8fefd
MD5 d8c219b68e19eec00a66b7a62c4fe72f
BLAKE2b-256 374c96d2850854922c4a379dc80b43749a09708fd47e991d3986258ac752d4aa

See more details on using hashes here.

File details

Details for the file shieldprompt-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: shieldprompt-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for shieldprompt-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b26286be548c86d3c264d140dc6c225e3bab68ba03a72763c51d4c82ec1a243c
MD5 7a71e605a6c3ca6da6d571c4adba9167
BLAKE2b-256 1c558e16832dd50a227028b601227ccbd64c9c822c9c10e51c9b2bd2036bbf81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page