For Claude Code · Cursor · Codex
Your AGENTS.md says “never”.
Your agent doesn’t have to listen.
Prose rules are suggestions. Hooks are enforcement. Paste a command or your agent file and see, in seconds, which of your “nevers” nothing actually enforces. Runs entirely in your browser.
- 40 tested rules
- 247 self-tests
- 0 bytes uploaded
Pick what to protect. You get real, working files (free core rules).
Save guard-lite.mjs to .nightlatch/ in your repo, then merge the settings file. Needs Node 18+. Restart your agent afterwards.
Want these as files? Get the free starter rules by email: three tested hooks (rm -rf, force push, .env) for Claude Code and Cursor, a Codex rules file and a test script. Enter $0 on Gumroad.
Why your rules file isn’t enough
Prose is optional
CLAUDE.md, AGENTS.md and Cursor rules are context. In long sessions, after a confusing error, or when a README says “run this to fix it”, the model can ignore them.
Hooks are not
Claude Code PreToolUse, Cursor beforeShellExecution and Codex prefix_rule run on every call, whatever the model decides. Deny means it never runs.
Static rules miss things
Bash(git push -f *) doesn’t catch cd app && git push origin main -f. A guard that reads the whole command does.
Why not just the built-in settings?
You should use them. Claude Code has permission deny and ask rules, Cursor has hooks, and Codex has prefix rules and a sandbox. What the kit adds:
Rules already written
40 rules across 9 risk areas, each with must-match and must-not-match tests (247 in total). You don’t start from an empty settings file.
One rule set, three tools
The same rules wired into Claude Code, Cursor and Codex, so you maintain one list instead of three formats.
Checks the actual command
A hook script reads the whole command, so rm -fr, git -C . push -f and cd x && … are caught. A prefix rule only matches the form you wrote.
Plus secret-file blocking across file reads and shell commands, and a pre-commit secret scanner. It isn’t a sandbox. For untrusted code, keep your tool’s sandbox on as well.
Guides
The full kit
Nightlatch Agent Guardrails Kit
One rule set, enforced in Claude Code, Cursor and Codex. Installs in 5 minutes, merges with your existing config, uninstalls cleanly.
Free tool
- 21 core rules, single-file guard
- Claude Code + Cursor config
- AGENTS.md audit
Kit
- 40 rules across 9 risk categories, each with tests (247 total)
- Installer: dry-run, safe JSON merge, backups, uninstall
- Codex prefix rules + sandbox config
- Policies: standard / strict (unattended runs) / sandbox, per-team and per-dev overrides
- Audit log of every blocked attempt
- Secret scanner: pre-commit hook + GitHub Actions workflow
- Guardrail-tamper protection + CODEOWNERS template
- AGENTS.md / CLAUDE.md templates for Next.js, FastAPI, Node API, Go, monorepos
- 4 incident playbooks (deleted work, leaked secret, overnight runs, reviewing agent PRs) + 2 worksheets
FAQ
How do I block dangerous commands with Claude Code PreToolUse hooks?
Add a PreToolUse hook with matcher "Bash" in .claude/settings.json that runs a script. Claude Code sends the tool call as JSON on stdin; the script returns permissionDecision "deny" (or "ask") with a reason. Nightlatch's generator above writes both the settings entry and a working guard script.
How do Cursor beforeShellExecution hooks work?
Cursor runs every command listed under beforeShellExecution in .cursor/hooks.json before the agent executes a shell command. The hook gets the full command on stdin and answers with permission "allow", "ask" or "deny". Exit code 2 also blocks. The free generator outputs a ready hooks.json.
What is a Codex prefix_rule?
Codex reads Starlark .rules files (for example ~/.codex/rules/default.rules). Each prefix_rule matches a command prefix such as ["git", "push", "--force"] and sets decision to allow, prompt or forbidden. The Nightlatch kit ships a tested rules file plus a workspace-write sandbox config.
Are AGENTS.md guardrails enough to stop an AI agent?
No. AGENTS.md, CLAUDE.md and Cursor rules are instructions the model usually follows, not enforcement. Hooks and permission rules run on every tool call regardless of what the model decides. Use the auditor above to find which of your "never" rules nothing enforces.
Does anything I paste leave my browser?
No. The checker, auditor and generator are plain JavaScript running on this page and never send what you type or paste. The only request the page makes is a page-view count: the page path, the referring site and your country. No cookies are set, no IP address is stored, and visitors with Do Not Track or Global Privacy Control on are not counted.
Will it slow my agent down?
The guard is a single Node process with no dependencies; a check takes a few milliseconds plus Node start-up (~40 ms).
What if a rule blocks something I actually need?
Every block names its rule id. Disable it, downgrade it to "ask", or allow the exact command in .nightlatch/policy.json.
Is this a sandbox?
No, and the docs say so. Pattern guards stop the common, catastrophic and prompt-injected cases. For untrusted code, use it together with a container or your tool's sandbox.
Does it work on Windows?
The guard is Node, so it runs anywhere Node 18+ does. The git pre-commit hook needs Git for Windows (which ships sh).
Can I get a refund?
If it doesn't work in your setup, reply to the Gumroad receipt within 14 days for a full refund.