Use exit codes when running AgentGit from a script or agent tool. Read the
message too: it names the affected target and the next step. For an
interactive problem, begin with agit status and agit doctor; see
Everyday commands.
Exit code meanings
| Code | Name | Meaning | Next step |
|---|---|---|---|
| 0 | Ok | Command completed successfully | Continue; read output for cancellations or skipped work |
| 1 | Failure | General failure | Read the reported error |
| 2 | Usage | Invalid arguments | Check agit <command> --help |
| 3 | Ref | A reference cannot be resolved or is ambiguous | Check agit status and use an explicit owner/repo@branch |
| 4 | Precondition | A required condition is not met | Follow the reported prerequisite |
| 5 | Auth | Credentials are missing or rejected | Sign in with agit login |
| 6 | Network | Network or Hub request failed | Check connectivity and the reported Hub error before retrying |
| 7 | Policy | A policy or integrity check refused the operation | Inspect the finding and follow its instructions |
| 8 | Interactive | The command needs an interactive terminal or decision | Run the indicated command in a terminal with the required input |
Handle refusals explicitly
A nonzero result should stop dependent work. Do not treat it as a successful save, publication, or merge. For example, use a shell condition to publish only after saving succeeds:
if agit commit alice/my-project@first-task; then
agit push alice/my-project@first-task
fi
Replace the target with your own. Code 7 from push can mean a secret was
found or that some outgoing content could not be fully scanned. The
printed reason determines the remedy; an empty findings list alone does
not establish that publication is safe.
Code 8 can mean that a confirmation, explicit import-lineage choice, or
terminal interface is required. A new import without --onto or
--independent cannot choose its lineage in an agent shell or JSON mode;
--yes does not answer that choice.
Pass an explicit target where appropriate, and keep decisions such as
publishing or changing visibility explicit in your automation.
Some commands can complete with a cancellation or skipped branch reported
in their output. For the saved or published result, verify the target with
agit status and agit log rather than relying on the exit code alone.
Return to the command reference for available operations and their help commands.