From 9789a1969c6f26fbaeae351eea530937546a64ca Mon Sep 17 00:00:00 2001 From: Rajiv Sinclair Date: Tue, 27 Jan 2026 10:44:08 -0800 Subject: [PATCH] fix: gracefully handle empty prompts in session-init hook When a user submits an empty or whitespace-only prompt to Claude Code, the UserPromptSubmit hook would throw "sessionInitHandler requires prompt" and block the operation. This change returns early with `{ continue: true }` instead of throwing, allowing the session to continue gracefully. Co-Authored-By: Claude Opus 4.5 --- src/cli/handlers/session-init.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cli/handlers/session-init.ts b/src/cli/handlers/session-init.ts index 095f9497..41c375f5 100644 --- a/src/cli/handlers/session-init.ts +++ b/src/cli/handlers/session-init.ts @@ -21,8 +21,9 @@ export const sessionInitHandler: EventHandler = { const { sessionId, cwd, prompt } = input; - if (!prompt) { - throw new Error('sessionInitHandler requires prompt'); + // Gracefully handle empty prompts (user submitted blank input) + if (!prompt || !prompt.trim()) { + return { continue: true, suppressOutput: true }; } const project = getProjectName(cwd);