Agent guide: CLI commands, large files, exit codes¶
Moved verbatim out of the root
AGENTS.md(progressive disclosure: the root file is loaded into every agent session, this one only when its pointer fires). The rootAGENTS.mdremains the primary contract.
Files that are large — edit carefully¶
Don't trust hard-coded line counts — they drift. The AI-readiness gate is the source of truth: it WARNs on any file >1500 lines and ERRORs >2000 (hard cap, no allowlist). To see today's large files, run:
That sentence is load-bearing: this paragraph previously named the WARN set as
"cli.py, dumper.py, and buildsource/cross_source_checks.py" long after it had
stopped being true (cli.py is now a small registration facade), which is
exactly the drift the "don't trust hard-coded line counts" warning above is
about. As a shape rather than a list: the WARN set is large — roughly 100
files, about a third of them under abicheck/ — and a meaningful number sit
within a few lines of the 2000-line hard cap, so a routine addition to one can
turn an ERROR on. Run the command; don't reason from any count written here.
architecture/debt.yaml is the sharper gate for these files and the one you
will actually trip: every one of them carries a no_growth baseline
(python scripts/check_architecture.py), so growing one is a reviewed
debt-baseline change, not an ordinary edit. ADR-061's definition of done wants
that file empty or holding only accepted exceptions — the way to shrink an
entry is to move responsibility out to a properly-owned module, never to
trim the file to fit (report/render_html.py is a worked example: it took
~200 lines of formatting out of html_report.py by giving them an owner).
When editing any large file, read the specific section you need rather than the
whole file. Several big commands have already been split into sibling
cli_<name>.py / diff_* modules (see module-map.md); prefer extending a
split-out module over growing the parent toward the cap.
Retiring a command or flag¶
Ask the maintainer how it leaves, before deleting it. The answer depends on who still calls it:
- Delete outright: the command, its tests, docs and hints all go, and
the CLI answers with its ordinary "no such command". A changelog fragment
names the replacement. The
compatremoval took this path. - Tombstone for one release: a stub that exits 64 with a pointer to the
replacement, removed in the next release.
scantook this path.
Pre-1.0 either is acceptable and the maintainer picks per case. Once abicheck promises backward compatibility, a retirement follows its ADR's deprecation window instead.
Adding a new top-level command¶
First, ask whether it should be a root command at all (ADR-043/ADR-054).
The public root surface is exactly dump, compare, deps,
aggregate, project — scan was retired by ADR-068 Phase 6, which deleted
the command and its scan-only modules, and the ABICC compat drop-in was
removed too — and tests/test_cli_root_surface.py
pins that set as
an executable contract, so a new root registration fails CI until the test is
updated too. Before adding one, a new root command must clear every one of
these (ADR-054's admission bar — the same review that consolidated four
G30/ADR-047 root groups, one added per artifact, back into the single
project group below):
- It answers a stable, user-facing question — not "here is JSON artifact X, let me expose the function that reads/writes it."
- Its operand is a domain object a user already thinks in terms of (a binary, a set of reports, a project config) — not an internal pipeline transport format (a manifest, a projection of another artifact).
- It is useful outside one specific CI Action's wire format. A command whose
whole job is "shape this JSON exactly how
actions/foo's one input expects it" is a library function that Action/workflow calls directly (python3 -c "from abicheck.x import y; ..."), not CLI surface — seeabicheck/buildsource/baseline_publish.py'sderive_baseline_libraries()for the pattern (used bypublish-baseline.yml/update-main-baseline.yml, never a CLI command). - It doesn't already fit naturally as an option or subcommand of an existing
durable operation (
--dry-run, a new<verb> <noun>subcommand under an existing group) — a second, parallel "preflight" vocabulary next to an already-established one (dump --dry-run) is exactly the drift ADR-050'splan --dump-manifestcommand caused before ADR-054 folded it back intodump --dump-manifest --dry-run. - It has a real, validated usage scenario beyond the PR that introduced it — not just "this pipeline stage produces an artifact, so it should be inspectable."
- Landing it means updating
tests/test_cli_root_surface.py, this file,README.md, anddocs/reference/cli-reference.md(python scripts/gen_cli_reference.py) in the same PR — a root surface change with only the test updated (or only the code) is how ADR-043's "nothing else is registered" invariant drifted from the actual command set before (the CLI carried ten root commands whileREADME.mdstill said six).
If it's advanced multi-target/CI-integration surface that fails the "user
already thinks in terms of this operand" bar (#2) on its own — validating a
project's .abicheck.yml, a build-output.json, or generating a run-plan —
it almost certainly belongs as a new subcommand of the existing project
group (abicheck/cli_project.py), not a new root command. project exists
precisely to hold this class of operation: project validate (one command
over a project config, a build-output directory, or a use-case manifest,
dispatched on the document's own schema — never its filename),
project plan, project history are all "read one project-integration
artifact, report on it" operations that share one advanced/opt-in namespace
instead of each claiming root. Add @project_group.command("your-verb")
there and extend tests/test_cli_root_surface.py's existing assertions
(which don't need to change, since project's subcommand set isn't pinned
the way the root set is) plus a TestProjectYourVerbCli-shaped test class.
Once a root command genuinely clears the bar above, pick the right home:
- Small command (one function, no significant helpers) — add to
cli.pydirectly with@main.command(...). - Larger command or command group — add as a sibling
abicheck/cli_<name>.pymodule: - Top of module:
from .cli import main(and any shared_helpers). - Decorate with
@main.command("foo")or@main.group("foo")as usual. - At the bottom of
cli.py, addcli_<name>to the side-effectfrom . import (...)block — that runs aftermainand helpers are defined, registering the new command. - If the new module uses
@clickdecorators, addabicheck.cli_<name>to thedisallow_untyped_decorators = falseoverride inpyproject.toml(alongside the existing entries). - If
scripts/check_ai_readiness.pyflags a cycle, this isIMPORT_CYCLE_ALLOWLIST's known CLI-registration cluster — see the import-cycle rule in the rootAGENTS.md"Rules" section before extending it. - Shared utility flags go through a decorator, not an inline copy.
-v/--verboseis@verbose_option, the one-o FORMAT=DESTINATIONexport request isexport_options(...), language islang_option(...)(all incli_options.py). Every visible option must carryhelp=text and a shared concept must use one canonical primary spelling — both are enforced bytests/test_cli_contract.py(test_no_option_has_empty_help,test_shared_concept_canonical_spelling). - Moving helpers out of a module that re-exports them? If you relocate a helper that an existing module re-exports "for API stability / tests" (e.g. the
cli_buildsourceblock), preserve the old import path with a lazy module-level__getattr__shim that resolves viaimportlib.import_module— a staticfrom .new_module import …re-export would re-introduce the import cycle the split was meant to avoid (see the shim at the tail ofcli_buildsource.py).
Exit codes¶
comparecommand (legacy, with no severity setting in effect): 0 = compatible, 2 = source break, 4 = ABI breakcomparecommand (severity-aware, withseverity.presetor a configseverity:block): 0 = no error-level findings, 1 = error in addition/quality only, 2 = error in potential_breaking, 4 = error in abi_breakingscan(includingscan --against) was deleted by ADR-068 Phase 6; its baseline mode iscompare OLD NEWand its audit mode iscompare --no-baseline NEW, both covered by thecomparerows above.- Orthogonal contract-coverage axis (ADR-049 Phase 7), on
compare(single-pair and directory/package alike): under a stated domain (--contract,.abicheck.ymlscope.public, or APIcontract_mode), the selected domain whose required evidence is incomplete contributes 1, folded withmax(contract_coverage_exit.py). It raises a clean0to1and never lowers a2/4, and it never rewrites a finding's compatibility decision or gate contribution. With no stated domain the evidence-adaptive default domain is one the run's own evidence closes, so the contribution is normally0. Every consumer that publishes an exit status folds it and explains it — the two CLIs and the composite Action (verdict: COVERAGE_INCOMPLETE). A directory/packagecompare(the per-library release fan-out) applies the same flag to each library andmaxs every library's own contribution into the release's exit code, stated in the release JSON summary under the samecontract_coverage_exit_contributionfield.gate.fail_on_removed_library's exit8is checked ahead of this coverage-only fallback when both could apply, so a removed library's own signal is never masked by an unrelated coverage gap - Orthogonal completeness axis (ADR-065 D6/D7, S2), directory/package
compareonly: a selected, expected member that never reached a completed comparison (not_suppliedwith no completeness proof on the lacking side,unsupported,failed) makesrun_outcome.scopereadincompleteand contributes1underscope.on_incomplete: block(0under the defaultwarn), folded withmaxlike the coverage axis; a run that completed no comparison at all contributes1under either setting (no_comparison_completed). Exit8requires a proven removal (NEW's inventory proven complete -- a storedProjectSnapshotpackage or bundle-facts document whose capture assertedinventory_complete; the container type alone proves nothing); an unmatched library under an unproven inventory is never a removal (unmatched_oldkeeps listing it). Owners:model/scope_acquisition.py(the record),policy/scope_completeness.py(the fold),workflows/release_scope.py(the release builder, with D9's one-candidate narrowing -- applied only when NEW is named as a single file, never from a discovered one-member directory, so a PR-controlled NEW tree cannot narrow its way pastblock),report/comparison_scope.py(the section) 64= usage error (bad flags/inputs;cli._EXIT_USAGE_ERROR) — applies across commands- Full per-command matrix:
docs/reference/exit-codes.md