Env File Protection
Hooks security 243
Prevent writing to .env files using the if condition for lightweight filtering. Blocks any Write tool call targeting .env* files, protecting secrets from accidental overwrites. Uses the if field to avoid spawning a process unless the file pattern matches.
npx claude-code-templates@latest --hook security/env-file-protection claude-code — env-file-protection
Content
JSON
{
"description": "Prevent writing to .env files using the if condition for lightweight filtering. ..."
"hooks": {
"PreToolUse": [1 item]
}
}