{"version":"2.1.284","anchor":"headless-textjson-runs-now-exit-with-a-local-slash-command","canonical_anchor":"headless-textjson-runs-now-exit-with-a-local-slash-command","heading":"Scripts using claude -p get a local command's exit code","tier":"use","area":"Headless Mode","url":"https:\/\/changelogs.core-directive.com\/v\/2.1.284\/e\/headless-textjson-runs-now-exit-with-a-local-slash-command","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.284","markdown":"### Scripts using `claude -p` get a local command's exit code\n\nIn `-p` mode with text or json output, Claude Code now exits with the exit code a local slash command reported, instead of always 0\n\n**Unclear.** It is unclear which local commands actually report an exit code.\n\n**What**\n\nWhen you run Claude Code non-interactively with `claude -p`, the exit code (the number a program returns to say whether it succeeded) was 0 on success. With text or json output it now comes from a local slash command, meaning a command Claude Code handles itself without asking the model, when that command reported an exit code and the turn did not go on to the model. Otherwise it stays 0.\n\n- Commands from plugins do not set it.\n\n- With `stream-json` output the exit code is still 0.\n\n**Why**\n\nScripts that run something like `claude -p \"\/some-command\"` can now tell from the exit code whether the command failed.\n\n- Area: Headless Mode\n- Tier: Use it now\n- Useful: 3\/5\n- Signal: 1\/5"}