Skip to content

Claude Code stops claude -p reporting success on broken runs

Version 2.1.318 fixes claude -p and Agent SDK sessions that exited clean even when a reply was cut off or a command failed outright.

Source: Anthropic

Anthropic shipped Claude Code 2.1.318 on 4 November, fixing a bug where claude -p and Agent SDK sessions reported success even when an API error cut off the reply mid-stream while a mod had hooked turn.step. The same release fixes claude -p exiting with code 0 and no output when startup itself failed, it now prints the error and exits 1, and a separate case where custom slash commands that fail, or that only Claude can invoke, printed nothing at all in claude -p and SDK output.

claude -p "run the task" ; echo $?

That line is the exact pattern the bugs broke: a 0 that didn’t mean what you thought it meant.

Why it matters: anyone running Claude Code headlessly in CI or behind the Agent SDK has been trusting an exit code that could read clean on a run that actually failed partway through. 2.1.318 makes that signal trustworthy again, worth upgrading to before you build more automation on top of it.

The caveat: this only affects headless use, claude -p and the Agent SDK. Interactive sessions were not reporting false success in the same way.

Share

Related reading

More from The Wire

All briefs