mishoko

Claude Code Recursive Delete Guard — Development skill for Claude Code

Development community

Claude Code hook that blocks unquoted rm -rf $VAR and repo-root deletes, even in bypassPermissions mode.

How to install Claude Code Recursive Delete Guard

This entry records only its repository, not the path inside it, so there is no exact command to give. Open mishoko/claude-code-recursive-delete-guard and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Claude Code Recursive Delete Guard does

Claude Code hook that blocks unquoted rm -rf $VAR and repo-root deletes, even in bypassPermissions mode.

Alternatives in Development

  • Om Tidy — Self-maintenance pass — acts on every hygiene flag: archives completed work, groups loose clusters, splits ove 4.6k ★
  • Nonstop — Autonomous work mode for Claude Code 263 ★
  • Solopreneur Başlangıç Rehberi — 989 skill var 248 ★

README

claude-code-recursive-delete-guard

A [Claude Code](https://docs.anthropic.com/en/docs/claude-code) `PreToolUse` hook that blocks unsafe recursive deletes before they run, **in every permission mode, `bypassPermissions` included**.

One Python file. Standard library only. About 0.25 ms per tool call.

Install

curl -fsSL https://raw.githubusercontent.com/mishoko/claude-code-recursive-delete-guard/main/recursive_delete_guard.py -o /tmp/rdg.py \
  && python3 /tmp/rdg.py --install

`--install` does four things:

  1. copies the hook to ~/.claude/hooks/recursive_delete_guard.py,
  2. runs the self-test,
  3. backs up ~/.claude/settings.json,
  4. adds one PreToolUse entry.

Running it again changes nothing, and existing hooks are kept. Restart open Claude Code sessions afterwards.

To check that it's live, ask Claude to run `true || rm -rf /tmp/probe-$$`. The `rm` can never execute, and you should see `Blocked by recursive_delete_guard`.

What it blocks

  tool call (Bash / Write / Edit / MultiEdit)
              │
              ▼
  ┌───────────────────────────────────┐
  │ rm -r with an unquoted $VAR/$(…)? │──► block
  │ find $T … -delete / -exec rm?     │──► block
  │ target is / · ~ · cwd · a parent  │
  │   · a git work-tree root · .git ? │──► block
  │ writes or runs a script that      │
  │   does any of the above?          │──► block
  └─────────────────┬─────────────────┘
                    │ otherwise
                    ▼
                  runs
Blocked Allowed
rm -rf $D rm -rf -- "${D:?}"
rm -r -f $(dirname $R)/x rm -rf build dist
find $T -type f -delete find . -name '*.pyc' -delete
rm -rf . / .. / ~ / / / ./* / ~/* rm -rf *.diff
rm -rf .git, or a git work-tree root rm -rf output/run
a script (heredoc or file) containing any of these git rm -r --cached x, echo "rm -rf $x"

Where it looks:

  • the Bash command itself, including commands inside `$(...)