Blocked Commands
Some terminal commands can delete work, rewrite history or change your whole computer. The Blocked Commands rule lists them, and Claude must have your explicit confirmation before running any of them. A hook called the safety guard backs the rule up by stopping the most dangerous commands before they run.
The rule lives in .claude/rules/blocked-commands.md. It is a critical engine file.
Commands That Need Your Confirmation
Section titled “Commands That Need Your Confirmation”| Command | Risk |
|---|---|
rm -rf |
Deletes folders and their contents without asking. Claude must confirm the path and scope |
sudo |
Runs a command with administrator rights. Claude must explain why it is needed |
git push --force |
Overwrites history on the remote. Never to main or master |
git reset --hard |
Discards uncommitted changes. Claude must confirm no work will be lost |
DROP TABLE, or DELETE FROM without WHERE |
Deletes data from a database |
Never Without an Explicit Request
Section titled “Never Without an Explicit Request”The rule also lists actions Claude never takes unless you ask for them.
- Commands that affect files outside the workspace.
- Installing software for the whole computer.
- Changing your global git settings.
- Commands that expose credentials or tokens.
How the Safety Guard Enforces It
Section titled “How the Safety Guard Enforces It”The safety guard is a hook that checks every terminal command Claude is about to run. If the command matches one of its patterns, the hook blocks it and gives Claude the reason. The hook covers most of the rule and a few patterns besides.
| Pattern | Blocked by the hook |
|---|---|
rm -rf and rm -fr |
Yes |
A command that starts with sudo |
Yes |
git push --force and git push -f |
Yes |
git reset --hard |
Yes |
DROP TABLE, or DELETE FROM with nothing after the table name |
Yes |
A script downloaded with curl or wget and piped straight into a shell |
Yes |
brew install, apt install, apt-get install, pip install -g, npm install -g |
Yes |
git config --global |
Yes |
| Files outside the workspace, exposing credentials | No, the rule alone covers these |
When the hook blocks a command, Claude tells you what it tried to run and why it was stopped. See Hooks Overview for how the hooks work and their limits.
Adding Your Own Blocked Commands
Section titled “Adding Your Own Blocked Commands”The rule is a critical file. Claude cannot edit it, and the next update overwrites any change you make by hand. To add commands of your own, follow these steps.
- Create
.claude/rules/my-blocked-commands.md. - List each command and the reason it needs confirmation.
- Start a new Claude Code session so Claude loads the file.
Your additions are a rule that Claude follows. The safety guard hook does not read this file, so it does not enforce your additions.

