Every week, another AI wrapper or internal RAG tool accidentally leaks a production sk-proj-... key, customer SSN, or database URI to a third-party LLM provider—or gets tricked by a <|im_start|>system delimiter injection.
Most teams either ignore the problem or add a heavy 300ms external guardrail API call on every request.
To solve this locally in <1ms with zero runtime dependencies, I built PromptShield Pro—a local-first LLM Security Firewall, Reversible PII Redactor, Multi-Model Cost Simulator, and 30-Template Production System Prompt Vault.
🛡️ What It Catches Locally
16+ Credential & PII Formats (with Reversible Redaction):
Scans for OpenAI (sk-proj-...), Anthropic (sk-ant-...), Gemini, AWS (AKIA...), GitHub, Stripe, and Slack keys, PostgreSQL/MongoDB connection URIs, JWTs, Luhn-verified credit cards, SSNs, and emails—replacing them with[REDACTED_...]tokens before calling the LLM and restoring them afterward viarestoreRedacted().Multi-Layer Prompt Injection & Obfuscation Firewall:
Detects direct instruction overrides, DAN/DevMode personas, system prompt extraction attempts, XML/ChatML delimiter spoofing, markdown image webhook exfiltration, Base64-encoded instructions, and invisible zero-width character steganography.Deterministic Prompt Compressor & Linter:
Strips conversational filler and lints missing JSON schemas or unisolated{{variables}}, saving 15%–35% on input tokens.Multi-Model Cost & Prompt Caching Simulator:
Compares monthly spend and prompt-caching savings across GPT-4o, o3-mini, Claude 3.7 Sonnet, Gemini 2.5 Pro/Flash, DeepSeek V3, and Llama 3.3 70B.
💻 Quick Example (Zero Dependencies in Node.js >= 18)
const { scanAndRedact, inspectPromptSecurity, compressPrompt } = require('./src/index');
// 1. Mask API keys, DB URIs, and PII before calling any LLM API
const { redactedText, vaultMap } = scanAndRedact(userPrompt);
// 2. Block Prompt Injections, Delimiter Escapes & Base64 Jailbreaks
const security = inspectPromptSecurity(redactedText);
if (security.blocked) {
throw new Error(`Blocked adversarial prompt (${security.riskLevel})`);
}
// 3. Strip token bloat & wrap in hardened XML data boundary
const { compressedText } = compressPrompt(redactedText);
🚀 Try the Free CLI Starter or Grab the Complete Toolkit
I've released a Free Starter Edition ($0+) with the CLI scanner, 5 starter system prompts, and the 30-case Red-Team benchmark suite, alongside the PromptShield Pro Complete Toolkit ($29) which includes the Offline Interactive Web Studio (studio/index.html) and all 30 Schema-Enforced Production System Prompts across 6 engineering categories:
👉 Download PromptShield Lite (Free) or PromptShield Pro on Gumroad
Would love any feedback from the community on additional secret formats or adversarial injection patterns you'd like to see added!
Top comments (0)