Skip to content

[BUG] PostToolUse hook JSON output not processed by Claude Code #3983

@durapensa

Description

@durapensa

Environment

  • Platform (select one):
    • Anthropic API
    • AWS Bedrock
    • Google Vertex AI
    • Other:
  • Claude CLI version: 1.0.56 (Claude Code)
  • Operating System: macOS 15.5 (Darwin 24.5.0)
  • Terminal: Ghostty.app

Bug Description

PostToolUse hooks that output JSON in the documented format are not being processed by Claude Code. The hook correctly outputs JSON with exit code 0, but Claude Code does not make this data available to the AI assistant as documented.

Steps to Reproduce

  1. Create a PostToolUse hook that outputs JSON in the documented format:
    {"reason": "Hook feedback message"}
  2. Configure the hook in .claude/settings.local.json:
    {
      "hooks": {
        "postToolUse": {
          "Bash": "python3 /path/to/hook_script.py"
        }
      }
    }
  3. Execute a Bash command that triggers the hook (e.g., ls)
  4. Hook executes successfully with exit code 0 and outputs the JSON
  5. Claude Code does not receive/process the JSON output

Expected Behavior

According to the hooks documentation, when a PostToolUse hook returns exit code 0 with JSON output, Claude Code should process that JSON. The AI assistant should have access to the hook's output data.

Actual Behavior

  • Hook executes correctly (verified via diagnostic logging)
  • Hook outputs proper JSON format (verified by capturing stdout)
  • Hook exits with code 0 (success)
  • Claude Code does not process the JSON output
  • The AI assistant never receives the hook data

Additional Context

This issue has been present since at least version 1.0.44. The hook implementation follows the documented specification exactly:

# Hook outputs JSON and exits with code 0
output = {"reason": "[KSI ⚡3]"}
print(json.dumps(output), flush=True)
sys.exit(0)

Diagnostic logs confirm the hook is working:

2025-07-19T10:30:59.565767 - JSON feedback output: [KSI ⚡3]

But Claude Code is not processing this output as documented. This prevents hooks from providing feedback to the AI assistant during tool execution.

Related Issues:

Workaround:
Currently forced to write diagnostic data to external log files since the documented JSON communication method doesn't work.

Metadata

Metadata

Assignees

Labels

area:coreautocloseIssue will be closed automaticallybugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOS

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions