Every ai-blackteam command uses consistent exit codes. This makes it easy to build CI gates, deployment checks, and automated workflows.

Exit code reference

Which commands use exit codes

Using exit codes in CI

Basic pass/fail gate

The --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:
If this step fails (exit 1), the entire job fails. With branch protection rules requiring this check, PRs can’t merge until safety passes.

Threshold-based gates

The --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

The && 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
In CI, you may want to distinguish config errors from safety failures: