The sn CLI uses standardized exit codes so CI wrappers and shell scripts can distinguish between failure classes without parsing output text.
Exit Codes
Standardized exit codes returned by the sn CLI.
| Code | Meaning | When |
|---|---|---|
| 0 | Success | Command completed without error |
| 1 | Runtime error | Network failure, instance rejected the request, assertion failed |
| 2 | Usage error | Missing argument, unknown flag, bad manifest path, or unrecognized subcommand |
| 3 | HTTP error | Non-2xx response from the target instance (`sn rest`), or drift gate blocked execute |
| 4 | Health gate | Regression lock conflict or health preflight threshold exceeded |
| 130 | SIGINT | User hit Ctrl-C mid-run (POSIX convention) |
| 143 | SIGTERM | Process was killed externally (POSIX convention) |
Pair with $? in shell scripts to branch on failure class:
sn execute manifest.ts
code=$?
if [ $code -eq 0 ]; then
echo "Deploy succeeded"
elif [ $code -eq 3 ]; then
echo "Drift detected — check sn drift manifest.ts"
elif [ $code -eq 4 ]; then
echo "Health gate blocked — check sn regression"
else
echo "Unexpected failure (exit $code)"
fiExit codes 130 and 143 follow the POSIX convention of 128 + signal_number (SIGINT=2, SIGTERM=15). Most CI systems surface these automatically as "cancelled" or "killed" rather than a raw number.