[BUG] Plugin SessionStart hook fails on Windows (hook script never executes)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Description
The superpowers@claude-plugins-official plugin's SessionStart hook consistently fails on Windows, displaying error messages to users on every session start and /clear command.
What Should Happen?
Expected Behavior
The SessionStart hook should execute successfully and inject the superpowers skill context without displaying any error messages.
Actual Behavior
Error messages are displayed on every session start and /clear command. The hook script never executes, despite being properly configured and working when run manually.
Error Messages/Logs
**Error messages:**
- `⎿ SessionStart:startup hook error` (on session start)
- `⎿ SessionStart:clear hook error` (when running `/clear`)
Steps to Reproduce
Steps to Reproduce
- Ensure superpowers plugin is enabled in
~/.claude/settings.json:
``json``
{
"enabledPlugins": {
"superpowers@claude-plugins-official": true
}
}
- Start a new Claude Code session
- Observe
SessionStart:startup hook errormessage - Run
/clearcommand - Observe
SessionStart:clear hook errormessage
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.22
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
Environment
- OS: Windows 11 with Git Bash (MSYS)
- Claude Code Version: 2.1.22
- Bash Version: GNU bash 5.2.26(1)-release (x86_64-pc-msys)
- Plugin Version: superpowers 4.1.1
- Git for Windows: Installed at
C:\Program Files\Git\bin\bash.exe
Investigation & Root Cause
<details>
<summary><strong>Debug Log Analysis</strong></summary>
From Claude Code debug logs (~/.claude/debug/*.txt):
2026-01-28T13:31:13.197Z [DEBUG] Getting matching hook commands for SessionStart with query: startup
2026-01-28T13:31:13.197Z [DEBUG] Found 2 hook matchers in settings
2026-01-28T13:31:13.197Z [DEBUG] Matched 1 unique hooks for query "startup" (2 before deduplication)
2026-01-28T13:31:24.595Z [DEBUG] Hook output does not start with {, treating as plain text
Key observation: The hook matcher successfully finds the hook, but ~11 seconds later Claude Code reports: "Hook output does not start with {, treating as plain text"
This suggests Claude Code is receiving output from the hook invocation, but it's not the expected JSON (likely an error message).
</details>
<details>
<summary><strong>Hook Script Never Executes</strong></summary>
We instrumented the hook script to write to a log file immediately upon invocation:
#!/usr/bin/env bash
echo "HOOK_START: $(date)" >> "/tmp/hook-trace.log" 2>&1
# ... rest of script
Result: When Claude Code attempts to run the hook, the log file receives NO entries, proving the script never executes.
However, running the script manually works perfectly:
$ bash ~/.claude/plugins/cache/claude-plugins-official/superpowers/4.1.1/hooks/session-start.sh
{
"hookSpecificOutput": {
"hookEventName": "SessionStart",
"additionalContext": "<EXTREMELY_IMPORTANT>..."
}
}
# Exit code: 0
</details>
<details>
<summary><strong>Hook Configuration</strong></summary>
The hook is properly configured in:~/.claude/plugins/cache/claude-plugins-official/superpowers/4.1.1/hooks/hooks.json
{
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume|clear|compact",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh"
}
]
}
]
}
}
The script itself:
- Has proper shebang:
#!/usr/bin/env bash - Uses
set -euo pipefailfor error handling - Uses pure bash constructs (no external dependencies beyond
cat) - Produces valid JSON output when run manually
- Follows documented format from the plugin's
docs/windows/polyglot-hooks.md
</details>
Hypothesis
Claude Code 2.1.x is supposed to auto-detect .sh files in hook commands and prepend bash on Windows (per the superpowers plugin documentation). However, one of these issues appears to be occurring:
- Path Resolution Failure:
${CLAUDE_PLUGIN_ROOT}may not be expanded correctly during hook invocation - Shell Invocation Issue: The automatic
bashprepending may be failing or malformed - Silent Command Failure: The constructed command may be failing before reaching the script
- Path Format Issue: Mixed Windows/Unix path formats may be causing command execution to fail
Impact
- Poor user experience with persistent error messages
- Superpowers skills not automatically loaded (though still manually accessible via Skill tool)
- Affects all Windows users of the superpowers plugin
Workaround
Disable the superpowers plugin to eliminate the error:
{
"enabledPlugins": {
"superpowers@claude-plugins-official": false
}
}
Suggested Fix
The Claude Code hook execution logic needs to be enhanced to:
- Log the exact command being executed - Include in debug logs:
- The constructed command line
- Working directory
- Environment variables (especially
CLAUDE_PLUGIN_ROOT) - Full stdout/stderr from the hook process
- Exit code
- Verify path variable expansion - Ensure
${CLAUDE_PLUGIN_ROOT}is properly expanded on Windows before executing
- Handle Windows path formats - Consider if paths need normalization (backslash vs forward slash)
- Better error reporting - When hooks fail, show users the actual error message instead of just "hook error"
Related
The superpowers plugin includes Windows-specific documentation at docs/windows/polyglot-hooks.md that references:
- anthropics/claude-code#9758 - .sh scripts open in editor on Windows
- anthropics/claude-code#3417 - Hooks don't work on Windows
- anthropics/claude-code#6023 - CLAUDE_PROJECT_DIR not found
This issue may be related to those previous Windows hook execution problems.
Additional Context
<details>
<summary><strong>Superpowers Plugin Hook Documentation Notes</strong></summary>
From superpowers/4.1.1/docs/windows/polyglot-hooks.md:
Claude Code 2.1.x changed the Windows execution model for hooks: Before (2.0.x): Hooks ran with shell:true, using the system default shell. This required polyglot wrapper scripts. After (2.1.x): Claude Code now auto-detects .sh files in hook commands and prepends "bash " on Windows.
The hooks.json was updated to reference the .sh file directly (not a .cmd wrapper) for Claude Code 2.1.x compatibility, but this appears to not be working as intended on Windows.
</details>
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗