Commit d26420ad4c6 for woocommerce
commit d26420ad4c6ff39ec7cca7853954e1fa96ab2cc5
Author: Thomas Roberts <5656702+opr@users.noreply.github.com>
Date: Tue Mar 31 17:48:44 2026 +0100
Add Claude Code hook to block edits to generated/built files (#63951)
Prevents AI agents from accidentally editing files in build output
directories (build/, build-module/, build-style/, build-types/, dist/)
or auto-generated .asset.php files. The hook runs as a PreToolUse
check on Write|Edit operations and blocks with a message directing
to edit the source instead.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
diff --git a/.claude/settings.json b/.claude/settings.json
index a3d1e4eaeff..31e41d951fa 100644
--- a/.claude/settings.json
+++ b/.claude/settings.json
@@ -10,5 +10,18 @@
],
"deny": [],
"ask": []
+ },
+ "hooks": {
+ "PreToolUse": [
+ {
+ "matcher": "Write|Edit",
+ "hooks": [
+ {
+ "type": "command",
+ "command": "jq -r \".tool_input.file_path // empty\" | { read -r f; if echo \"$f\" | grep -qE \"/(build|build-module|build-style|build-types|dist)/|[.]asset[.]php$\"; then printf '{\"decision\":\"block\",\"reason\":\"This is a generated/built file. Edit the source instead.\"}'; fi; }"
+ }
+ ]
+ }
+ ]
}
}