SessionStart hook reports error on /compact with no actionable details

Resolved 💬 3 comments Opened Apr 5, 2026 by CyanoTex Closed Apr 9, 2026

Summary

When /compact triggers a SessionStart hook, Claude Code sometimes reports a generic "SessionStart:compact hook error" with no details. The hook itself runs correctly — valid JSON output, exit code 0, completes well within the 30s timeout.

Steps to Reproduce

  1. Install a plugin with a SessionStart hook registered for startup|clear|compact
  2. Run a session long enough to accumulate context
  3. Run /compact
  4. Observe "SessionStart:compact hook error" in the output

Observed Behavior

A generic error message appears after compaction. No stderr output, no stack trace, no indication of what failed. The hook's JSON output is valid and the process exits cleanly when run manually.

Expected Behavior

Either:

  • The hook succeeds silently (since its output is valid), or
  • The error message includes actionable details (stderr content, exit code, timeout info, output validation failure reason)

Possible Causes

  • Stderr noise: Node.js may emit deprecation/experimental warnings to stderr that Claude Code interprets as a hook failure, even though stdout contains valid JSON
  • Timing: The compaction process may race with hook execution, causing the output to be discarded or misread
  • Output size: The hook returns a large additionalContext string (~3KB of markdown); if there's an undocumented size limit, the error message doesn't say so

Environment

  • Windows 11 Pro
  • Claude Code CLI (latest as of 2026-04-05)
  • Hook: SessionStart with matcher startup|clear|compact, 30s timeout
  • Plugin: claudian (Obsidian vault integration)

Suggestion

At minimum, surface the actual failure reason in the error message (stderr content, exit code, or validation error). A generic "hook error" with no details makes debugging impossible for plugin authors.

View original on GitHub ↗

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