Stop Claude Code from deleting files
Put a check in front of every shell command Claude Code runs. ThumbGate denies the broad deletes by default. When the agent deletes something you wanted, you give it a thumbs-down: ThumbGate warns the next time it tries that command, and after three thumbs-downs on the same command, strict mode blocks it.
Updated 27 November 2026. Behavior below was checked against ThumbGate 1.49.1 with a fresh install and no learned rules.
What goes wrong in practice
Coding agents delete files to tidy up: a build folder, a "temporary" directory, a cache, or untracked files that look like leftovers. Most of the time that is fine. The damage comes from the few times the target is wrong, too broad, or holds work that was never committed. Instructions in CLAUDE.md help, but the agent can still ignore them. A hook runs before the command, whatever the agent decides.
What ThumbGate checks before a command runs
- Default gates. A fixed set of destructive commands is denied before it runs, with no setup beyond install.
- Learned rules. A thumbs-down on a command records it. The next time the agent tries the same command, ThumbGate warns. After three thumbs-downs on the same command, strict mode blocks it.
- The same delete in Python. In strict mode, once a delete rule is blocking, the same literal path deleted through Python (
shutil.rmtree,os.remove,Path(...).unlinkand similar) is denied too.
What it catches, and what it misses
| Command | Fresh install | Notes |
|---|---|---|
rm -rf ~, rm -rf / | Denied | Default gate for broad deletes on home or root. |
git clean -fdx | Denied | Can delete untracked work. |
git reset --hard | Denied | Can discard uncommitted changes. |
rm -rf ./build | Warns | A narrow delete is allowed with a risk warning. A thumbs-down turns it into a learned rule. |
find . -name "*.log" -delete | Warns | Allowed with a risk warning. A thumbs-down turns it into a learned rule. |
| A Python delete of a path ThumbGate has never seen | Allowed | Only caught when it matches a learned, blocking delete of the same literal path. |
| A reworded delete, or a path built at run time | Not caught | Variables, joined paths and scripts the gate cannot read are outside what it checks. |
To see these decisions on your own machine without running anything, run npx thumbgate decision-check. It passes 32 sample commands through the default gates and prints allow, warn or block for each.
ThumbGate is not a sandbox and does not retrain the model. Keep version control and backups for anything you can't lose.
Compared with a hand-written hook
You can write your own Claude Code PreToolUse hook with a list of patterns to refuse, and free guard hooks do the same. That works well for a fixed list. ThumbGate starts from a similar fixed list, then adds rules from your own thumbs-downs, so a delete that hurt you once is checked next time without you editing a script. Neither approach understands what an arbitrary script will do when it runs.
Install
Install the ThumbGate Claude Code plugin, then run:
npx thumbgate init --agent claude
See install for other agents. Outside Claude Code, most integrations only advise and do not guarantee a block.
Pricing
The local CLI is free (MIT): the default gates, 3 learned rules and 2 thumbs a day (10 in total) after a 7-day Pro trial. Pro keeps every learned rule active. Teams can request a 30-day team pilot.