privacy-rules
GitHub用于创建、编辑、测试和管理Snow CLI隐私脱敏自定义规则,支持正则匹配与结果遮蔽。
触发场景
安装
npx skills add MayDay-wpf/snow-cli --skill privacy-rules -g -y
SKILL.md
Frontmatter
{
"name": "privacy-rules",
"description": "Use when the user wants Snow CLI to redact \/ mask \/ desensitize something specific in tool results (order numbers, employee ids, internal hostnames, customer codes, tokens with a custom format, etc.) or asks to create, edit, test, enable\/disable, or delete privacy custom rules (隐私脱敏自定义规则). Drafts a regex rule, dry-runs it on sample text, confirms with the user, then saves it through the session-command privacy-rules commands.",
"allowed-tools": "session-command-list, session-command-run, askuser-ask_question, filesystem-read"
}
privacy-rules
Help the user author privacy custom masking rules for Snow CLI. Rules live in
privacy.customRules of <project>/.snow/settings.json (scope project) or
~/.snow/settings.json (scope global) and are applied to selected tool results
in both Local Rules mode and Online API mode.
Commands (via session-command-run)
| Goal | command | args | confirm |
|---|---|---|---|
| List rules | privacy-rules.list |
--scope=project / --scope=global (optional) |
no |
| Dry-run a rule | privacy-rules.test |
JSON {"sample":"...","pattern":"...","group":0,"replacement":"","withBuiltinRules":false} or {"sample":"...","id":"<ruleId>"} |
no |
| Add / update | privacy-rules.upsert |
[--scope=global] <rule object or array> |
yes |
| Replace all | privacy-rules.set |
[--scope=global] <rule array> |
yes |
| Delete | privacy-rules.remove |
[--scope=global] <idOrName ...> or JSON string array |
yes |
| Check privacy switch | privacy |
status |
no |
args is passed through verbatim, so put raw JSON directly in it (no extra quoting).
Scope defaults to project. Project rules, when defined, fully override global ones.
Rule format
{
"id": "optional, generated when omitted",
"name": "required, short human label",
"pattern": "required JavaScript regex",
"group": 0,
"replacement": "",
"enabled": true
}
pattern: JavaScript regex syntax. A leading(?i)/(?m)/(?s)flag and(?P<name>...)named groups are also accepted (Snow App compatible). Do not use(?x)or inline flags in the middle of the pattern.group: capture group to mask;0masks the whole match. Use a group to keep the key and mask only the value, e.g.order[-_ ]?no[:=]\s*(\w+)withgroup: 1.replacement: literal text such as[ORDER]; empty masks every character with*.upsertmatches an existing rule byid, then byname, and keeps omitted fields.- Limits: name up to 120 chars, pattern up to 2000 chars, at most 200 rules per scope.
- Remember JSON escaping: the regex
\d+is written as"\\d+"inside JSON.
Workflow
- Clarify what must be hidden. Ask for 1-3 realistic sample lines (fake values are fine)
and whether the key/prefix should stay visible. Use
askuser-ask_questionwhen the target format is ambiguous. - Inspect current state:
privacy-rules.list(andprivacystatusto see whether privacy filtering is enabled at all). - Draft the narrowest regex that matches the samples. Prefer anchoring on stable prefixes/keys and word boundaries over broad character classes.
- Dry-run with
privacy-rules.teston every sample, plus at least one negative sample that must NOT match. Iterate untilmatchesis exactly what the user wants. UsewithBuiltinRules: trueto see the combined result with built-in rules. - Confirm with the user: show the final rule JSON, the scope, and the masked preview.
- Save with
privacy-rules.upsertandconfirm: true. Re-runprivacy-rules.listto verify. - Remind the user: rules only apply when privacy filtering is enabled and the tool is
selected in Privacy Settings -> Tool Results (defaults:
filesystem-read,ace-search,terminal-execute). Enabling privacy isprivacy on(also needs confirm).
Examples
Mask employee ids such as EMP-1234:
{"name": "Employee id", "pattern": "\\bEMP-\\d{4,6}\\b"}
Keep the key, replace only the order number:
{
"name": "Order number",
"pattern": "(?i)order[-_ ]?no[:=]\\s*(\\w+)",
"group": 1,
"replacement": "[ORDER]"
}
Mask internal hostnames under corp.example.com:
{
"name": "Internal host",
"pattern": "\\b[a-z0-9-]+(?:\\.[a-z0-9-]+)*\\.corp\\.example\\.com\\b"
}
Safety rules
- Never write without explicit user approval; writes require
confirm: true. - Do not paste real secrets into rules or replacements; regexes should describe the format, not embed actual sensitive values.
- Avoid catastrophic backtracking (
(a+)+,(.*)*, nested unbounded quantifiers); JavaScript regexes are backtracking and run on every masked tool result. - Prefer
upsertoverset;setreplaces the whole list of that scope. - Changing
--scope=globalaffects every project without project-level rules; ask first.
版本历史
- a9eba5f 当前 2026-11-03 02:39


