To stop an AI coding agent from deleting files on a Mac, use three layers. Commit your work often. Tighten the agent's own permission settings. Then put an approval gate in front of destructive commands and keep snapshots you can restore.
Layer 1: commit before you hand over the keyboard
Version control is the first safety net. Commit or stash before a long agent session. Files that were never committed, such as a local .env file or new work, are the ones a bad command destroys for good.
Layer 2: use the agent's own permissions
Most coding agents can ask before running shell commands or editing files. Leave those prompts on for anything outside reading, building and testing. The weakness is fatigue. After the fiftieth prompt, people approve without reading.
Layer 3: gate the dangerous commands
AgentGate is a Mac app from Rivets Software that sits between the agent and your Mac. Known read, build and test commands pass without interruption. These stop for an approval card:
- Destructive commands such as rm -rf, git reset --hard, force pushes, DROP TABLE and sudo.
- Reads of secrets, such as SSH keys or a .env file.
- Commands hidden in Base64, hex or URL encoding. The card shows the decoded command.
- An agent trying to edit its own hooks or quit AgentGate.
You approve with Touch ID, Apple Watch or your Mac password. If nobody answers, the card blocks the command, so a background agent does not slip through.
Undo what got through
Before a supported file-edit tool runs, AgentGate snapshots the project. Each prompt that changed files gets a restore point on a timeline. You can restore one file, bring back a deleted one, or rewind the whole project. The folder a rewind replaces is kept for 7 days.
Which agents are covered
Coverage is not the same for every agent, so check yours on the AgentGate product page.
- Claude Code has the fullest coverage, with approval cards on every tool call and snapshots.
- Codex CLI and Gemini CLI were tested for blocking an unanswered deletion and for snapshots before file writes.
- Cursor, Windsurf and Claude Desktop have no tool hooks. Only their MCP servers are covered.
Know the limits
- It is a guardrail, not a virtual machine. It runs as you, alongside the agent. It makes harm much harder and leaves a record. It does not make harm impossible.
- It protects only while it is running.
- It runs on macOS 14 or later, on Apple silicon and Intel.
What it costs
There is a free 3-day trial. After that it is $79 once for one Mac, with a 30-day refund.
Frequently asked questions
Can I undo an rm -rf an AI agent already ran?
Only if a copy exists. Check your last commit, Time Machine or another backup. AgentGate can restore from its own snapshots, but only for changes made while it was protecting the project.
Does it slow the agent down?
Routine commands such as tests, builds and file reads pass silently. Only risky actions wait for you.
Does it need a kernel extension?
No. It works through each agent's own hook and MCP settings. Unprotect removes its entries from your settings file.
What else does Rivets make for Mac?
See the guide to searching offline external drives on a Mac for another example.
