By Vero SecurityBuilt and funded by Vero Security, the AI Security Engineering platform.Read the charter

Guarding .env and .git with a PreToolUse hook

A short script reads the tool call JSON, checks the target path against patterns such as .env, package-lock.json and .git/, and exits with code 2 plus a reason on stderr. The agent gets the reason as feedback and the edit never runs. You can write and test one after reading.

Read in this order

  1. OfficialBlock edits to protected files (Claude Code hooks guide)A worked script that matches protected paths and blocks the edit with exit code 2.

Save your progress

We email you a sign-in link. No password.

By signing in you agree to the terms. The privacy policy explains how we use your details.

Join the AI security engineering community

Free. Roadmap updates, chapters near you, and first word when credentials open.

We’ll email you community updates. Unsubscribe anytime. By sending this you agree to the terms. The privacy policy explains how we use your details.