SessionStart hook hangs in trusted directories on Windows
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?
When a directory is marked as "trusted" (hasTrustDialogAccepted: true in ~/.claude.json), the SessionStart hook causes Claude Code to hang completely. The terminal becomes unresponsive and cannot be exited with Ctrl+C.
However, if the directory is NOT trusted (shows trust dialog on startup), the same hook works perfectly fine.
What Should Happen?
The SessionStart hook should execute normally regardless of whether the directory is trusted or not.
Error Messages/Logs
Steps to Reproduce
- Create a simple SessionStart hook in
~/.claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "cmd /c echo hello",
"timeout": 15
}
]
}
]
}
}
- Create a new test directory:
mkdir C:\test-trusted - Start Claude in that directory:
cd C:\test-trusted && claude - When the trust dialog appears, click "Trust" to accept
- Exit Claude normally
- Start Claude again in the same directory:
claude - Result: Claude hangs completely. Terminal is frozen.
Workaround
Remove the directory's trust status from ~/.claude.json by deleting the corresponding entry in the projects object. This forces the trust dialog to appear again, which allows hooks to work.
Additional Notes
- The hang occurs even with the simplest possible hook (
cmd /c echo hello) - The hang is not caused by Python or any specific hook logic
- Adding delays to the hook script does not help
- The issue seems to be related to the timing/mechanism of hook execution in trusted directories
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Latest
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗