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 license-gated command.
codecharter login, codecharter logout and codecharter auth status are not
license-gated and never return 6. login exits 0 on a completed sign-in and
1 when it was denied, expired, or the credentials could not be stored;
logout and auth status always exit 0. See
Browser sign-in.
codecharter coverage has its own set — 1 below the threshold, 2 failed or
incomplete tests, 3 no coverage data, 64 usage or environment error — listed
in full on codecharter coverage.
codecharter graph uses a smaller set of its own — 2 for a usage error
(including an unresolved or ambiguous target) and 3 for a failed analysis,
with no findings-based exit code since it has nothing to gate — listed in
full on codecharter graph.
An invalid global --workspace (a path that does not exist, or one that
conflicts with the command's own absolute path) is a usage error of the
command it was given to: 64 for coverage and baseline migrate, 2 for
every other command. See
Choosing the workspace.
codecharter req check also uses its own small set — 1 on any Error-level
diagnostic, 2 for a usage error (an invalid --workspace path or an
unknown --output value) — listed in full on
codecharter req check.
| 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 rule source configured, a --rules directory that does not exist, a corrupt baseline file, or a missing lockfile when profiles are configured), or an inconclusive run: the result cannot be trusted, whatever it found. Stderr names each reason with its code, for example [core-library-unresolved] or [config-lock-drift]. See Run context and reach. |
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. |
64 |
Your license covers more than one organization and none was selected via org: in .codecharter/config.yml or the CODECHARTER_ORG environment variable. See Choosing an Organization in the CLI. Unrelated to the 64 that codecharter coverage returns for a usage or environment error. |
--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 error, configuration error or inconclusive run (see stderr)" ;;
esac