Stop Claude Code from deleting your tests with a PreToolUse hook
This story is from 2026-11-27. It is preserved in the archive; the latest stories are on the live feed.
A write guard can protect .env and dist . It will not stop Claude Code from "cleaning up" a failing test with rm , git rm , or an empty Write. A PreToolUse hook can refuse those deletions so the model has to fix the test instead. The hook should name the blocked path and exit 2 . The hook Save this…
Read the full story at DEV Community — AI ↗
Timeline · 1 report
- 2026-11-27 00:54 · DEV Community — AI
Stop Claude Code from deleting your tests with a PreToolUse hook