Files
dev 278ecca018 Add ctxguard: hook-enforced context sanitization
Keeps credentials, company names, personal names and PII out of the model's
context. Enforcement lives in Claude Code hooks rather than in instructions to
the agent: a skill alone cannot protect anything, because by the time the agent
reads a rule the surrounding context has already been sent.

Credentials are removed irreversibly and marked. Entities from a user-supplied
dictionary become stable aliases, rewritten back to real values on their way to
disk and to the shell, so code and commands referring to them still work.

Published from a clean tree; development history is not included.
2026-09-16 11:33:09 +03:00

27 lines
1.2 KiB
Markdown

---
description: Protect a company name, person, hostname or project codename behind a stable alias
---
Register a value in the ctxguard dictionary so it is replaced by an alias everywhere
before it reaches the model, and restored on the way back to disk.
Arguments: `$ARGUMENTS` — the value, optionally followed by a type.
Run:
```
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/ctxguard.py" entity add "<value>" --type <company|person|host|project|email|phone|custom> [--match stem] [--hint "<safe description>"]
```
Guidance:
- Use `--match stem` for Russian names and any word that inflects, so that
`Петров / Петрова / Петровым` all match.
- `--hint` is injected into the model's context verbatim, so it must describe the
entity without repeating it ("retail customer", not "Globex is a customer"). The
command rejects a hint containing the value.
- Add spelling variants with repeated `--variant` (transliterations, abbreviations).
Afterwards show the new alias and run `entity list` so the user can see the whole
dictionary. Never print the value back to the user's terminal — they typed it, but the
transcript is exactly what we are trying to keep clean.