Back to Hooks

Env File Protection

Hooks security 282 Scanned by NVIDIA SkillSpector

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.

Install Command
npx claude-code-templates@latest --hook security/env-file-protection
View on GitHub
claude-code — env-file-protection

Scanned by NVIDIA SkillSpector

Automated static analysis (no LLM) · v2.12.0 · 2026-10-17

3 observations
scanner score 26/100

SkillSpector looks for patterns such as shell commands, credential access, network calls or unpinned dependencies. An observation is something worth reading in the files before you install, not a confirmed vulnerability. Components that run code locally, like hooks, MCP servers and security tooling, naturally show more of them.

  • Credential Access
    Privilege Escalation · SKILL.md:3
  • Credential Access ×2
    Privilege Escalation · env-file-protection.json:2

Learn more about NVIDIA SkillSpector.

Content

JSON
{
"description": "Prevent writing to .env files using the if condition for lightweight filtering. ..."
"hooks": {
"PreToolUse": [1 item]
}
}

Stack Builder

0 components

Your stack is empty

Browse components and click the + button to add them to your stack for easy installation.