Why Claude Code fails on Windows when you use multi-line prompts Anthropic's Claude Code CLI fails on Windows when given multi-line prompts because the npm-installed claude.CMD batch shim truncates everything after the first newline, causing the agent to receive incomplete instructions. Developer tests showed the direct claude.exe binary works correctly, while the shim silently drops the prompt's second line, leading to failed tasks without any error logs. The fix is to call claude.exe directly or flatten prompts to single-line strings. Why Claude Code fails on Windows when you use multi-line prompts The ghost in the machine We were testing routine web work: filling forms, downloading files, and verifying data. I was using two different setups. One hit the computer use API directly, and the other used Claude Code /en/tags/claude%20code/ in headless mode claude -p paired with Playwright. To keep things objective, we used machine verification. We didn't trust the agent's "I'm done" message; we checked the actual JSONL payloads and file sizes. When the headless setup started failing almost every single trial, my first instinct was that the model was just choking on the specific prompt format. I was wrong. The model wasn't the problem—the Windows environment was. The culprit is the .CMD shim If you're on Windows and installed Claude /en/tags/claude/ Code via npm, you've got a file called claude.CMD sitting on your PATH. When you use Python's subprocess or shutil.which "claude" , Windows resolves to that .CMD file instead of the actual executable. That file is just a batch wrapper: "%dp0%\node modules\@anthropic-ai\claude-code\bin\claude.exe" % Here is the catch: when you pass a multi-line prompt through that % argument forwarder in cmd.exe , everything after the first newline is silently deleted. The agent doesn't get an error; it just receives a truncated prompt. In my tests, the agent would see "Follow the instruction below exactly," and then nothing. Of course, it failed because the actual instructions were on line two. I put together this snippet to prove it. If you run this, you'll see the shim fails while the direct .exe works: python import os, subprocess EXE = os.path.join os.environ "APPDATA" , "npm", "node modules", "@anthropic-ai", "claude-code", "bin", "claude.exe" CMD = os.path.join os.environ "APPDATA" , "npm", "claude.CMD" PROMPT = "Follow the instruction below exactly.\nOutput the string MARKER TAIL 9137 and nothing else." for label, argv0 in "claude.CMD shim ", CMD , "claude.exe direct ", EXE : r = subprocess.run argv0, "-p", PROMPT , capture output=True, text=True, encoding="utf-8", errors="replace", timeout=180 out = r.stdout or "" + r.stderr or "" print label, "tail received =", "MARKER TAIL 9137" in out How to fix your AI workflow This is a nightmare to debug because there are no crash logs or non-zero exit codes. Everything looks "fine," but your agent is basically operating with amnesia. If you're building a real-world deployment on Windows, you have two options to avoid this: Call the binary directly: Don't trust shutil.which . Explicitly point your code to claude.exe . Flatten your prompts: Replace all newlines with spaces before passing the string to the CLI. This is the safer bet for cross-platform stability. For anyone doing deep dive prompt engineering, just remember that the "plumbing" between your Python script and the LLM can be just as volatile as the model itself. Next Claude Code managed to polish our internal agent using a $10k → /en/threads/6472/ All Replies (3) @ChrisPunk /en/users/ChrisPunk/ Probably just another case of lazy dev work. Why would it even work on Linux but not Windows?