How to block AI coding agents from running rm -rf, force push and other banned commands A new blog post lays out a three-layer approach to stopping AI coding agents from executing destructive commands such as `rm -rf`, `git push --force` and `prisma migrate reset`: server-side branch protection on GitHub or GitLab, per-agent deny rules and hooks in Claude Code, Codex and Cursor, and containment in a container, disposable VM or fresh clone. The post promotes Harbor, a tool that enforces team guardrails at command-execution time across Claude Code, Codex, Cursor and GitHub Copilot and, rather than issuing a bare denial, tells the agent the sanctioned alternative — for example substituting `prisma migrate dev` for `prisma migrate reset`. Harbor's hook fails open if it errors, and the post advises keeping branch protection and sandboxes in place and testing a banned command in a test repo via `harbor check "git push --force"` before relying on it; `npx harborloop init` is free for one teammate. Blog How to block AI coding agents from running rm -rf, force push and other banned commands Published An agent with shell access will eventually try a command you wish it hadn't. Use layers. Layer 1: the server Turn on branch protection on GitHub or GitLab. Disable force pushes on main and release branches and require pull requests. This holds even if an agent tries. Layer 2: each agent's own settings - Claude Code: deny rules in settings and PreToolUse hooks that inspect a command before it runs Claude Code hooks https://gethrbr.com/blog/claude-code-hooks . - Codex: execution rules that forbid a command or require approval a forbidden Codex rule https://gethrbr.com/blog/why-codex-ignores-agents-md . - Cursor: use the Allowlist run mode, so only the commands you list run without approval. Cursor's docs call the allowlist best-effort, not a security boundary. The Cursor CLI also takes deny rules. The catch: these are set per tool and per machine. With a mixed team, the lists drift. Layer 3: containment Run agents in a container, a disposable VM or a fresh clone. Keep backups. Containment limits damage when a rule is missed. Where Harbor fits Harbor holds an agent to your rules at the moment it runs a command, and tells the agent what to do instead. Example: your team bans prisma migrate reset because it wipes every row. You turn on a guardrail for it and write the remedy on it: a migration made with prisma migrate dev . Harbor blocks the command and points the agent to the remedy. The banned command never runs. That last part matters. A bare “denied” leaves the agent guessing, and it often retries a variant. A block that names the alternative gets the task done. You also do not start the list from a blank page. Harbor suggests guardrails from what your team already wrote: a rule that names the command, a deny entry in a repo's .claude/settings.json , or a package script that runs it. A person turns each one on, and it reaches Claude Code, Codex, Cursor and GitHub Copilot on every teammate's machine guardrails https://gethrbr.com/docs/guardrails . Caveats - Harbor does not replace server-side branch protection or sandboxes. Keep both for the worst case. Harbor's hook fails open: if it errors, the call runs. - Check your own setup by trying a banned command in a test repo before you rely on it. harbor check "git push --force" prints which guardrail stops a command and what the agent will read. Try it Run npx harborloop init . It is free for you and one teammate, no card. Questions How do I stop an AI coding agent from running rm -rf or git push --force? Use layers. Turn on branch protection so force pushes to main fail on the server. Set each agent's own controls: deny rules and PreToolUse hooks in Claude Code, forbidden execution rules in Codex, the Allowlist run mode in Cursor. Run agents in a container, a disposable VM or a fresh clone. Harbor adds one guardrail that refuses the command in Claude Code, Codex, Cursor and Copilot and tells the agent what to run instead. Does Cursor have a deny list for terminal commands? Not in the IDE, by its current docs. The run modes are Auto-review, Allowlist and Run Everything, and the docs call the allowlist best-effort, not a security boundary. The Cursor CLI takes deny rules in its permissions config. Why tell the agent what to run instead of only denying the command? A bare denial leaves the agent guessing, and it often retries a variant of the same command. A refusal that names the sanctioned route, such as a migration made with prisma migrate dev instead of prisma migrate reset, gets the task done.