Skip to content

Exit Codes

What exit codes the CLI returns and what they mean.

The table below applies to codecharter analyze. Other commands reuse the same numbers with different meanings (for example, codecharter test exits 1 on spec failures and codecharter verify exits 1 when drift is detected). Exit code 6 (license error) applies to every command.

Code Meaning
0 Success. No findings above the --fail-on threshold.
1 Findings above the --fail-on threshold.
2 Usage or configuration error (for example invalid flag combinations, a missing diff file, no rules directory found, a corrupt baseline file, or a missing lockfile when profiles are configured).
3 Analysis could not run. Either the solution failed to load, or the profile cache is incomplete and the portal cannot be reached. In the latter case, run codecharter update while online.
4 Lockfile out of date. With platform profiles configured, a profile's content hash differs from what the portal reports. Run codecharter update.
6 License error. License file is missing, expired, tampered with, or not valid for this CLI version. See License File.
10 Configuration file structurally invalid. .codecharter/config.yml or .codecharter/config.local.yml contains malformed YAML or an invalid structure. The exact error is printed to stderr.

--fail-on and Exit Code 1

codecharter analyze MySolution.sln --fail-on error
codecharter analyze MySolution.sln --fail-on warn
codecharter analyze MySolution.sln --fail-on info
Value Exit code 1 when
error at least one error finding
warn at least one warn or error finding
info at least one finding at all

Without --fail-on, any finding causes exit code 1. Pass --fail-on error to gate only on error-severity findings.

Examples in CI Shells

GitHub Actions

- name: CodeCharter
  run: codecharter analyze MySolution.sln --fail-on error
  # Exit code 1 turns the step red, GitHub stops the job.

Bash — reading exit codes

codecharter analyze MySolution.sln --fail-on error
code=$?
case $code in
  0) echo "ok" ;;
  1) echo "findings over threshold" ;;
  2) echo "usage or configuration error" ;;
esac