Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By karanb192v1.0.0MITIn 1 marketplace
Stops rm, mv and mkdir commands that would silently hit a differently-cased entry on case-insensitive disks like APFS or NTFS. The hook runs on every Bash call and denies matches, logs them locally, and claims it makes no network calls.
Trending plugins
7-day copy clicks
Run automatically on Claude Code events. Claude doesn't decide.
1 caution to review before installing
A hook runs when Claude uses the Bash tool
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
case-sensitivity, data-loss-prevention, filesystem, safety-hook, rm-protection, macos-apfs, claude-code, hooks ·
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Stops
rm -rf contentsilently destroyingContenton case-insensitive filesystems (APFS default, exFAT, NTFS).
On a case-insensitive volume, Content and content are the same path, so a miscased delete lands on the real directory anyway (see anthropics/claude-code#37875). A PreToolUse hook on Bash resolves the real target of destructive commands (rm, rmdir, mv, mkdir, touch, find -delete and find -exec rm/unlink) and denies the ones that would hit a differently-cased entry of what was typed. Directory context is modeled properly: cd/pushd/popd chains, &&/||/;/|/& connectors gated by exit status, subshell scoping, heredoc stripping, quotes and escapes, and wrapper prefixes (sudo, nohup, exec, env, ...). No probe files: case-insensitivity is proven by the collision itself (the typed name is absent from readdir() yet the path still exists).
Idea credit: @yurukusa.
/plugin marketplace add karanb192/claude-code-hooks # once per machine
/plugin install case-insensitive-guard@claude-code-hooks
Restart Claude Code, done. (Or from a shell: claude plugin install case-insensitive-guard@claude-code-hooks.)
| Event | Runs | What happens |
|---|---|---|
PreToolUse (Bash) | sync (it must answer before the command runs) | Parses the command, resolves every destructive target against the real filesystem, and returns permissionDecision: "deny" (or "ask", see below) with both names in the reason when a case-variant would be hit. Safe commands pass through untouched. |
What it deliberately does NOT flag: glob targets (shell glob matching is case-sensitive), $VAR/$( )/backtick targets (not statically resolvable, conservatively allowed), exact-case deletes (intentional), a case-only rename like mv readme.md README.md (the canonical fix), mv -t DIR (moves INTO a directory), plain rm of a case-variant directory (rm refuses directories, nothing is destroyed), and heredoc bodies (document text, not commands). On a case-sensitive volume it never fires: the miscased command fails harmlessly on its own.
All optional, set via environment variables:
| Variable | Default | Purpose |
|---|---|---|
HOOK_SAFETY_LEVEL | high | Safety level: critical, high, or strict. Invalid values fall back to high. Prefer this over editing the script (plugin updates overwrite installed files). |
HOOK_ASK_CRITICAL | unset (deny) | Literal string true: critical-level hits prompt for approval instead of denying. |
HOOK_ASK_HIGH | unset (deny) | Literal string true: high-level hits prompt instead of denying. |
HOOK_ASK_STRICT | unset (deny) | Literal string true: strict-level hits prompt instead of denying. |
Safety levels are cumulative:
| Level | Blocks |
|---|---|
critical | Recursive rm -r/-rf (and find -delete) onto a case-variant |
high | + non-recursive deletes that really remove something: rm of a case-variant FILE, rm -d/rmdir of a case-variant dir, mv overwriting a case-variant FILE |
strict | + mkdir/touch onto an existing case-variant (usually a no-op, but often a sign the agent has the wrong name in mind) |
Set them inline in your hook command, or export them in your shell profile:
{
"type": "command",
"command": "HOOK_SAFETY_LEVEL=strict HOOK_ASK_STRICT=true node \"${CLAUDE_PLUGIN_ROOT}/case-insensitive-guard.js\""
}
Blocked/asked commands are logged to ~/.claude/hooks-logs/<date>.jsonl (command, typed vs actual name, session id). It makes no network calls (the script only uses fs, path, and os), so everything stays on your local machine.
/plugin uninstall case-insensitive-guard@claude-code-hooks
Part of claude-code-hooks: production-ready Claude Code hooks, each installable on its own as a plugin.
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub karanb192/claude-code-hooks --plugin case-insensitive-guardPlugins from other owners that cover similar ground