Binary Mutation Guard
Reads only a bounded prefix without following symlinks, recognizes NUL and common binary signatures, and prevents text Write or Edit tools from corrupting those files.
Runs on
Scope
$npx @youdede/toolkit add binary-mutation-guard --target claude-code
What it does
Block text-editor mutations against existing binary or binary-signature files.
When it fires
- implementation
- pre-commit
How it behaves
Block text-editor mutations against existing binary or binary-signature files.
It does not block normal binary-producing build commands.
It does not classify UTF-16 text or JSON notebooks as binary solely by extension.
It does not repair, convert, or inspect full binary contents.
Configuration
targets/claude-code/binary-mutation-guard.mjs
- Version
- 1.0.0
- Requires
- node
- Licence
- RiskThis automatic gate blocks text-editor mutations against existing binary or binary-signature files; a false denial can interrupt legitimate work, but it does not execute the blocked action.
- Medium
- ModeHow it works: fixed rules, model instructions, or both.
- Deterministic only
- Behaviour
- Enforces, blocks on violation
- On failure
- Denies and blocks
- LatencyThe entrypoint handles one intercepted event to block text-editor mutations against existing binary or binary-signature files without deferred work.
- Immediate
- Data retentionWhether data remains after use and who manages its storage.
- Not retained
Often used with
All in Development