[BUG] SessionStart prompt hooks crash with unhandled exception
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?
Bug: SessionStart prompt hooks crash with unhandled exception
Summary
A SessionStart hook of type: "prompt" throws an unhandled exception on every session start. The exception message itself reads "This is a bug," suggesting the platform team may already be aware, or it's a generalized catch-all response. Reporting to confirm it is reproducible across platforms and versions, and to document the impact on plugin development.
---
Environment
- Claude Code version: 2.1.109
- Platforms: Ubuntu 24.04.4 LTS (x86_64), Raspberry Pi OS Lite 64-bit (aarch64) — reproduced on both
---
Steps to reproduce
- Create a hooks.json with a SessionStart prompt hook:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "prompt",
"prompt": "Your instruction here."
}
]
}
]
}
}
- Start a new Claude Code session.
---
Actual behavior
The session crashes immediately with:
ToolUseContext is required for prompt hooks. This is a bug.
---
Expected behavior
The prompt hook fires at session start and the model executes the instruction before the user's first message.
---
Additional notes
- type: "command" hooks at SessionStart work — but only inject output as a <system-reminder>. The model does not act on it until the user sends their first message, making it unsuitable for auto-executing instructions on open.
- ${CLAUDE_PLUGIN_ROOT} expands correctly in command hooks but not in prompt hooks.
- The primary use case blocked by this bug: plugins that need to auto-run a startup routine (e.g. load session context, deliver a sitrep, custom greeting/instruction) when a session opens, without requiring the user to type a command first.
What Should Happen?
The prompt hook fires at session start and the model executes the instruction before the user's first message.
Error Messages/Logs
ToolUseContext is required for prompt hooks. This is a bug.
Steps to Reproduce
- Create a hooks.json with a SessionStart prompt hook:
```
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "prompt",
"prompt": "Your instruction here."
}
]
}
]
}
}
2. Start a new Claude Code session.
### Claude Model
Sonnet (default)
### Is this a regression?
I don't know
### Last Working Version
_No response_
### Claude Code Version
2.1.109
### Platform
Anthropic API
### Operating System
Ubuntu/Debian Linux
### Terminal/Shell
Terminal.app (macOS)
### Additional Information
_No response_
5 Comments
Confirming on macOS — same error on Darwin 25.2.0 (macOS 26.2), Claude Code 2.1.112. Identical minimal repro:
type: "prompt"hook on SessionStart throwsToolUseContext is required for prompt hooks. This is a bug.at session start. Theplatform:linuxlabel probably wants widening — this isn't platform-specific.Confirming still reproduces on macOS (Darwin 24.6.0) with Claude Code 2.1.114. Same minimal repro:
type: "prompt"hook onSessionStartthrowsToolUseContext is required for prompt hooks. This is a bug.on every session start. The siblingtype: "command"hook in the same block fires normally, so the regression is isolated to prompt hooks.Confirming still reproduces on Windows 11 Pro with Claude Code 2.1.119.
Minimal repro matches the original: a project-scoped
.claude/settings.jsoncontaining atype: "prompt"SessionStart hook throwsToolUseContext is required for prompt hooks. This is a bug.immediately on session start. Siblingtype: "command"hooks in the same block keep firing normally, so the regression is isolated to the prompt-hook dispatcher.Two data points that may be worth adding:
hooks.json, but the same error fires for a hook defined directly in project-levelsettings.jsonwith no plugin involved. The failure looks like it is in the prompt-hook dispatcher itself, independent of plugin loading.platform:macosandplatform:linux; verified here on native Windows (not WSL) with a fresh session.platform:windowsmay want widening.Reproducer (
.claude/settings.json):Confirming on Claude Code 2.1.123 / macOS 15.7 (Darwin 25.5.0) — same minimal repro (
type: "prompt"hook onSessionStartthrowsToolUseContext is required for prompt hooks. This is a bug.).Adding a previously-unreported downstream-impact data point: this bug interacts with
/remote-control(and presumablyremoteControlAtStartup: true) to cause a hard, user-visible failure beyond the cosmetic banner.Failure mode
SessionStartprompt hook errors withToolUseContext is required for prompt hooks. Thehook_non_blocking_erroris recorded as an attachment in the session's local transcript./remote-control.Remote Control failed to connect: Session creation failed — see debug log. The CLI shows onlyRemote Control connecting…during the wait./remote-controlinvoked ~20 min later succeeds in 0.8 s.Transcript-side measurements (same session, no other variables):
| metric | failed (10:26 JST) | retry (10:47 JST) |
| --- | --- | --- |
| time since session start | 8.2 s | ~20 min |
| attachments in immediate window | 8 (incl.
hook_non_blocking_error) | 0 || transcript bytes accumulated | 50.3 KB | 51.3 KB (Δ = +1 KB) |
| outcome | 27.8 s → Session creation failed | 0.8 s → bridge active |
Payload size is essentially identical between attempts; the only meaningful difference is the dirty-hook-state attachment in the failed window. May be worth cross-referencing with #52775 (the other known SessionStart-hook × remote-control interaction bug).
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.