-
Notifications
You must be signed in to change notification settings - Fork 8
chore: claude Notification Hook이 Windows 환경에서도 동작하도록 #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
whqtker
merged 1 commit into
solid-connection:develop
from
whqtker:chore/654-add-hooks-on-windows
Feb 14, 2026
+30
−2
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Add-Type -AssemblyName System.Windows.Forms | ||
| $n = New-Object System.Windows.Forms.NotifyIcon | ||
| $n.Icon = [System.Drawing.SystemIcons]::Information | ||
| $n.Visible = $true | ||
| $n.BalloonTipTitle = "Claude Code" | ||
| $n.BalloonTipText = "Awaiting your input" | ||
| $n.ShowBalloonTip(5000) | ||
| Start-Sleep -Milliseconds 5100 | ||
| $n.Dispose() |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env python3 | ||
| import os | ||
| import platform | ||
| import subprocess | ||
|
|
||
| system = platform.system() | ||
| script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
||
| if system == "Darwin": | ||
| subprocess.run([ | ||
| "osascript", "-e", | ||
| 'display notification "Awaiting your input" with title "Claude Code"' | ||
| ]) | ||
| elif system == "Windows": | ||
| ps1_path = os.path.join(script_dir, "notify.ps1") | ||
| subprocess.run([ | ||
| "powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", | ||
| "-File", ps1_path | ||
| ]) |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
Claude Code Cursor IDE hook execution Windows shell compatibility💡 Result:
On Windows, Claude Code hooks execute exactly the command string you configure (they’re “user-defined shell commands”). The official hooks guide even provides Windows examples that explicitly invoke
powershell.exe -Command ..., which is the most reliable pattern on Windows shells. (docs.claude.com)Why
.shhooks often fail in Cursor/WindowsIf your hook is configured like this:
{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh" }…Claude Code may open the
.shfile in VS Code/Cursor instead of executing it on Windows (a reported Windows bug/behavior). (github.com)Practical Windows-compatible fixes
{ "type": "command", "command": "powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"C:\\path\\to\\hook.ps1\"" }(Or inline
-Command "..."as shown in the docs.) (docs.claude.com).sh, invoke Bash explicitly (Git Bash or WSL), don’t execute the.shpath bare:bash.exe, and you may need to set:CLAUDE_CODE_GIT_BASH_PATH="C:\Program Files\Git\bin\bash.exe"(docs.claude.com){ "type": "command", "command": "\"C:\\Program Files\\Git\\bin\\bash.exe\" -lc \"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh\"" }Cursor IDE note
If something works in standalone CMD/PowerShell but not in Cursor’s integrated terminal, it’s often because the integrated terminal doesn’t inherit the same environment (so variables like
CLAUDE_CODE_GIT_BASH_PATHmay not be visible there). (reddit.com)Citations:
🌐 Web query:
Cursor IDE .claude/hooks configuration Windows cmd.exe PowerShell💡 Result:
Where to configure hooks (Cursor / Claude Code)
Claude Code hooks are read from these JSON files (user- or project-scoped):
~/.claude/settings.json,.claude/settings.json, or.claude/settings.local.json. (docs.anthropic.com)They run shell commands, receiving event context as JSON on stdin. (docs.anthropic.com)
After editing hooks, Claude Code takes a startup snapshot; changes typically require review via the
/hooksmenu to apply. (docs.anthropic.com)On Windows,
~maps to your home directory (typicallyC:\Users\<you>), so user settings are usually:C:\Users\<you>\.claude\settings.jsonPowerShell hook (recommended on Windows)
1) Put a script somewhere, e.g.
<repo>\.claude\hooks\my-hook.ps1Example
my-hook.ps1(reads stdin JSON):2) Reference it from
.claude/settings.jsonUse
$CLAUDE_PROJECT_DIRso it works regardless of current working directory. (docs.anthropic.com){ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"\\\"$CLAUDE_PROJECT_DIR\\\"\\.claude\\hooks\\my-hook.ps1\"" } ] } ] } }(That quoting pattern is important if your project path contains spaces, per the docs’ guidance to quote
$CLAUDE_PROJECT_DIR.) (docs.anthropic.com)cmd.exe hook (if you really want cmd)
You can call
cmd.exe /d /s /c ..., but handling stdin JSON in pure batch is awkward, so the common pattern is:cmd.exe→ callpowershell.exeanyway.Example:
{ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "cmd.exe /d /s /c \"powershell.exe -NoProfile -ExecutionPolicy Bypass -File \\\"%CLAUDE_PROJECT_DIR%\\.claude\\hooks\\my-hook.ps1\\\"\"" } ] } ] } }If you tell me which hook event you’re targeting (
PreToolUse,PostToolUse,PermissionRequest, etc.) and what you want to do (block commands, log, run formatters/tests), I can provide a ready-to-paste config + script for that specific case.Citations:
🏁 Script executed:
Repository: solid-connection/solid-connect-server
Length of output: 1476
🏁 Script executed:
Repository: solid-connection/solid-connect-server
Length of output: 63
🏁 Script executed:
Repository: solid-connection/solid-connect-server
Length of output: 904
🏁 Script executed:
Repository: solid-connection/solid-connect-server
Length of output: 451
Windows에서 작동하지 않는 유닉스 셸 문법 수정 필요
현재
.claude/settings.json의 훅 명령어가 Windows 호환성 목표와 맞지 않습니다. 공식 Claude Code 문서에 따르면, Windows에서는2>/dev/null,||같은 유닉스 셸 문법이 작동하지 않습니다. 프로젝트에 이미 PowerShell 버전(notify.ps1)이 있음에도 불구하고, 현재 설정은 그것을 사용하고 있지 않습니다.수정이 필요한 항목:
Notification 훅 (12행)
python3 .claude/hooks/notify.py 2>/dev/null || python .claude/hooks/notify.py2>/dev/null)과 논리 연산자(||) 불가PostToolUse 훅 (23행)
python3 .claude/hooks/post-edit-check.py 2>/dev/null || python .claude/hooks/post-edit-check.py두 훅 모두 공식 권장사항(PowerShell 명시적 호출)에 따라 수정하면 Windows에서도 안정적으로 작동합니다. 저장소에 이미 있는
notify.ps1같은 리소스를 활용하여 완전한 Windows 지원을 갖출 수 있습니다.🤖 Prompt for AI Agents