PostToolUse hooks cannot inject context visible to Claude
Problem
PostToolUse hooks can show messages to the user via systemMessage, but there's no way to inject content that Claude (the AI) can see in its context.
Use Case
We have a command_guard.py hook that shows reminders when certain files are edited (e.g., migration files should use a specific workflow). The reminder should be visible to Claude so it can adjust its behavior, not just to the user.
What We Tried
All of these approaches with exit 0 in PostToolUse:
{"decision": "block", "reason": "reminder"}- Shows as "blocking error" to user, not visible to Claude{"systemMessage": "reminder"}- Shows to user only{"additionalContext": "reminder"}- No effect{"hookSpecificOutput": {"additionalContext": "reminder"}}- No effect{"hookSpecificOutput": {"modifyResult": "original + reminder"}}- No effect- Plain stdout with
<system-reminder>tags - No effect - stderr output - No effect
What Works (Workaround for Bash only)
For Bash tools, we can use PreToolUse with updatedInput to append && echo '<system-reminder>...</system-reminder>' to the command. This makes the reminder appear in the command output, which Claude can see.
This workaround doesn't work for Edit/Write tools since we can't append output to those.
Feature Request
Add a way for PostToolUse hooks to inject content into Claude's context. Possible approaches:
- Make
additionalContextactually work for PostToolUse - Add a
modifyResultfield that appends to the tool result - Document how to achieve this if it's already possible
Environment
- Claude Code CLI
- Hook type: PostToolUse with command type
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗