SessionStart hook hangs in trusted directories on Windows

Resolved 💬 4 comments Opened Feb 4, 2026 by chenxiaofie Closed Mar 6, 2026

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

  1. Create a simple SessionStart hook in ~/.claude/settings.json:
{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "cmd /c echo hello",
            "timeout": 15
          }
        ]
      }
    ]
  }
}
  1. Create a new test directory: mkdir C:\test-trusted
  2. Start Claude in that directory: cd C:\test-trusted && claude
  3. When the trust dialog appears, click "Trust" to accept
  4. Exit Claude normally
  5. Start Claude again in the same directory: claude
  6. 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_

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗