Description
.claude/settings.json has two problems that prevent the check-file-length.sh PostToolUse hook from running:
1. Invalid hooks schema
The config uses "hook" (singular string) instead of the required "hooks" (array of command objects). Claude Code skips the entire file on validation failure, so no hooks run at all.
2. Shell script not portable to Windows
The hook is a .sh bash script. On Windows, this has several known issues (anthropics/claude-code#23556, anthropics/claude-code#18610, anthropics/claude-code#24097):
- Claude Code may resolve
bash to WSL's bash.exe instead of Git Bash
.sh files may open in an editor instead of executing
- No
.gitattributes exists, so Git on Windows converts LF → CRLF, breaking the shebang
The original setup was done on macOS where none of these surface.
Steps to reproduce
- Clone the repo on Windows
- Open Claude Code
- See startup warning:
.claude/settings.json
└ hooks → PostToolUse → 0 → hooks: Expected array, but received undefined
Files with errors are skipped entirely, not just the invalid settings.
- Edit any
.tsx file — the 250-line limit hook does not fire
Expected behavior
The check-file-length.sh hook should run after every Write|Edit on all platforms, blocking files over 250 lines.
Suggested fix
- Fix the schema — rename
hook → hooks array with { type, command } objects
- Rewrite the hook as a Node.js script (
check-file-length.js) for cross-platform portability
- Add
.gitattributes with *.sh text eol=lf to prevent CRLF corruption
Description
.claude/settings.jsonhas two problems that prevent thecheck-file-length.shPostToolUse hook from running:1. Invalid hooks schema
The config uses
"hook"(singular string) instead of the required"hooks"(array of command objects). Claude Code skips the entire file on validation failure, so no hooks run at all.2. Shell script not portable to Windows
The hook is a
.shbash script. On Windows, this has several known issues (anthropics/claude-code#23556, anthropics/claude-code#18610, anthropics/claude-code#24097):bashto WSL'sbash.exeinstead of Git Bash.shfiles may open in an editor instead of executing.gitattributesexists, so Git on Windows converts LF → CRLF, breaking the shebangThe original setup was done on macOS where none of these surface.
Steps to reproduce
.tsxfile — the 250-line limit hook does not fireExpected behavior
The
check-file-length.shhook should run after everyWrite|Editon all platforms, blocking files over 250 lines.Suggested fix
hook→hooksarray with{ type, command }objectscheck-file-length.js) for cross-platform portability.gitattributeswith*.sh text eol=lfto prevent CRLF corruption