Summary
AGENTS.md states the convention: "Return usage errors as usageError so CLI misuse exits 2; runtime/daemon failures should exit 1." Two commands don't follow it for argument-count misuse — they exit 1 instead of 2.
Where
ao review submit and ao preview declare their positional-arg validators with a bare Cobra validator:
backend/internal/cli/review.go — Args: cobra.MaximumNArgs(1)
backend/internal/cli/preview.go — Args: cobra.MaximumNArgs(1) (and preview clear → Args: cobra.NoArgs)
Cobra's arg-count error is a plain errors.New(...). The root's SetFlagErrorFunc only wraps flag-parse errors as usageError, not Args validation, so a too-many-args error is not a usageError and ExitCode returns 1.
Every other command wraps its validator so arg-count misuse becomes a usageError (exit 2): noArgs (root.go), oneSessionIDArg / the claim-pr and rename validators (session.go), and the inline wrappers in project.go and completion.go.
Repro
$ ao review submit mer-1 mer-2
Error: accepts at most 1 arg(s), received 2
$ echo $?
1 # expected 2
Same for ao preview a b and ao preview clear extra.
This is inconsistent with the commands' own tests, which already assert exit 2 for their other usage errors (TestReviewSubmitMissing*IsUsageError, TestPreview_*IsUsageError). A caller that distinguishes usage misuse (2) from a daemon/runtime failure (1) misclassifies these.
Suggested fix
Wrap the arg validators so arg-count misuse returns usageError (exit 2), matching the sibling commands, and reuse the existing noArgs helper for preview clear.
Summary
AGENTS.mdstates the convention: "Return usage errors asusageErrorso CLI misuse exits 2; runtime/daemon failures should exit 1." Two commands don't follow it for argument-count misuse — they exit1instead of2.Where
ao review submitandao previewdeclare their positional-arg validators with a bare Cobra validator:backend/internal/cli/review.go—Args: cobra.MaximumNArgs(1)backend/internal/cli/preview.go—Args: cobra.MaximumNArgs(1)(andpreview clear→Args: cobra.NoArgs)Cobra's arg-count error is a plain
errors.New(...). The root'sSetFlagErrorFunconly wraps flag-parse errors asusageError, notArgsvalidation, so a too-many-args error is not ausageErrorandExitCodereturns1.Every other command wraps its validator so arg-count misuse becomes a
usageError(exit 2):noArgs(root.go),oneSessionIDArg/ the claim-pr and rename validators (session.go), and the inline wrappers inproject.goandcompletion.go.Repro
Same for
ao preview a bandao preview clear extra.This is inconsistent with the commands' own tests, which already assert exit
2for their other usage errors (TestReviewSubmitMissing*IsUsageError,TestPreview_*IsUsageError). A caller that distinguishes usage misuse (2) from a daemon/runtime failure (1) misclassifies these.Suggested fix
Wrap the arg validators so arg-count misuse returns
usageError(exit 2), matching the sibling commands, and reuse the existingnoArgshelper forpreview clear.