Exit code reference
| Code | Meaning | When it happens |
|---|---|---|
| 0 | All safe | Every attack was blocked. Benchmark passed threshold. No findings. |
| 1 | Safety failure | At least one attack bypassed safety. Benchmark below threshold. Critical scan finding. |
| 2 | Configuration error | Unknown provider, missing API key, invalid arguments. |
Which commands use exit codes
| Command | Exit 0 | Exit 1 | Exit 2 |
|---|---|---|---|
ai-blackteam run | Attack blocked | Attack bypassed | Unknown provider/attack |
ai-blackteam batch | All blocked | Any bypassed | Unknown provider |
ai-blackteam sweep | All blocked across all providers | Any bypassed | No providers configured |
ai-blackteam benchmark | Score >= threshold | Score < threshold | Invalid config |
ai-blackteam defend | No bypasses with defense | Bypasses with defense | Missing defense args |
ai-blackteam scan | No critical findings | Critical findings found | Path not found |
ai-blackteam asl3 | All blocked | Any bypassed | Unknown provider |
ai-blackteam expand run | All blocked | Any bypassed | Unknown provider |
ai-blackteam mega-sweep | (always 0) | (always 0) | Missing dataset |
Using exit codes in CI
Basic pass/fail gate
--quiet flag suppresses output, so the command just returns a code. Useful when you only care about pass/fail.
Shell conditionals
GitHub Actions branch protection
In your workflow, a non-zero exit code automatically fails the check:Threshold-based gates
--threshold flag makes ai-blackteam benchmark exit 1 if the score is below the specified percentage. This is the recommended way to set a minimum safety bar.
Combining with deployment
&& ensures deployment only happens if safety passes.
Multiple conditions
Handling exit code 2
Exit code 2 means a configuration problem, not a safety issue. Common causes:- API key not set in environment or config
- Unknown provider name (typo)
- Unknown attack name
- Missing required flags