Block Claude Code from dangerous commands

The short answer

A simple hook that greps for rm -rf misses bash -c '…', $(…), an env-var prefix or git -C. Scopebond splits a shell command into every program it will run and blocks the call if any part breaks a rule. The starter rules cover destructive programs, force-pushes to protected branches and reads of key and secret files. In a workspace, force-pushes to protected branches and secret-file reads are blocked from the start; every other rule starts in Monitor, so you see what it would block; switch it to Block and it stops the command before it runs.

Turn on protection

Install Scopebond (see Get started). In a workspace, force-pushes to protected branches, secret-file reads and changes to Scopebond itself are blocked from the start; every other rule starts in Monitor, so you see what it would block before you switch it to Block. The starter rules cover release branches, destructive programs, the agent's own keys, its CI config and .env secrets.

Why splitting the command matters

Scopebond splits a command into every program it runs (a && b, $(c), bash -c '…', env-prefixes, git -C) and blocks the whole call if any part breaks a rule.

Block, don't just watch

When a rule in Block stops an action, Scopebond tells Claude Code to block it (exit code 2), which holds even in bypass-permissions mode. When an action is allowed, Claude Code's own permission flow still applies: Scopebond blocks, and it does not approve anything on its own.

Good to know

What this does not do

Scopebond checks actions the coding agent sends through its tools. An action taken outside the agent is not covered. If the coding tool cannot start Scopebond's check, the action runs unchecked, and the Scopebond app on the computer reports it. Scopebond does not classify file contents; it decides on the action.

Alternatives

Questions

Can the agent get around a simple grep rule?

Yes, which is why Scopebond splits a command into every program it runs. A blocked program hidden behind bash -c, $(…) or an env-prefix is still caught.

Does a blocked action still run?

No. When a rule in Block stops an action, Scopebond returns exit code 2, which Claude Code treats as a block even in bypass-permissions mode.

What happens to a command Scopebond can't read?

It is recorded as not checked, so you see it in your workspace and can tighten your rules.