Try the demo

batch file arguments are invalid

Your Rust program passes a multi-line prompt to an agent's command line, and it works everywhere but Windows.

The error

Error { kind: InvalidInput, message: "batch file arguments are invalid" }

Why it happens

On Windows, npm installs command-line tools as .cmd scripts: claude.cmd, codex.cmd. Running one goes through cmd.exe, whose quoting rules can't carry every argument safely. Since Rust 1.77.2, the fix for CVE-2024-24576, Command escapes arguments for batch files and refuses the ones it can't pass safely. A line break is one of them, so a multi-line prompt fails before anything runs.

A second trap sits next to it: Command::new("claude") looks for claude.exe, so with an npm install it fails with program not found. Resolve the full path first.

The fix

  • Send the text on stdin. Many agent CLIs read the prompt from it: codex exec - does.
  • Or write it to a file and pass the file's path.
  • Or run the real program behind the shim, when the package ships one.

Test with a real .cmd shim. A stand-in .exe in your tests passes both traps, and the bug ships.

How we found it

Building DMN, whose panes start Claude Code and Codex for you. DMN now runs the program behind the shim where there is one, and sends Codex its prompt on stdin.

DMN reads your agents' past sessions on your machine. When the same error is fixed the same way in two or more of them, it keeps the fix as a one-line lesson. When the error turns up again, Claude Code is told the fix straight away, and any agent can search what earlier sessions found. How DMN keeps what agents learn.

Stop fixing the same error twice