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.4.tar.gz (45.9 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.4-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: shieldprompt-0.1.4.tar.gz
  • Upload date:
  • Size: 45.9 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.4.tar.gz
Algorithm Hash digest
SHA256 1afbed5b51f9c85e116fd14161567c4e7234cbee6f692c24fbed8d733dc8943a
MD5 9afa3e00700a5b99d257db2a3d64ddb4
BLAKE2b-256 951751a9cdf8c28db03a6b6180fea693080c2652e647aa0210d04db8e27abefc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: shieldprompt-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 23.6 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 39e134338292438d1a8b31c9646bbec1bb4ae4809dcf2170403ef3c1022fde37
MD5 f4ab9bef1c429153166b71211afc3421
BLAKE2b-256 91fe048f963d1030f0405c9e5d4c56cae9f189c47cd66ed3e5b1dbd99dc78442

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