Skip to content

Conversation

@m4nt0de4
Copy link

@m4nt0de4 m4nt0de4 commented Feb 3, 2026

Summary

  • Removes 196 informational console.error() calls across 25 hook files
  • Keeps 24 legitimate console.error() calls for real errors and security events
  • Normal hook execution now produces zero stderr output

Problem

All PAI hooks use console.error() for both informational/progress messages AND actual errors. Claude Code interprets any stderr output from a hook as a failure, displaying "hook error" to the user even when hooks execute successfully.

This means every session shows multiple false "hook error" messages during normal operation — at startup (SessionStart hooks), on every prompt (UserPromptSubmit hooks), and on tool use (PreToolUse hooks).

Fix

Systematically classified all 220 console.error() calls across 27 hook files:

Classification Action Count
Informational/progress messages Removed 196
Real errors in catch blocks Kept 5
Security events (BLOCKED/ALERT) Kept 11
Debug-gated (if DEBUG) Kept 7
Already commented out Kept 1

Files modified (25)

Hook files (15): LoadContext, StopOrchestrator, UpdateTabTitle, SoulEvolution, RelationshipMemory, SessionSummary, AgentOutputCapture, AutoWorkCreation, CheckVersion, QuestionAnswered, SetQuestionTab, ImplicitSentimentCapture, ExplicitRatingCapture, WorkCompletionLearning, SecurityValidator

Handler files (7): VoiceNotification, UpdateCounts, ISCValidator, TabState, SystemIntegrity, ResponseCapture, RebuildSkill

Lib files (3): notifications, observability, change-detection

Remaining console.error calls (24, all legitimate)

  • StopOrchestrator (4) — catch blocks for real errors
  • StartupGreeting (1) — catch block for banner failure
  • SecurityValidator (11) — BLOCKED/ALERT security events + parse error
  • TraceEmitter (7) — gated behind DEBUG_HOOKS env var
  • observability (1) — already commented out

Test plan

  • Start a new Claude Code session — no "hook error" messages should appear
  • Submit a prompt — no "UserPromptSubmit hook error" messages
  • Trigger a SecurityValidator block — should still show BLOCKED in stderr
  • Set DEBUG_HOOKS=true — TraceEmitter debug output should still appear

Fixes #477

🤖 Generated with Claude Code

…alse errors

Claude Code interprets any stderr output from hooks as a failure, displaying
"hook error" to the user even when hooks execute successfully. All hooks were
using console.error() for both informational/progress messages AND actual errors.

This commit removes 196 informational console.error() calls across 25 hook files,
keeping only 24 that represent actual errors:
- catch blocks handling real failures (StopOrchestrator, StartupGreeting)
- Security events: BLOCKED/ALERT (SecurityValidator)
- Debug-gated output behind DEBUG_HOOKS=true (TraceEmitter)

Normal hook execution now produces zero stderr output.

Fixes danielmiessler#477

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hooks write to stderr causing false "hook error" display in Claude Code

1 participant