Armory
Source
Browse
Hooks

env-file-protection

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.

Score
Unranked
Evidence
No signals yet
Last commit
Not known
Listed

Install

armory install env-file-protection --cli claude

writes the file to.claude/hooks/env-file-protectionListed as compatible

Configuration
# fetches the hook script into:
.claude/hooks/env-file-protection
# then register it in your settings.json "hooks" block.

↳ Add the hook entry to settings.json, then restart the harness.

Needs the armory CLI · not on npm yet, build it from cli/ in the repository

What it is

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.

When to use it

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.

How to install / invoke

# Wire this hook script into .claude/settings.json
curl -sL https://raw.githubusercontent.com/davila7/claude-code-templates/main/cli-tool/components/hooks/security/env-file-protection.json -o .claude/hooks/env-file-protection.json

Notes

Extracted from davila7/claude-code-templates, security category.