Skip to content
youdede

Generated file guard

DevelopmentHookv1.0.0

A deterministic Claude Code PreToolUse gate for Write and Edit that recognizes explicit generated-file headers, narrow generated filename conventions, and framework-owned output directories (.next, .nuxt, .svelte-kit) without treating broad build directories as generated by default.

Runs on

Scope
$npx @youdede/toolkit add generated-file-guard --target claude-code

What it does

Prevent direct agent edits to files that are conclusively generated artifacts.

When it fires

  • implementation
  • maintenance

How it behaves

Collect a bounded file header and deterministically protect confirmed generated outputs.

It does not regenerate a protected file, identify its generator, or edit its source template.

It does not classify every file under generic build or dist directories as generated.

It does not expose a project-writable policy, inline suppression, or agent-controlled exception path.

Configuration

targets/claude-code/generated-file-guard.mjsnode · read-only

Version
1.0.0
Requires
node
Licence
RiskThis automatic gate prevents direct agent edits to files that are conclusively generated artifacts; 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 prevent direct agent edits to files that are conclusively generated artifacts without deferred work.
Immediate
Data retentionWhether data remains after use and who manages its storage.
Not retained

Often used with

All in Development