[BUG] claude -p (--print) returns empty stdout in 2.1.83 (regression from 2.1.81)

Resolved 💬 3 comments Opened Mar 25, 2026 by tayfunbulent Closed Mar 25, 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?

claude -p (print/non-interactive mode) returns empty stdout in version 2.1.83. The model generates a response (confirmed via --output-format stream-json), but the text is not written to stdout or the result field.

This breaks any automation, scripts, or CI/CD pipelines that rely on claude -p for headless usage.

What Should Happen?

claude -p "prompt" should print the model's text response to stdout, as it did in 2.1.81 and all prior versions.

Error Messages/Logs

# 2.1.83 — empty output
$ npx @anthropic-ai/claude-code@2.1.83 -p "Say hello in one word"
(empty — no output, exit code 0)

# 2.1.81 — works correctly
$ npx @anthropic-ai/claude-code@2.1.81 -p "Say hello in one word"
Hello!

# 2.1.83 with --output-format json shows result is empty despite tokens being generated
$ claude -p "Say hello" --max-turns 1 --output-format json
{"type":"result","subtype":"success","is_error":false,...,"result":"","output_tokens":21,...}

# 2.1.83 with --output-format stream-json confirms the model DOES produce text
# Assistant message contains {"type":"text","text":"hello world"}
# But the final result event has "result":""

Steps to Reproduce

  1. Install Claude Code 2.1.83: npm install -g @anthropic-ai/claude-code@2.1.83
  2. Run: claude -p "Say hello in one word"
  3. Observe: no output on stdout, exit code 0
  4. Compare with 2.1.81: npx @anthropic-ai/claude-code@2.1.81 -p "Say hello in one word" → prints response correctly

Root Cause Hypothesis

The stream-json verbose output shows that the model generates a response with both thinking and text content blocks. The text block contains the actual response, but it is not aggregated into the final result field. Likely candidates from the 2.1.83 changelog:

  • --bare -p (SDK pattern) is ~14% faster to the API request — optimization to the -p output path may have broken text result aggregation
  • Faster claude -p startup with unauthenticated HTTP/SSE MCP servers (~600ms saved) — changes to -p startup flow
  • Fixed claude.ai MCP connectors (Slack, Gmail, etc.) not being available in single-turn --print mode — changes to --print mode behavior

Is this a regression?

Yes, this worked in a previous version.

Last Working Version

2.1.81

Claude Code Version

2.1.83 (Claude Code)

Claude Model

Opus

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

  • Also reproduced from non-interactive environments (launchd scheduled jobs)
  • The --output-format json output confirms tokens are consumed and billed, but the result string is empty
  • Both claude -p "prompt" (argument) and echo "prompt" | claude -p (stdin) produce the same empty result
  • The --long form --print behaves identically (empty)

View original on GitHub ↗

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