Policy file guard
A Claude Code PreToolUse gate for Write and Edit that protects existing lint, format, dependency, and ownership configuration from in-session modification.
Runs on
Scope
$npx @youdede/toolkit add policy-file-guard --target claude-code
What it does
Stop an agent from silently weakening existing quality and ownership policy files.
When it fires
- implementation
- maintenance
How it behaves
Evaluate structured runtime input and deterministically allow or block the guarded operation.
It does not decide that a policy change is legitimate on the agent's behalf.
It does not modify protected configuration or expose agent-writable exceptions.
It does not inspect or block files outside the active project root.
It does not intercept shell commands that modify a policy file.
Configuration
targets/claude-code/policy-file-guard.mjs
- Version
- 1.0.0
- Requires
- node
- Licence
- RiskThis automatic gate stops an agent from silently weakening existing quality and ownership policy 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 stop an agent from silently weakening existing quality and ownership policy files without deferred work.
- Immediate
- Data retentionWhether data remains after use and who manages its storage.
- Not retained
Often used with
All in Development