fix: make the Read hook work on Windows - #5
Open
learte4 wants to merge 1 commit into
Open
Conversation
On Windows the hook silently logged nothing. Two causes, both in main(): - jq.exe emits CRLF, so every value read from its output carried a trailing \r. The `tool_name == "Read"` guard therefore never matched and the script exited before reaching any logging code. - file_path arrives with backslash separators, which never match the `*".claude/skills/"*` pattern. Strip the CR from all five values and normalize the separators before the guards. No behavior change on macOS/Linux, where neither condition occurs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows the plugin silently records nothing. The hook runs, exits 0, and never writes a line — so
.skill-observer/logs/skills.jsonlstays empty forever and there is no error to point at.Two causes, both in
main()ofscripts/skill-tracker.sh:jq.exeemits CRLF. Every value read out of thejq -rblock carries a trailing\r, sotool_nameis"Read\r". The[[ "${tool_name}" == "Read" ]]guard never matches and the script exits before reaching any logging code.file_patharrives with backslashes (D:\proj\.claude\skills\foo\SKILL.md), which never match the*".claude/skills/"*pattern in the guard below it.Either one alone is enough to kill logging; together they make it look like the hook simply isn't registered.
Fix
Strip the CR from the five values, and normalize the separators before the path guard:
Both are no-ops on macOS and Linux: there is no CR to strip and no backslash to replace.
${var%$'\r'}removes at most one trailing CR and leaves LF-only values untouched.Reproducing
On Windows with Git Bash, read any
SKILL.mdunder.claude/skills/with the hook installed. Before this change the log file is never created; after it, theskill_loadedevent appears as expected.I have been running this patch locally since 2026-07-17 across a few dozen sessions, which is how the second issue in the pair surfaced — fixing only the CRLF gets you past the
tool_nameguard and straight into the backslash one.Related: I opened a separate PR for an unrelated performance issue in the same function. The two touch different lines a few apart; whichever lands first, the other needs at most a trivial rebase.