Nightlatch / Guides
Guardrail guides for AI coding agents
Copy-paste configs for Claude Code, Cursor and Codex. Every script on these pages is checked by a test script before it is published.
How to block rm -rf in Claude Code with a PreToolUse hook
A tested PreToolUse hook script and settings.json that stop Claude Code from running rm -rf, rm -fr, rm -r -f and sudo rm -rf, even inside && chains and bash -c.
Claude Code (also works in Cursor)
Stop the Cursor agent from reading .env files with a beforeReadFile hook
A tested Cursor hooks.json and script that block the agent from reading .env, .env.local and .env.production through file reads and shell commands, while .env.example stays readable.
Cursor (also works in Claude Code)
Codex CLI rules: prefix_rule examples that block dangerous commands
Copy-paste Codex .rules file with prefix_rule examples for git push --force, rm -rf, git reset --hard and npm publish, checked with codex execpolicy check. Includes the limits of prefix matching.
Codex CLI
Stop AI coding agents from running git push --force
One tested hook script for Claude Code and Cursor, plus Codex prefix rules, that block git push --force, -f and +refspec pushes while allowing --force-with-lease. With branch protection as the backstop.
Claude Code · Cursor · Codex
Keep Claude Code out of your .env files
Read deny rules for .env files in Claude Code settings.json, what they cover and miss according to the docs, and a tested PreToolUse hook that blocks source .env, cp .env and similar shell commands.
Claude Code