feat: expose hook stdout/stderr to the conversation for debugging

Resolved 💬 2 comments Opened Mar 27, 2026 by Andrew-Tierno Closed Mar 27, 2026

Problem

When a PreToolUse or PostToolUse hook errors, Claude Code shows a banner like:

PreToolUse:EnterPlanMode hook error

But there's no way to see:

  • What the hook's stderr/stdout was
  • What exit code it returned
  • Which specific hook in the array failed

The hook runs in a subprocess — its output is invisible to the conversation.

Impact

  • Can't debug hook failures without manually running the hook command
  • Agents can't self-diagnose hook issues
  • Hook development requires trial-and-error with no feedback loop

Suggestion

  1. Include hook stderr in the error banner (truncated to ~200 chars)
  2. Add a --debug-hooks flag or setting that pipes full hook output to the conversation
  3. Or: a /hooks test <tool-name> command that dry-runs hooks and shows their output
  4. Log hook output to a file (e.g., ~/.claude/debug/hooks.log) that agents can read

Any of these would make hook development and debugging dramatically easier.

View original on GitHub ↗

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