prompt-scrub v1.0.0: a local-first scrubber for prompts and their responses #76
LottieOxford
announced in
Annoucements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Built by the Nano Collective, a community collective building AI tooling not for profit, but for the community.
This is the first public release of
prompt-scrub, a small Node.js utility that runs entirely on your machine. It detects identifying content inside a prompt (emails, paths, secrets, phone numbers, URLs, postal addresses, and a couple of opt-in categories), replaces each finding with a stable placeholder likeEmail_1orPath_2, and lets you rehydrate the model's response back to the original values locally after it comes back.The motivation is simple: most accidental identifier leakage to a cloud LLM lives in the text of the prompt and the text of its response. Stripping it there, deterministically, before the prompt leaves your machine is a useful layer in a privacy posture, and one that does not need a network round-trip, a new account, or a hosted service to work.
What it actually does
The package exposes two functions and a CLI.
scrub()takes either a plain string or an array of{ role, content }messages, runs the configured detectors over the text, replaces each finding with a category-namespaced placeholder, and returns the scrubbed content plus a session id:You send
scrubbedContentto whatever LLM provider you already use. When the response comes back,rehydrate()walks the text, looks up each placeholder in the session map, and swaps them back. Unknown placeholders (placeholder text the model hallucinated, or placeholders from a previous session) are passed through unchanged and surfaced as warnings so you can decide whether to trust them:The session id is the link between the two steps. It points at a small JSON file under your OS config directory that holds the placeholder-to-original mapping. The file is written atomically, with restrictive permissions, and includes a corrupt-file quarantine path so a half-written map does not silently disable rehydration. The location is overridable via the
PROMPT_SCRUB_CONFIG_DIRenvironment variable.Detectors
Eight detectors ship in the box.
On by default:
Off by default, opt-in:
URL detection also accepts a trusted-host allowlist with subdomain matching, so internal services you control can pass through without a placeholder if that is what you want. Overlapping detector findings (an email that looks like a URL fragment, say) resolve by a documented priority order, with longer span winning on ties. Determinism is deliberate: the same input and session always produce the same scrubbed output, which keeps provider prompt-cache prefixes byte-stable.
The CLI
A small command-line wrapper around the same logic. The recommended workflow is
inspectfirst, thenscrub:inspectis the part we want people to actually use. It does not write a session file and it prints a SHA-256 hash of the scrubbed output so you can verify byte-stable cache prefixes across runs:Extensibility
Two extension points:
customDetectorsinScrubOptions). Each one returns matches in the same shape the built-ins do, so they slot into the same priority / span logic.package.json, merged into the active set, and visible inrules list. This is the path for sharing detectors across projects without forking the package.What this is, and what it is not
prompt-scrubreduces identity leakage at the content layer. It is partial defence, not anonymity, and the README and the Threat Model are explicit about the distinction because the distinction matters.It does defend against:
It partially mitigates:
Email_1instead of your address. That is materially less identifying, but not zero, and a determined provider can still correlate across a session if it has access to its own logs.ls,git log,cat, andgrepoutputs are scrubbed before the next LLM turn. Coverage is limited to the configured detectors.It does not defend against:
A user who believes this tool makes them anonymous is worse off than one who never used it, because they stop reading their prompts and trust the defaults. Always use
inspectfirst. The Threat Model document spells out the full picture in one place.Install
The package is open source under the project's licence. Source, full docs, and the Threat Model live at the repo:
https://github.com/Nano-Collective/prompt-scrubber
Feedback wanted
This is the first public release. The things we would most like to hear about:
Issues and PRs are welcome at the repo. There is also a Nano Collective Discord for the wider conversation about what the collective is building and why.
Beta Was this translation helpful? Give feedback.
All reactions