Docs / Exit codes

Exit codes

Exit codes your scripts can branch on.

Stable, scriptable meanings. The message tells a human what happened; the exit code tells a script what to do.

CodeNameMeaningTypical next step
0Okworked
1Failurelegacy catch-all (being retired in favor of precise codes)read stderr
2Usagebad argumentsfix the invocation
3Refreference unresolvable or ambiguouscheck agit log, spell the ref fully
4Preconditiona precondition wasn’t metrun the command it tells you to run
5Authnot signed in, or token rejectedagit login
6Networkhub unreachable / network errorretry in a moment; if it persists, the hub may be down
7Policya gate refused: secret scan, push gate, baseline mismatchfollow the printed reason
8NeedsDecisionneeds an interactive answer (e.g. publish from a read-only clone) but stdin isn’t a TTYrun the exact command it prints

Two examples of the code carrying the story:

  • 8 in CI is the designed answer to “promote this clone or not?” — the decision belongs to a person, so automation gets the command to hand them, not a guess.
  • 7 from agit push means the secret scan found something. There is no silent override on the hub side; fix the content.

All codes are regression-pinned by the CLI’s test suite against a table in src/lib.rs — they don’t drift.