Protect AI coding agents from rm -rf mistakes
May 2026
AI coding agents are productive because they can run commands. That same power creates risk: an agent can delete the wrong directory, run git reset --hard, or execute a cleanup script with a bad path.
Why confirmations are not enough
Command approval prompts help, but they rely on a human noticing the mistake in time. Autonomous runs and long command sequences make that harder. A backup layer should work even when the command is approved.
Shell-level protection
oops watches commands through the shell hook and PATH-level agent mode. When a CLI agent runs rm -rf, git reset --hard, git clean -fd, rsync --delete, or a cleanup wrapper, oops backs up the affected files first.
Recommended setup
Install oops, then enable the stricter agent profile for agent-heavy workspaces:
Use protected paths for high-value folders and run oops doctor after setup. For a broader overview, read how to protect your files from AI coding agents.