feat(hooks): block backslashed Windows-path redirects in bash
Adds a PreToolUse(Bash) hook (block-backslash-winpath.sh) that rejects commands redirecting/writing to a backslashed Windows drive path (e.g. > D:\claudetools\ .claude\current-mode). On Git Bash those strip the backslashes and PUA-substitute ':' (U+F03A), creating garbled junk files that have repeatedly polluted the repo. The hook quote-strips the command first, so the pattern appearing inside strings or commit messages does not false-trigger; Windows-tool args (icacls, pwsh -File) and forward-slash/relative paths pass. Wired into settings.json so every machine picks it up on /sync. Pairs with the sync.sh staging guard. Also: CLAUDE.md note on the Windows mode-write path; record jq install on GURU-KALI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -67,6 +67,8 @@ echo dev > .claude/current-mode # substitute the actual mode name
|
||||
```
|
||||
This file is gitignored (machine-local). The `UserPromptSubmit` hook reads it to gate the lock check on dev mode.
|
||||
|
||||
**Windows/Git Bash:** always use the relative path above (or forward slashes — `/d/claudetools/.claude/current-mode`). NEVER a backslashed Windows path like `D:\claudetools\.claude\current-mode`: Git Bash strips the backslashes and substitutes the illegal `:` with a Unicode PUA char, creating a garbled junk file instead of writing the path. A `PreToolUse(Bash)` hook (`.claude/hooks/block-backslash-winpath.sh`) blocks such redirects; `sync.sh` also strips any that slip through before staging.
|
||||
|
||||
**Auto-initialization:** If `.claude/current-mode` is missing (e.g., fresh clone), the UserPromptSubmit hook automatically creates it with "general" as the default mode. No manual setup required.
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user