Sign in
Explore
Add-ons · HookTesting & SecuritySecrets & privacySecurity auditsReviewed

security/env-file-protection

Denies any Write to .env files, so secrets are not overwritten by accident.

Kind
Hook
Works with
Claude Code
Source
Claude Code Templates @ 72e5f237f64d
Path
cli-tool/components/hooks/security/env-file-protection.json
Jobs
Guardrails
Topics
Secrets & privacy, Security audits

Credit

Made by
davila7
Original
github.com/davila7/claude-code-templates/blob/72e5f237f64d70a…
License
MIT

Listed by Skill Manifest; not made by us.

InstallInstall it by hand, following the source.
Install factsScanned 3 Nov 2026
Adds
  • Entries under `hooks` in .claude/settings.json
  • Hook on PreToolUse
Runs scripts
Yes
  • hook command runs on every matching event
Uses the network
None found
Needs secrets
None found
Source revision
72e5f237f64d
Licence
MIT
Last activity
26 Nov 2026
Source changed after the scan
Yes
  • Last push 26 Nov 2026, scanned 3 Nov 2026; read it again before you rely on this scan
Review
Reviewed

Found by a static scan of the stored text; nothing is run. “None found” is not a guarantee, so read what you install before you run it.

{
  "description": "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.",
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Write",
        "hooks": [
          {
            "type": "command",
            "if": "Write(.env*)",
            "command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"deny\",\"permissionDecisionReason\":\"Writing to .env files is blocked by hook\"}}'"
          }
        ]
      }
    ]
  }
}