claude-code - 💡(How to fix) Fix Hook output: support native IDE notifications [1 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#46694Fetched 2026-04-12 13:35:31
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

Hooks (PreToolUse, PostToolUse, UserPromptSubmit, etc.) can return additionalContext and permissionDecision via JSON stdout. There's no way for a hook to trigger a native IDE notification (VS Code window.showInformationMessage / showWarningMessage / showErrorMessage).

Error Message

severity values: "info" | "warning" | "error" mapping to the VS Code notification API.

Root Cause

Hooks (PreToolUse, PostToolUse, UserPromptSubmit, etc.) can return additionalContext and permissionDecision via JSON stdout. There's no way for a hook to trigger a native IDE notification (VS Code window.showInformationMessage / showWarningMessage / showErrorMessage).

Fix Action

Fix / Workaround

Current Workaround

Code Example

{
  "notification": {
    "message": "Context at 50% — consider writing CONTINUITY.md",
    "severity": "warning"
  },
  "additionalContext": "CONTEXT PRESSURE: YELLOW (50%)..."
}
RAW_BUFFERClick to expand / collapse

Summary

Hooks (PreToolUse, PostToolUse, UserPromptSubmit, etc.) can return additionalContext and permissionDecision via JSON stdout. There's no way for a hook to trigger a native IDE notification (VS Code window.showInformationMessage / showWarningMessage / showErrorMessage).

Use Case

Context pressure monitoring: a UserPromptSubmit hook computes context window usage % and wants to show the user a visible notification at threshold crossings (25%, 50%, 80%). Currently the only option is additionalContext which injects text the model sees but the user doesn't see directly.

Proposed API

New hook output field notification:

{
  "notification": {
    "message": "Context at 50% — consider writing CONTINUITY.md",
    "severity": "warning"
  },
  "additionalContext": "CONTEXT PRESSURE: YELLOW (50%)..."
}

severity values: "info" | "warning" | "error" mapping to the VS Code notification API.

Current Workaround

Using a separate VS Code extension that watches a cache file written by the hook. Works but adds an extension dependency for what could be a built-in hook capability.


🤖 Generated with Claude Code

extent analysis

TL;DR

Implement a new hook output field notification to enable hooks to trigger native IDE notifications.

Guidance

  • Define the notification field in the hook output JSON with message and severity properties to specify the notification content and type.
  • Use the severity values "info", "warning", or "error" to map to the corresponding VS Code notification API.
  • Update the hook to return the notification field in addition to additionalContext to provide a visible notification to the user.
  • Consider removing the current workaround that relies on a separate VS Code extension and a cache file.

Example

{
  "notification": {
    "message": "Context at 50% — consider writing CONTINUITY.md",
    "severity": "warning"
  },
  "additionalContext": "CONTEXT PRESSURE: YELLOW (50%)..."
}

Notes

The proposed API change requires updates to the hook output processing to handle the new notification field and integrate with the VS Code notification API.

Recommendation

Apply workaround by implementing the proposed notification field in the hook output JSON, as it provides a more integrated and user-friendly solution compared to the current workaround.

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 Hook output: support native IDE notifications [1 participants]