Rules the agent cannot break Recommended
Block dangerous actions with hooks
Use the agent's hooks or permission rules to block actions that must never happen, instead of trusting instructions.
How to do it
Most agents can run a script before a tool call and stop it. Claude Code, for example, blocks a call when a PreToolUse hook exits with code 2. Block force pushes, deleting folders, editing applied migrations and reading secret files. Commit the settings so the whole team gets them.
Example
#!/bin/bash
# .claude/hooks/block-dangerous.sh, run before every shell command
command=$(jq -r '.tool_input.command')
if [[ "$command" =~ (push\ --force|rm\ -rf\ /|DROP\ TABLE) ]]; then
echo "Blocked by project policy: $command" >&2
exit 2
fi
How to check
Ask the agent to run a blocked command, such as git push --force. The hook stops it and the agent reports the reason.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers ai development playbook: https://agentwranglers.se/playbook/ai-assisted-development/rules-the-agent-cannot-break/blocking-hooks.