claude-memory/graph/solutions/fixed-posttooluse-hook-context-injection-ba1890.md

1.1 KiB

id type title tags importance confidence created updated relations
ba189013-3890-4464-a22d-cdc3d68d8068 solution Fixed PostToolUse hook context injection
claude-code
hooks
pai
fix
memorygraph
0.8 0.8 2025-12-07T07:26:28.700934+00:00 2026-03-02T02:08:36.768785+00:00
target type direction strength edge_id
250d2fe0-5866-42f1-b83d-187b3a64fb84 BUILDS_ON incoming 0.73 e8e3d8cf-6ccf-4b39-a625-466151c1b392
target type direction strength edge_id
be0bda86-d893-4f86-97c4-0ca4e1073121 BUILDS_ON incoming 0.86 0b72d209-d461-463c-a720-cf8d47ef5fe8

PostToolUse hooks cannot inject stdout directly into Claude context - only SessionStart and UserPromptSubmit can. The fix is to use JSON output with additionalContext field: {hookSpecificOutput: {hookEventName: 'PostToolUse', additionalContext: 'your message'}}. Also discovered tool_response (not tool_output) is the correct field name, and exitCode doesn't exist - must infer success from stdout patterns. Full reference: https://notes.manticorum.com/reference/claude-code-hooks-context-injection