Skip to content

claude -p subprocess produces empty stdout when called from Bash tool #118

@WesleyMFrederick

Description

@WesleyMFrederick

Problem

claude -p called from the Bash tool inside a Claude Code session exits 0 but produces zero bytes of stdout. The Seatbelt nesting bypass (CLAUDE_SANDBOX_ACTIVE + unset CLAUDECODE) works correctly — no sandbox or nesting errors. But output is lost.

Context

Another session needs claude -p as a semantic layer inside a UserPromptSubmit hook (learning injection via haiku). The sandbox fix on branch fix/nested-seatbelt-bypass resolved the kernel-level nesting error, but stdout capture remains broken.

Definition of Success

From inside a running Claude Code session, this Bash tool call:

echo '{"prompt":"test"}' | claude -p --model haiku --max-turns 1 --output-format text

Must:

  1. Exit 0
  2. Print non-empty text to stdout (any response from haiku)
  3. Complete in under 15 seconds
  4. Work without manual env overrides (no env -u CLAUDECODE, no unset prefix)

Evidence

Tested on branch fix/nested-seatbelt-bypass with CLAUDE_SANDBOX_ACTIVE=1 confirmed in env:

Criteria Result
Exit 0
Non-empty stdout ❌ Empty (0 bytes)
Complete in <15s
No manual env overrides

Hypothesis

Claude Code may redirect or suppress child claude process stdout when invoked from the Bash tool. This is separate from the Seatbelt sandbox issue — it's Claude Code internal output handling.

Acceptance Criteria

  • claude -p produces non-empty stdout when called from Bash tool
  • No manual env variable workarounds required
  • Works under Seatbelt sandbox (branch sessions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions