Skip to content
Get AI Business OS

Blocked Commands

AI Business OS

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.

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

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.

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.

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.

  1. Create .claude/rules/my-blocked-commands.md.
  2. List each command and the reason it needs confirmation.
  3. 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.