case-insensitive-guard — Claude Code plugin: install and details
case-insensitive-guard is a Claude Code plugin that blocks destructive Bash commands aimed at a path with a different letter case. It checks commands such as rm -rf before they run.
MIT ★ 586 updated 2026-10-26
/plugin marketplace add karanb192/claude-code-hooks
/plugin install case-insensitive-guard@claude-code-hooksWhat case-insensitive-guard does
The plugin checks Bash commands before execution and resolves their targets against the actual filesystem. If a command would hit a file or directory whose name differs only by letter case, the hook denies it or asks for approval. It follows cd and pushd chains and parses shell quoting and substitutions.
Set the protection level with HOOK_SAFETY_LEVEL: critical, high, or strict. The HOOK_ASK_CRITICAL, HOOK_ASK_HIGH, and HOOK_ASK_STRICT variables can switch each level to approval prompts. The hook stays inactive on case-sensitive filesystems and allows targets involving $VAR or command substitutions. Blocked commands and approval requests go to ~/.claude/hooks-logs/<date>.jsonl; the plugin makes no network calls.
What it helps with
- stop
rm -rf contentfrom deletingContent - catch deletion of a file with mismatched letter case
- prevent
mvfrom overwriting a differently cased file - set command blocking by safety level
Example prompts for the agent
- Delete the
contentdirectory recursively. - Move
readme.mdtoREADME.md. - Create the file
config.json.
How to install case-insensitive-guard
Plugin marketplace
/plugin marketplace add karanb192/claude-code-hooks/plugin install case-insensitive-guard@claude-code-hooksStep by step, with commands for each platform: Claude Code plugins: marketplaces, installing, and building your own
Questions about case-insensitive-guard
How do I install case-insensitive-guard in Claude Code?
Run /plugin marketplace add karanb192/claude-code-hooks, then /plugin install case-insensitive-guard@claude-code-hooks, and restart Claude Code.
What does case-insensitive-guard do?
Its hook checks destructive Bash command targets and blocks those that would hit a differently cased file or directory on a case-insensitive filesystem.
Which protection levels does case-insensitive-guard provide?
critical blocks recursive deletion, high adds selected non-recursive deletes and file overwrites through mv, and strict also covers mkdir and touch. Each level can be configured to ask for approval.
Source text
case-insensitive-guard · MIT
# case-insensitive-guard
> Stops `rm -rf content` silently destroying `Content` on 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](https://github.com/anthropics/claude-code/issues/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](https://github.com/karanb192/claude-code-hooks/pull/8).
## Install
```
/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`.)
## What it does
| 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.
## Configuration
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:
```json
{
"type": "command",
"command": "HOOK_SAFETY_LEVEL=strict HOOK_ASK_STRICT=true node \"${CLAUDE_PLUGIN_ROOT}/case-insensitive-guard.js\""
}
```
## Data & privacy
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.
## Uninstall
```
/plugin uninstall case-insensitive-guard@claude-code-hooks
```
Part of [claude-code-hooks](https://github.com/karanb192/claude-code-hooks): production-ready Claude Code hooks, each installable on its own as a plugin.
© Karan Bansal · MIT · karanb192/claude-code-hooks