PR #8 by @yurukusa proposed a genuinely good hook idea: on case-insensitive filesystems (APFS default, exFAT, NTFS), Content and content are the same path, and anthropics/claude-code#37875 documents real data loss from exactly this (rm -rf content destroying Content).
The submitted implementation couldn't ship as-is (verified against the PR script on an APFS volume):
- Misses the motivating incident class: the parser is anchored to the start of the command string, so
cd somewhere && rm -rf Content is allowed straight through (exit 0). Also missed: rm -i, multi-argument rm, globs.
- Blocks harmless commands:
mkdir -p Content is hard-blocked (exit 2) when a case-variant exists, even though mkdir -p there is a safe no-op.
- No automated tests; not requirable (no
module.exports guard), so it can't follow the repo's test pattern.
Requirements for a house-standard implementation
Credit for the idea and the incident research goes to @yurukusa.
PR #8 by @yurukusa proposed a genuinely good hook idea: on case-insensitive filesystems (APFS default, exFAT, NTFS),
Contentandcontentare the same path, and anthropics/claude-code#37875 documents real data loss from exactly this (rm -rf contentdestroyingContent).The submitted implementation couldn't ship as-is (verified against the PR script on an APFS volume):
cd somewhere && rm -rf Contentis allowed straight through (exit 0). Also missed:rm -i, multi-argumentrm, globs.mkdir -p Contentis hard-blocked (exit 2) when a case-variant exists, even thoughmkdir -pthere is a safe no-op.module.exportsguard), so it can't follow the repo's test pattern.Requirements for a house-standard implementation
&&,;,|) and check everyrm/mv/destructive segment, not just a start-anchored matchcwd(and any precedingcdin the same command)rm, globs, quoted pathsmkdir -p{}exit 0),require.mainguard + pure-function exports, hermetic testsCredit for the idea and the incident research goes to @yurukusa.