[BUG] Hook stdin input cannot be piped from sh script to child scripts

Resolved 💬 2 comments Opened Mar 31, 2026 by championwang00 Closed Mar 31, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using a shell script as a hook entry point, the hook's stdin input (JSON payload) can be read correctly inside the sh script itself, but cannot be passed to a child script (e.g., via pipe or redirection to npx tsx).

This is not a duplicate of issues about hooks not receiving input — the input arrives fine at the sh script level, but is lost when forwarding to sub-processes.

What Should Happen?

The stdin payload should be passable from the hook's sh entry script to child processes via pipe, redirection, or arguments.

Steps to Reproduce

#!/bin/bash
set -e

# This works — payload is received:
payload=$(cat)
echo "$payload" >> console.log  # ✅ correctly logged

# This fails — child process receives empty stdin:
echo "$payload" | npx tsx notify.ts  # ❌ empty in notify.ts

Error Messages/Logs

2026-01-17T08:52:15.896Z [DEBUG] Notification:permission_prompt [.claude/hooks/notify.sh] completed with status 1
2026-01-17T08:52:15.896Z [DEBUG] Hook output does not start with {, treating as plain text

Workaround Needed

Currently no known workaround for passing hook stdin to child TypeScript processes.

---

Reopened from #18790 which was auto-closed by the stale bot. The original author clarified it was not a duplicate, but the issue was closed due to inactivity.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗