Empezar
Stop Claude Code Deleting Your Files (Free)

Stop Claude Code Deleting Your Files (Free)

Free Claude Code hook for non-programmers. It blocks commands that can delete many files at once (rm -rf, Remove-Item -Recurse, del /s, wildcards, git clean -f) and asks you first when one command names several files. Includes a self-test that checks the hook really runs on your computer, and a one-page safety checklist. Tested on Windows 10 with Claude Code 2.1.280. Python 3, standard library only. MIT license. A guard rail, not a backup. #Ingeniería

Valoración
Se necesitan más valoraciones
Vendidos
4
Cómo se usa
Descargar

Stop Claude Code Deleting Your Files (Free)

A free hook, a self-test and a one-page checklist, for people who are not programmers but use Claude Code.

Why a hook

Writing "never delete my files" in CLAUDE.md is not enough. Anthropic's documentation says CLAUDE.md is context, not something Claude Code enforces. To block an action whatever Claude decides, it points to hooks.

A hook is a small script Claude Code runs before a tool, such as a shell command. It can block the action.

What's inside

  • hooks/no_mass_delete.py: the hook. Python 3, standard library only.
  • hooks/selftest.py: checks that the hook really starts and decides right on your computer. Deletes nothing.
  • hooks/settings.example.windows.json (Windows) and hooks/settings.example.json (macOS/Linux)
  • SKILL.md: optional skill check-delete-guard. Ask Claude "Is my delete guard working?" and it checks the install and explains the result. It edits no file.
  • CHECKLIST.md: one page: backup, install, check.
  • README.md: install steps for Windows, in plain words.

What it does

  • Blocks: recursive deletes (rm -rf, Remove-Item -Recurse, rd /s, del /s), deletes with a wildcard, del on a folder, git clean -f, find ... -delete, wiping disks, robocopy /mir.
  • Asks you first: one command that names two or more files (rm a.txt b.txt).
  • Lets through: deleting one named file, text that only mentions a delete, git clean -n.
  • Does not see: files deleted one at a time in separate commands, deletes inside a script file, and more. The README lists them.

Tested

  • Windows 10, Claude Code 2.1.280, Python 3.13, with both the Bash tool and the PowerShell tool.
  • 225 unit tests for this hook, all passing.

Not tested yet

  • a Windows PC without Git Bash (the settings use the exec form, which should not need it, according to Anthropic's documentation)
  • macOS and Linux
  • the Claude desktop app (Code tab) and the VS Code extension

Limits

  • A guard rail, not a guarantee. A command written another way can get past it.
  • Not a backup. Make a backup first; the README shows how.
  • After a Claude Code update, run the self-test again.

The paid kit

This hook comes from the Claude Code Safety Kit for Non-Programmers. It adds three more hooks (changes outside the project folder, sending or publishing, risky git commands), two skills (project setup, checking a "done" report), backup and install tools, and a 13-page guide. US$19, one-time purchase: Claude Code Safety Kit for Non-Programmers.

MIT license. Not affiliated with or endorsed by Anthropic. "Claude" and "Claude Code" are trademarks of Anthropic.