claude-code - 💡(How to fix) Fix additionalContext in UserPromptSubmit hook output is silently dropped [1 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#52876Fetched 2026-04-25 06:18:31
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Fix Action

Workaround

Use plain stdout (e.g., echo "user-message-submitted: $TS"), which surfaces correctly as a system-reminder.

Code Example

{
     "hooks": [{
       "type": "command",
       "command": "echo '{\"additionalContext\": \"user-message-submitted: 2026-04-24T13:43:01Z\"}'",
       "timeout": 3
     }]
   }
RAW_BUFFERClick to expand / collapse

Bug

Hook returning {"additionalContext": "..."} from UserPromptSubmit produces valid JSON but the content is never surfaced to the assistant. The assistant cannot see the value in any form — not as a system message, not as context, nothing.

Repro

  1. Register a UserPromptSubmit hook:
    {
      "hooks": [{
        "type": "command",
        "command": "echo '{\"additionalContext\": \"user-message-submitted: 2026-04-24T13:43:01Z\"}'",
        "timeout": 3
      }]
    }
  2. Send a message
  3. Ask the assistant what context it received from the hook — it sees nothing

Workaround

Use plain stdout (e.g., echo "user-message-submitted: $TS"), which surfaces correctly as a system-reminder.

Expected

additionalContext should be visible to the assistant, per the hook documentation.

Environment

  • Claude Code, as of 2026-04-24
  • macOS
  • Hook registered under UserPromptSubmit in .claude/settings.json

extent analysis

TL;DR

The issue can be worked around by using plain stdout instead of returning JSON from the UserPromptSubmit hook.

Guidance

  • The likely cause is that the assistant is not designed to handle JSON output from hooks, which is why plain stdout works as a workaround.
  • To verify, try registering a new hook with plain stdout output and check if the assistant can see the context.
  • The current workaround is to use plain stdout, such as echo "user-message-submitted: $TS", which surfaces correctly as a system-reminder.
  • Consider checking the hook documentation for any updates or changes to how JSON output is handled.

Example

{
  "hooks": [{
    "type": "command",
    "command": "echo 'user-message-submitted: 2026-04-24T13:43:01Z'",
    "timeout": 3
  }]
}

Notes

This workaround may not be ideal for all use cases, especially if the hook needs to return structured data. It's unclear if this is a bug or an intended behavior, and further investigation may be needed to determine the root cause.

Recommendation

Apply workaround: using plain stdout is the most straightforward solution given the current information, as it allows the assistant to see the context as intended.

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

claude-code - 💡(How to fix) Fix additionalContext in UserPromptSubmit hook output is silently dropped [1 comments, 2 participants]