Seamless PII Redaction and Restoration
Paste the following prompt into your AI chat to install this skill:
Please install @user_d4c41464/pii-redact according to https://skillhub.cn/install/skillhub.md.
About this skill
Problem
When sending user input, logs, or ticket content to an LLM, the text may contain PII such as ID numbers, phone numbers, bank card numbers, emails, detailed addresses, and names. Sending raw text increases exposure, while manual redaction is error-prone and still requires restoring placeholders in the response. This skill replaces 17 PII types before the request and restores them after the LLM returns, so callers see placeholders while end users still see the original values.
How It Works
It centers on redact.py and restore.py. Before sending, it applies rule-based matching and replaces sensitive fields with short placeholders, for example 身份证****1234, 手机****5678, 邮箱****, and [金额已脱敏]. After the response, it uses a mapping to restore the placeholders. It supports ID cards, passports, officer IDs, permits, tax numbers, mobile numbers, landlines, emails, bank cards, license plates, WeChat IDs, QQ IDs, addresses, amounts, and names. It requires Python 3.x, with 3.8+ recommended. It is suitable for LLM-facing gateways, proxies, or server-side call chains.
Boundaries
Names require context keywords such as “我”, “甲方”, or “乙方”; landlines must include the - separator; bank card numbers need preceding keywords like “银行”, “账号”, or “卡号”; detailed addresses match administrative keywords or province/city/district/street patterns. The mapping is a temporary file and should be cleaned up after the session.
Use Cases
- Redact customer chat and ticket text before sending it to an LLM for summarization or routing.
- Replace names, bank card numbers, and ID numbers in contract or support records before calling an external model.
- Mask multi-turn user messages before storing logs or vector entries, then restore placeholders for display.
- Hide amounts, tax numbers, and license plates in business text before feeding it to a model for extraction.
Best For
- Customer-support platform engineers integrating external LLMs who want chat messages redacted before model calls.
- Backend developers building agent services who need PII placeholders applied before requests and restored after responses.
- Compliance engineers reviewing contracts, tickets, or chat logs who need names, card numbers, and addresses masked.
- Data-cleaning algorithm engineers who need phone numbers, emails, and amounts converted to safe placeholders.
Related Skills
Run a grilling session to interact with or test AI agents.
A systematic prompt optimization skill that refines prompts using a four-step distillation framework (diagnose, structure, think, compress) and methodologies from four prompting masters.
Tencent Cloud OCR agent for K-12 exam grading with async full-sheet or single-question marking, handwritten answer recognition, correctness, knowledge points, and coordinates.
Quickly converts a user's input, list, or screenshot into a multi-page workbench, supporting template selection, custom builds, and responsive layouts.