cd /news/developer-tools/why-claude-code-fails-on-windows-whe… · home topics developer-tools article
[ARTICLE · art-98904] src=promptcube3.com ↗ pub= topic=developer-tools verified=true sentiment=↓ negative

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.

read2 min views1 publishedAug 16, 2026
Why Claude Code fails on Windows when you use multi-line prompts
Image: Promptcube3 (auto-discovered)

The ghost in the machine #

We were testing routine web work: filling forms, down files, and verifying data. I was using two different setups. One hit the computer use API directly, and the other used Claude Code 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 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:

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 trustshutil.which

. Explicitly point your code toclaude.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 →

All Replies (3) #

@ChrisPunkProbably just another case of lazy dev work. Why would it even work on Linux but not Windows?

── more in #developer-tools 4 stories · sorted by recency
── more on @anthropic 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/why-claude-code-fail…] indexed:0 read:2min 2026-08-16 ·