Your Claude Code CLI batch loop might look perfect—it runs, it finishes—but half of your .typed files could be filled with error messages instead of valid Python code, and you won't discover the problem until py_compile runs. This is the most common failure pattern in Claude Code CLI automation, and it stems from a simple oversight: bare bash loops don't check exit codes.
In this short, we break down exactly why naive claude -p batch loops fail in production and what you need to know before automating anything at scale with Claude Code CLI. Always implement exit code checks to ensure each iteration succeeds before moving to the next.