[PR #86] [MERGED] fix: Stop hook fails on Windows — multiline YAML command not parsed by Git Bash #85

Closed
opened 2026-03-03 18:50:29 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/OthmanAdi/planning-with-files/pull/86
Author: @raykuo998
Created: 2/27/2026
Status: Merged
Merged: 2/28/2026
Merged by: @OthmanAdi

Base: masterHead: fix/windows-stop-hook-multiline


📝 Commits (2)

  • f2f0547 fix: Stop hook fails on Windows — multiline YAML command not parsed by Git Bash
  • 6cc1584 fix: restore mastracode relative-path fallback for project-local installs

📊 Changes

7 files changed (+7 additions, -176 deletions)

View changed files

📝 .codebuddy/skills/planning-with-files/SKILL.md (+1 -25)
📝 .codex/skills/planning-with-files/SKILL.md (+1 -25)
📝 .cursor/skills/planning-with-files/SKILL.md (+1 -25)
📝 .kilocode/skills/planning-with-files/SKILL.md (+1 -25)
📝 .mastracode/skills/planning-with-files/SKILL.md (+1 -26)
📝 .opencode/skills/planning-with-files/SKILL.md (+1 -25)
📝 skills/planning-with-files/SKILL.md (+1 -25)

📄 Description

Summary

  • The Stop hook in SKILL.md uses a YAML multiline block (command: |) with a ~25-line bash script for OS detection. On Windows, Claude Code passes hook commands through Git Bash, which fails to parse the multiline content — SCRIPT_DIR=... is interpreted as a command name instead of a variable assignment
  • Replaced the multiline block with a single-line command: set SD variable inline, try powershell.exe first (Windows), fall back to sh (Linux/macOS). The OS-detection logic is eliminated entirely since the fallback chain handles it implicitly
  • Applied to all 7 tool variants (claude, cursor, codex, codebuddy, kilocode, mastracode, opencode)

Error on Windows (before fix)

Stop hook error: Failed with non-blocking status code: bash:
SCRIPT_DIR=/c/Users/rayku/.claude/skills/planning-with-files/scripts: No such file or directory
sh: /check-complete.sh: No such file or directory

Root Cause

YAML command: | multiline blocks are not reliably parsed by Git Bash on Windows. The shell receives the first line (SCRIPT_DIR=...) as a command to execute rather than a variable assignment, causing the entire hook to fail.

Fix

Before (25 lines per variant):

command: |
  SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/planning-with-files}/scripts"
  IS_WINDOWS=0
  if [ "${OS-}" = "Windows_NT" ]; then
    ...20 more lines of OS detection...
  fi

After (1 line per variant):

command: "SD=\"${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/planning-with-files}/scripts\"; powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"$SD/check-complete.ps1\" 2>/dev/null || sh \"$SD/check-complete.sh\""

Test plan

  • Verified fix resolves the error on Windows 11 with Git Bash
  • Verify check-complete.ps1 runs correctly via powershell.exe on Windows
  • Verify check-complete.sh runs correctly via sh on Linux/macOS (powershell.exe not found, falls through to sh)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/OthmanAdi/planning-with-files/pull/86 **Author:** [@raykuo998](https://github.com/raykuo998) **Created:** 2/27/2026 **Status:** ✅ Merged **Merged:** 2/28/2026 **Merged by:** [@OthmanAdi](https://github.com/OthmanAdi) **Base:** `master` ← **Head:** `fix/windows-stop-hook-multiline` --- ### 📝 Commits (2) - [`f2f0547`](https://github.com/OthmanAdi/planning-with-files/commit/f2f05478bbef44882e21fb32ce7c16138d47ab51) fix: Stop hook fails on Windows — multiline YAML command not parsed by Git Bash - [`6cc1584`](https://github.com/OthmanAdi/planning-with-files/commit/6cc1584671d5e9bae42c0a4b859595d3a84c7519) fix: restore mastracode relative-path fallback for project-local installs ### 📊 Changes **7 files changed** (+7 additions, -176 deletions) <details> <summary>View changed files</summary> 📝 `.codebuddy/skills/planning-with-files/SKILL.md` (+1 -25) 📝 `.codex/skills/planning-with-files/SKILL.md` (+1 -25) 📝 `.cursor/skills/planning-with-files/SKILL.md` (+1 -25) 📝 `.kilocode/skills/planning-with-files/SKILL.md` (+1 -25) 📝 `.mastracode/skills/planning-with-files/SKILL.md` (+1 -26) 📝 `.opencode/skills/planning-with-files/SKILL.md` (+1 -25) 📝 `skills/planning-with-files/SKILL.md` (+1 -25) </details> ### 📄 Description ## Summary - The Stop hook in SKILL.md uses a YAML multiline block (`command: |`) with a ~25-line bash script for OS detection. On Windows, Claude Code passes hook commands through Git Bash, which fails to parse the multiline content — `SCRIPT_DIR=...` is interpreted as a command name instead of a variable assignment - Replaced the multiline block with a single-line command: set `SD` variable inline, try `powershell.exe` first (Windows), fall back to `sh` (Linux/macOS). The OS-detection logic is eliminated entirely since the fallback chain handles it implicitly - Applied to all 7 tool variants (claude, cursor, codex, codebuddy, kilocode, mastracode, opencode) ## Error on Windows (before fix) ``` Stop hook error: Failed with non-blocking status code: bash: SCRIPT_DIR=/c/Users/rayku/.claude/skills/planning-with-files/scripts: No such file or directory sh: /check-complete.sh: No such file or directory ``` ## Root Cause YAML `command: |` multiline blocks are not reliably parsed by Git Bash on Windows. The shell receives the first line (`SCRIPT_DIR=...`) as a command to execute rather than a variable assignment, causing the entire hook to fail. ## Fix Before (25 lines per variant): ```yaml command: | SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/planning-with-files}/scripts" IS_WINDOWS=0 if [ "${OS-}" = "Windows_NT" ]; then ...20 more lines of OS detection... fi ``` After (1 line per variant): ```yaml command: "SD=\"${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/planning-with-files}/scripts\"; powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"$SD/check-complete.ps1\" 2>/dev/null || sh \"$SD/check-complete.sh\"" ``` ## Test plan - [x] Verified fix resolves the error on Windows 11 with Git Bash - [x] Verify `check-complete.ps1` runs correctly via powershell.exe on Windows - [x] Verify `check-complete.sh` runs correctly via sh on Linux/macOS (powershell.exe not found, falls through to sh) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 18:50:29 +03:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/planning-with-files#85
No description provided.