Description
All hooks in PAI v2.3 write informational/status messages to stderr using console.error(). Claude Code interprets any stderr output as a hook failure, displaying "hook error" messages even when hooks execute successfully.
Steps to Reproduce
- Install PAI v2.3
- Start a new Claude Code session
- Observe multiple "SessionStart:startup hook error" messages at startup
- Observe "UserPromptSubmit hook error" and "PreToolUse:Bash hook error" during normal usage
Expected Behavior
No error messages when hooks complete successfully (exit code 0).
Actual Behavior
Claude Code shows "hook error" for every hook, even though:
- Hooks execute correctly (banner displays, context loads)
- Exit codes are 0
- The "errors" are just informational log messages
Root Cause
Hooks use console.error() for status messages. For example, in LoadContext.hook.ts:
console.error('⏱️ Session start time recorded for notification timing');
console.error('📚 Reading PAI core context from skill file...');
console.error(`✅ Read ${paiContent.length} characters from PAI SKILL.md`);
Claude Code treats any stderr output as an error condition.
Suggested Fix
Option A (Recommended): Change informational console.error() calls to console.log() or remove them entirely. Reserve console.error() only for actual errors.
Option B (Workaround): Add 2>/dev/null to hook commands in settings.json:
{ "type": "command", "command": "${PAI_DIR}/hooks/LoadContext.hook.ts 2>/dev/null" }
Affected Files
All hooks in Releases/v2.3/.claude/hooks/ and Packs/pai-hook-system/src/hooks/:
- LoadContext.hook.ts
- StartupGreeting.hook.ts
- CheckVersion.hook.ts
- UpdateTabTitle.hook.ts
- SetQuestionTab.hook.ts
- ExplicitRatingCapture.hook.ts
- SecurityValidator.hook.ts
- (and others)
Environment
- PAI Version: 2.3.0
- Claude Code Version: 2.1.17
- OS: macOS
Description
All hooks in PAI v2.3 write informational/status messages to stderr using
console.error(). Claude Code interprets any stderr output as a hook failure, displaying "hook error" messages even when hooks execute successfully.Steps to Reproduce
Expected Behavior
No error messages when hooks complete successfully (exit code 0).
Actual Behavior
Claude Code shows "hook error" for every hook, even though:
Root Cause
Hooks use
console.error()for status messages. For example, inLoadContext.hook.ts:Claude Code treats any stderr output as an error condition.
Suggested Fix
Option A (Recommended): Change informational
console.error()calls toconsole.log()or remove them entirely. Reserveconsole.error()only for actual errors.Option B (Workaround): Add
2>/dev/nullto hook commands in settings.json:{ "type": "command", "command": "${PAI_DIR}/hooks/LoadContext.hook.ts 2>/dev/null" }Affected Files
All hooks in
Releases/v2.3/.claude/hooks/andPacks/pai-hook-system/src/hooks/:Environment