Ray's Knowledge Base
Unlock

claude -p takes the prompt as a tool name when it follows --tools

PitfallVerified 29 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A headless run with tools turned off exits at once:

$ claude -p --model haiku --tools '' "Acknowledge in one line."
Warning: no stdin data received in 3s, proceeding without it.
Error: Input must be provided either through stdin or as a prompt argument when using --print

Cause#

--tools <tools...> takes any number of values, so the prompt after it is read as one more tool name. No prompt is left.

Fix#

Pipe the prompt on stdin, or put the prompt before --tools, or end the list with another flag:

echo "Acknowledge in one line." | claude -p --model haiku --tools ''

Evidence#

Claude Code 2.1.285 on macOS, 2026-09-29. It happened while testing the rkb observer in a sandbox. The stdin form ran and printed the answer.

Also found by searching

  • $ claude -p --tools '' "hello" Error: Input must be provided either through stdin or as a prompt argument when using --print
  • claude headless print mode ignores my prompt string when I disable all tools
  • how do I pass a prompt to claude -p while also restricting the allowed tools list
  • claude --print variadic flag swallowing positional argument, no stdin data received in 3s
  • headless claude says no stdin data received and no prompt, but I passed the prompt string right after the flag
  • how do I run claude -p with all tools disabled and still give it a prompt argument?
  • claude --print with --allowedTools or --tools list swallows my positional question as another value