/code-health:privacy-filterfrom Code Health
Local on-device PII filter using OpenAI opf (1.5B MoE). Detects and redacts 8 PII categories (email, phone, address, etc.) before sending text to cloud LLMs. Supports reversible redaction for safe round-trip de-identification and re-identification.
Ships in Code Health. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
opf)Local, on-device PII filter. A 1.5B-param bidirectional token classifier (50M active, sparse MoE) that labels and redacts personal data in one forward pass. Runs on the your GPU (or CPU). Everything stays on the machine — nothing leaves for the cloud.
Primary use: de-identify text locally, then safely send the obezlichenny version to a cloud LLM (Claude/GPT). Optionally re-identify the LLM's answer afterwards.
account_number · private_address · private_email · private_person ·
private_phone · private_url · private_date · secret
git clone https://github.com/openai/privacy-filter ./work/privacy-filter-opf
pip install -e ./work/privacy-filter-opf
First run auto-downloads the checkpoint (2.7 GB) from openai/privacy-filter to
~/.opf/privacy_filter; transformers + ONNX formats land in
~/.cache/huggingface/hub/models--openai--privacy-filter.
Wrapper shipped with this skill: scripts/privacy_filter.py.
CRITICAL (Windows / no-Triton): the MoE kernels default to a Triton path on CUDA and crash with
ModuleNotFoundError: triton. The wrapper setsOPF_MOE_TRITON=0automatically (pure-PyTorch fallback, still GPU). If callingopf/from opf import OPFdirectly, exportOPF_MOE_TRITON=0first.
cd ~/.claude/skills/privacy-filter
# Detect + see labelled spans as JSON
python scripts/privacy_filter.py "John Doe, [email protected], +1234567890" --format json
# Redact a file to text (default placeholders <PRIVATE_EMAIL> etc.)
python scripts/privacy_filter.py -f letter.txt --out letter.clean.txt
# Pipe usage
type doc.txt | python scripts/privacy_filter.py
Always use real Windows paths (C:/Users/...), never /tmp — Git Bash mangles
POSIX paths into MSYS paths. Output files are always written UTF-8.
The model's default placeholders are not unique (<PRIVATE_PERSON> repeats), so they
can't be restored. --reversible assigns unique tokens ([PRIVATE_PERSON_1], …),
reuses the same token for repeated values (keeps coreference), and writes a restore map.
Round-trip is byte-exact (verified).
# 1. De-identify locally, keep the map private
python scripts/privacy_filter.py -f contract.txt --reversible \
--map map.json --out contract.clean.txt
# 2. Send contract.clean.txt to the cloud LLM. Instruct it to KEEP placeholders verbatim.
# 3. Re-identify the LLM's answer locally (no model load needed)
python scripts/privacy_filter.py --restore --map map.json -f llm_answer.txt --out final.txt
map.json contains real PII → keep it local, never send it anywhere.
| Flag | Default | Notes |
|---|---|---|
--device auto|cpu|cuda | auto | cuda if available |
--decode viterbi|argmax | viterbi | viterbi = coherent spans; argmax = faster, noisier |
--label-mode typed|redacted | typed | redacted collapses all to <REDACTED> |
--reversible + --map FILE | off | unique tokens + restore map |
--restore + --map FILE | off | re-identify, no model load |
--checkpoint DIR | ~/.opf/privacy_filter | or set $OPF_CHECKPOINT |
--format text|json | text | json includes spans + summary |
-f FILE (repeatable), --out FILE | — | model loads once for all -f files |
import os; os.environ.setdefault("OPF_MOE_TRITON", "0") # before importing opf
from opf import OPF
opf = OPF(device="cuda", output_mode="typed", decode_mode="viterbi")
r = opf.redact("Alice [email protected]")
r.redacted_text # "<PRIVATE_PERSON> <PRIVATE_EMAIL>"
[(s.label, s.text, s.start, s.end) for s in r.detected_spans]
opf) — eval & fine-tuneopf "Alice was born on 1990-01-02." # one-shot (uses GPU; set OPF_MOE_TRITON=0)
opf redact -f file.txt --format json
opf eval dataset.jsonl # metrics vs ground truth
opf train train.jsonl --output-dir ckpt/ # fine-tune
Out-of-the-box recall on Russian is roughly two-thirds. Strong: emails, URLs, dates, phones, account numbers. Weak: person names (patronymics/diminutives split or missed — e.g. «Фамилия | Имя Отчество» detected as two spans), addresses (partial spans), secrets (novel formats missed). OpenAI reports fine-tuning on just 10% in-domain data lifts F1 0.545 → 0.962.
For any RU production use: evaluate on your own data and fine-tune. See
references/finetuning-ru.md for the dataset schema, opf train/opf eval recipes,
and calibration tips.
secret is the weakest category — do not rely on it alone for credentials. Combine
with regex/entropy scanners for API keys.--decode viterbi (default) over argmax.Use ONLY openai/privacy-filter (HuggingFace) and github.com/openai/privacy-filter.
A typosquat double (Open-OSS/privacy-filter) shipped an infostealer and got 244k
downloads in 18h. Never pip install or download a "privacy-filter" from any other org.
references/model-card.md — architecture, decoding/operating points, output schema,
browser/ONNX + transformers.js usage. Read when tuning precision/recall or deploying
in a browser/JS app.references/finetuning-ru.md — Russian fine-tuning: JSONL schema, opf train/eval,
custom label spaces, calibration. Read before fine-tuning or evaluating on RU data.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub jhamidun/claude-code-config-pack --plugin code-health9 skills in this plugin
/config-healthЗдоровье конфига Claude Code: битые ссылки, вес промпта, лимит памяти, живость MCP. Триггеры: «проверь конфиг», «вес промпта». НЕ чужой скилл→skill-manager; НЕ код→health-inline/health-inlineЧинит codebase health инлайн: /health bugs|cleanup|deps|reuse|security — детекция→фикс→верификация. Только pnpm+TypeScript-репо. НЕ одна красная сборка→build-fix./leak-scanPII/деанон перед публикацией (leak_scan.py) + prompt-injection в чужом скилле (skill_injection_scan.py). Триггеры: «обезличь репо», «проверь скилл перед установкой»./osint-reconРазведка инфраструктуры домена/IP CLI osint_client.py: DNS, whois, субдомены, порты/CVE, санкции. Триггеры: «пробей домен». НЕ люди→social-intel./security-auditSecurity-аудит: секреты в коде, pip/npm audit, OWASP Top 10. Триггеры: «аудит безопасности», «проверь на уязвимости». НЕ активный пентест→агент security-engineer (режим PENTEST)./skill-auditЗаглушка: проверка чужого скилла/плагина до установки переехала в skill-manager, режим «Аудит». Сам не вызывается, держит старые ссылки живыми.Other plugins' skills for the same job