# How to stop PII and national IDs from reaching LLMs

DevFeed: [How to stop PII and national IDs from reaching LLMs](<https://devfeed.tech/articles/how-to-stop-pii-and-national-ids-from-reaching-llms-119450.md>)

Original publisher: [Read original article](<https://nirmata.com/2026/10/29/how-to-stop-pii-and-national-ids-from-reaching-llms/>)

Author: Ritesh Patel

Published: 2026-10-29T19:00:00Z

Content type: tutorial

Language: en

Sources: [Nirmata](<https://devfeed.tech/sources/nirmata.md>)

Topics: [pii](<https://devfeed.tech/topics/pii.md>), [Claude Code](<https://devfeed.tech/topics/claude-code.md>), [ner](<https://devfeed.tech/topics/ner.md>), [gateway](<https://devfeed.tech/topics/gateway.md>), [Regular expression](<https://devfeed.tech/topics/regular-expression.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-agents](<https://devfeed.tech/tags/ai-agents.md>), [ai-governance](<https://devfeed.tech/tags/ai-governance.md>), [block](<https://devfeed.tech/tags/block.md>), [checksums](<https://devfeed.tech/tags/checksums.md>), [claude-code](<https://devfeed.tech/tags/claude-code.md>), [claude-code-hooks](<https://devfeed.tech/tags/claude-code-hooks.md>), [data-protection](<https://devfeed.tech/tags/data-protection.md>), [gateway](<https://devfeed.tech/tags/gateway.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [ids](<https://devfeed.tech/tags/ids.md>), [llms](<https://devfeed.tech/tags/llms.md>), [ner](<https://devfeed.tech/tags/ner.md>), [pii](<https://devfeed.tech/tags/pii.md>), [security](<https://devfeed.tech/tags/security.md>), [stop](<https://devfeed.tech/tags/stop.md>)

## AI overview

Keep PII from reaching an LLM by checking prompts and tool results before they leave your network, using checksum recognizers for structured IDs and named-entity models for names, then redacting, holding or blocking matches. Coverage depends on checking each route: Claude Code's UserPromptSubmit can block but cannot rewrite typed prompts; PreToolUse can alter tool inputs, and PostToolUse can redact results only after the tool has run. A gateway can inspect model requests routed through it, but separate scripts or MCP servers may bypass it, and gateway redaction support must be verified. Presidio's Aadhaar recognizer is disabled by default and must be added explicitly; its checksum still allows about 10% of random 12-digit numbers through, so matches need review. Detection is not complete, and hook timeouts pass prompts unless onFailure is set to block. The excerpt recommends testing with synthetic valid and near-miss numbers, starting with redaction and review, and limiting agent file access.

## Source excerpt

Stop PII and national IDs reaching LLMs: detect them with checksums and NER, then redact, hold or block each match in Claude Code hooks or at a gateway.