claude-code - 💡(How to fix) Fix Plugin SessionStart hooks execute but additionalContext stdout is silently discarded [5 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45438Fetched 2026-04-09 08:05:25
View on GitHub
Comments
5
Participants
2
Timeline
12
Reactions
0
Author
Timeline (top)
commented ×5labeled ×5closed ×1cross-referenced ×1

Error Message

Stop hooks in the same plugin work correctly (blocking error prompts appear). Only SessionStart additionalContext is affected.

Code Example

{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh",
            "timeout": 10
          }
        ]
      }
    ]
  }
}

---

{
  "hookSpecificOutput": {
    "hookEventName": "SessionStart",
    "additionalContext": "This text should appear in conversation context"
  }
}
RAW_BUFFERClick to expand / collapse

Problem

Plugin SessionStart hooks execute successfully (side effects work) but their stdout JSON containing hookSpecificOutput.additionalContext is silently discarded. The injected context never appears in the agent conversation.

Stop hooks in the same plugin work correctly (blocking error prompts appear). Only SessionStart additionalContext is affected.

Reproduction

  1. Install a plugin with this hooks.json:
{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh",
            "timeout": 10
          }
        ]
      }
    ]
  }
}
  1. session-start.sh outputs valid JSON:
{
  "hookSpecificOutput": {
    "hookEventName": "SessionStart",
    "additionalContext": "This text should appear in conversation context"
  }
}
  1. Start a new interactive terminal session

Expected: additionalContext text appears as a system-reminder in conversation context Actual: Hook executes (file side effects work), stdout is discarded, no context injected

Evidence

  • Hook execution confirmed via file markers (touch commands in the script create files)
  • Plugin loading confirmed via channel MCP tools appearing in deferred tools list
  • Manual execution of the script produces valid JSON
  • Stop hooks in the same plugin/hooks.json work correctly
  • Tested across 4 agents in different project directories, all consistent
  • Same hooks.json format that works for settings.json hooks

Environment

  • Claude Code latest (2026-04-08)
  • Plugin installed at user scope
  • macOS Darwin 25.3.0
  • Interactive terminal sessions (not --print mode)

extent analysis

TL;DR

The issue can be resolved by verifying the JSON output of the session-start.sh script and ensuring it is correctly formatted to include the additionalContext in the agent conversation.

Guidance

  • Verify that the session-start.sh script is producing the correct JSON output with additionalContext by running it manually and checking its stdout.
  • Check the plugin's documentation to ensure that the hooks.json format is correct and supported for SessionStart hooks.
  • Test the plugin with a simplified session-start.sh script that only outputs the required JSON to isolate the issue.
  • Confirm that the issue is not specific to the interactive terminal sessions by testing it in a different environment.

Example

{
  "hookSpecificOutput": {
    "hookEventName": "SessionStart",
    "additionalContext": "This text should appear in conversation context"
  }
}

This example shows the expected JSON output of the session-start.sh script.

Notes

The issue might be specific to the SessionStart hooks or the way the additionalContext is being processed. Further investigation is needed to determine the root cause.

Recommendation

Apply a workaround by modifying the session-start.sh script to log its output to a file, allowing for further debugging and verification of the issue. This will help determine if the problem lies in the script's output or the plugin's processing of it.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING