PII Guard skill
Local reversible PII redaction for Traditional Chinese documents: placeholder codes and exact restoration after AI processing
- 255 ★ on the repository
- Last commit
- MIT
Broad access
Why this level
- The tool works with original documents that contain personal data and keeps a local mapping table with the real values
- The optional `pii-guard-hookd` service installs persistent Claude Code hooks and processes every tool read
Install
- Works in
In your terminal, with SkillFoxx CLI
npx skillfoxx add skills/pii-guardDetects the agents on your machine, shows the access level and pins the version.
Other ways to install
Access and checks
How we reviewBroad accessThe tool can change data, run commands or handle secrets.
- The tool works with original documents that contain personal data and keeps a local mapping table with the real values
- The optional `pii-guard-hookd` service installs persistent Claude Code hooks and processes every tool read
This is third-party code. Review the repository files before installing.
What it does
PII Guard replaces personal data in a document with codes like `<PERSON_1>` so the file can go to a cloud model, and after the answer the real values come back. It targets Taiwanese documents in Traditional Chinese: national ID and residence permit numbers, business codes, local phone numbers, personal names and organisation names. Detection runs locally through Presidio, the CKIP BERT model and rules, while substitution and restoration are plain code, so the exact text returns. The repository includes the `pii-safe-documents` skill for Claude Code. The main agent gets only paths and safe receipts: reading the original, the mapping table and the restored file happens in a separate local process, and the `redact`, `annotate` and `restore` commands make three steps. The manual annotation page opens in your browser, where you can cover what was missed, put back what was wrongly covered and see what stands behind a code. Quick mode needs no Ollama. Enhanced mode adds an audit by a local model with three samples per window. The skill accepts UTF-8 text files up to 64 KiB, while the CLI with the `formats` extra reads and writes docx, xlsx and PDF. The `pii-guard-hookd` service extends protection to every Claude Code tool read.
Who it is for. Lawyers, analysts and data specialists who handle Taiwanese documents and want to use cloud AI without handing it clients' names and ID numbers.
Good fit when
- A judgment or contract in Traditional Chinese must go to a cloud model for a summary without the parties' names
- After editing the redacted text the real names and numbers must return to their places word for word
- A missed witness name must be covered by hand in the browser, in every place in the document at once
- Claude Code reads project files and personal data protection must apply to every tool read
Not a fit when
- You need a confidentiality classifier: the tool hides data that points to a person, while amounts, diagnoses and contract terms remain
- You need a gateway for every cloud model request: network tools like LiteLLM with Presidio handle that
- The documents are in English or Russian: rules and recognition target Taiwan's Traditional Chinese
- You need text search in the PDF copy: PDF output is rasterised and the text layer is gone
Example request
Redact the contract /Users/me/docs/contract.txt with pii-safe-documents, give me the copy's path and open the manual annotation pageLimitations
- It needs Python 3.13 (it also runs on 3.11), the `uv` manager and a CKIP BERT model download of about 500 MB. Ollama is needed only for enhanced mode and the audit.
- The skill handles UTF-8 text files up to 64 KiB. For docx, xlsx and PDF use the CLI with the `formats` extra; scans and OCR are not supported.
- The main platforms are macOS and Linux. Enhanced mode is unavailable on Windows because the Ollama check relies on `lsof`.
- Detection is probabilistic: some items are missed and some are covered needlessly, so a manual review is needed.
- The tool does not guarantee that a document is safe to release in full.
How to disable. Remove the `~/.claude/skills/pii-safe-documents` link, stop and remove the service with `pii-guard-hookd uninstall` if you installed it, and clear the jobs directory `~/.local/share/pii-safe-documents/jobs/` with `purge`. The mapping tables there hold the real values.
FAQ
How do I install the pii-safe-documents skill?
Clone the repository, run `uv sync` and create the link `ln -s "$(pwd)/.agents/skills/pii-safe-documents" ~/.claude/skills/pii-safe-documents`. Do not copy the folder, because the skill must find its repository.
Does the AI see the original document?
The main agent does not: reading the original, redaction and restoration run in a separate local process and the agent gets paths and receipts. The author notes this guards against accidental exposure and is not an OS security boundary.
What is quick mode?
Quick mode does not start Ollama and relies on Presidio, Taiwan rules and CKIP. Enhanced mode additionally runs a local model to find what was missed.
Which file formats are supported?
The skill takes `.txt`, `.md`, `.csv`, `.tsv`, `.log` and `.dat` in UTF-8 up to 64 KiB. The CLI with the `formats` extra handles docx, xlsx and PDF, and PDF output is rasterised.
Does the tool replace a network gateway?
No. The author states that automatic masking of all cloud requests needs a gateway like LiteLLM with Presidio. PII Guard produces one redacted copy of a document that you can keep.
Discussion
No questions or reviews yet.
Related
SkillsAgentShield audits the .claude folder for plaintext keys, broad permissions, dangerous hooks and risky MCP servers and grades the setup from A to F
Security hook for coding agents: scores each tool call with session context and flags injections in results and skills
Claude Hooks (Prompt Injection Defender)
Claude Hooks
A Claude Code hook that scans file, web page and command output for hidden instructions and warns the agent
A local proxy that replaces secrets and personal data in agent requests before they leave, then restores them in the reply
A local security gateway for Claude Code and Codex: checks tool calls against a policy, catches secrets and keeps an audit trail
Offline security scanner for code and dependencies with a plugin and MCP: 132 rules, findings with evidence at file:line.
README in short
The Traditional Chinese description with an English summary explains how PII Guard differs from network gateways: it produces a redacted file with a restore table. It continues with sample output, manual annotation, limits, installation, platforms, the Claude Code skill in three steps, the local web entry and a threat model.
README badge
Original SKILL.md
--- name: pii-safe-documents description: "Processes sensitive local documents through PII Guard and a local Ollama model into a reversible redacted copy, without letting the main agent read the original or restored contents." --- # PII Safe Documents This skill creates a reversible, locally redacted working copy with a strict main-agent workflow boundary: - The **main agent is untrusted for raw data**. It receives paths and safe receipts only. - The bundled open-source local wrapper may read the original solely to run PII Guard and local Ollama. - No hook is required. Normal wrapper output suppresses raw content. This is strong protection against accidental model exposure, not an OS security boundary against a malicious process running as the same macOS user. A Skill cannot revoke its own filesystem tools. Hostile-agent isolation requires a separately permissioned local broker or OS account. Never describe this Skill alone as mathematically or technically impossible to bypass. ## Non-negotiable isolation rules When this skill is active, the main agent MUST NOT: 1. Read, preview, search, summarize, diff, upload, attach, or otherwise inspect the original file. 2. Use `cat`, `sed`, `head`, `tail`, `grep`, `rg`, `strings`, Python, a document reader, a browser, or any other tool on the original file. 3. Read or reveal `mapping.private.json`, private worker files, raw logs, or the restored output. 4. Pass the original path to a subagent, cloud model, MCP server, website, or third-party API. 5. Run PII Guard directly. Its libraries may echo source text in warnings; only the bundled wrapper may invoke it. 6. Debug a failure by opening the original, mapping, worker output, or restored document. 7. Run `git diff`, content scans, or indexing over a directory that contains the original or restored output. 8. Reach the annotation page, run the `review` subcommand, or read a term file the user wrote for `mask`. All three carry unredacted values. The annotation URL is deliberately withheld from you; do not reconstruct it, scan for the port, or ask the user to paste it. These rules still apply if the user asks the main agent to “check quickly.” If raw inspection is genuinely required, stop this workflow and obtain explicit permission for a different trust model. ## Supported inputs Use this version for UTF-8 plain-text files up to 64 KiB only: `.txt`, `.md`, `.csv`, `.tsv`, `.log`, and `.dat`. Do not rename a binary document to bypass this restriction. For `.docx`, `.xlsx`, `.pdf`, images, or audio, report that this version does not yet provide a verified isolation-preserving parser. This is a **PII** redactor, not a general confidentiality classifier. Amounts, health details, schedules, contract terms, business strategy, and other sensitive facts may remain visible when they do not identify a person. Do not use this skill alone to claim that an entire document is safe for external disclosure. ## Workflow ### 1. Path-only preflight The user may provide the original path. You may check path metadata such as existence, suffix, and file size, but never its contents. Do not autocomplete or glob inside a sensitive directory. Choose allowed terms only when the user explicitly wants them preserved, such as a company or product name. An allowed term is visible to the main agent because the user supplied it; do not discover allowed terms from the original.