ax-check rule
AXC-C005: Unknown command gives no suggestion
An unknown subcommand produced no "did you mean", no list of valid commands and no pointer to help.
ax-check is a checker being prepared for release. This page documents the rule ahead of that release; see all 50 rules.
| Severity | warn |
| Kind | Heuristic. A pattern match: a prompt to look, not a verdict. |
| Mode | ax-check probe-cli |
| Applies to | Command-line programs, run as a subprocess |
| Pattern tags | error-recovery, discovery |
| Fix in one line | On an unknown command, suggest the closest valid command and list the valid ones. |
When given a subcommand that does not exist, the program gave no “did you mean”, no list of valid commands and no pointer to help. This is the moment an agent most needs a map, and the program leaves it with nothing.
What it checks
The rule looks only at the unknown-subcommand probe, which runs <cmd> axcheck-unknown-subcommand when you pass --probe errors. It runs only when the help output lists subcommands, because a CLI with no subcommands may take the word as an ordinary argument. It fires when the output contains none of these: a “did you mean” style suggestion, a pointer to help, or at least two of the commands that help lists.
Why it matters
Agents often start with a guess at a command name taken from memory or from stale instructions. When the guess is wrong, a good CLI tells them what is available. The Command Line Interface Guidelines describe discoverable CLIs as ones that “suggest what command to run next, suggest what to do when there is an error.” A suggestion turns a dead end into one more step. Without it the agent must try --help, parse it, and retry, if it thinks to do so at all.
This rule is narrower than AXC-C004. AXC-C004 asks whether any error names a next step. This rule asks whether the unknown-command case lists the real commands.
How to fix
On an unknown command, print the closest valid command and list the valid ones, or at least point to --help. Keep it short.
Example
Before
$ invoicer axcheck-unknown-subcommand </dev/null; echo $?
error: command failed
1
After
$ invoicer axcheck-unknown-subcommand </dev/null; echo $?
error: unknown command "axcheck-unknown-subcommand".
Valid commands: create, list, show, export, void.
Run: invoicer --help
2
For a near miss, a suggestion is better still:
$ invoicer crate
error: unknown command "crate". Did you mean "create"?
A Python fix using the standard library:
import difflib
close = difflib.get_close_matches(cmd, COMMANDS, n=1)
if close:
print(f'error: unknown command "{cmd}". Did you mean "{close[0]}"?', file=sys.stderr)
print("Valid commands: " + ", ".join(COMMANDS), file=sys.stderr)
How ax-check detects it
ax-check parses the help output for the names of the subcommands. It then checks the unknown-subcommand output for “did you mean” (or “perhaps you meant”, “maybe you meant”, “similar command”), for help or --help, for “available commands”, “valid commands” or a “commands:” heading, or for the names of at least two real subcommands. It never invents or mistypes one of your real subcommands to test for suggestions. Some CLIs auto-correct a typo and run the corrected command, which would cause a real action, so ax-check always uses the fixed name axcheck-unknown-subcommand. This means it cannot test your “did you mean” logic for near misses. It only checks that the far-miss case is helpful.
To reproduce by hand: invoicer axcheck-unknown-subcommand </dev/null; echo $?.
A CLI whose help does not list its subcommands in a form ax-check can parse is not tested at all, so the rule can miss real problems. Silence it with --disable AXC-C005 if it does not apply.
Safety note: The error probes this rule needs are opt-in: run with --probe errors. Without it the rule is not checked, and the report lists it as not checked. Argument parsers normally reject an unknown subcommand, an unknown flag or a missing value before doing any work, but a program that does not validate its arguments will do its ordinary work instead. probe-cli executes your program under your own OS account. The temporary working directory and HOME it uses are not a sandbox: the program can still read and write anything your account can, and use the network. Probe a CLI you have not reviewed only inside a container or a throwaway virtual machine. Run ax-check probe-cli --dry-run -- invoicer first to see the probes that would run, and see the “Probe safety” section of the ax-check README for what is and is not isolated.
Sources
- Guideline: Command Line Interface Guidelines, clig.dev. https://clig.dev/ . Says discoverable CLIs suggest what command to run next and what to do when there is an error.
- Site guide: Design for recovery, agentexperience.tech. https://agentexperience.tech/insights/design-for-recovery/ . Covers errors that tell the caller the next valid action.
Related evidence
Records in the AX evidence register that share a pattern tag with this rule. A shared tag means the record is about the same pattern, not that it tests this rule. Read the evidence class before the number.
- EV-0002: Constraints stated only in prose produce silent failures on live APIs (Preprint). SilentProbe (preprint) reports that only 7.5% of 2,501 public OpenAPI documents declare an enum, and that on live endpoints machine-checkable constraints returned an honest error in 111 of 111 cases while prose-only constraints failed silently in 44 of 61.
- EV-0003: Error text that names the next tool lifts recovery (Preprint). A preprint testing five OpenAI models reports that an expired-credential error naming a terminal command left 45% of tasks recovered, naming the server's login tool instead raised recovery to 84%, and on rate limits naming the call to repeat raised recovery from 6% to 88%.
- EV-0004: Naming recovery tools is the active ingredient in failure receipts (Preprint). Outcome Monitors (preprint) reports that receipts naming a violated outcome and the public recovery tools raised ToolMaze completion from 10.9% to 28.1% across four models, and that removing the list of recovery tools eliminated the gain.
- EV-0005: Idempotency keys cut duplicate writes from 28% to 4% (Preprint). LIMBO (preprint) reports that offering an idempotency key on every write cut duplicate side effects from 28% to 4% of episodes because agents use keys when they exist, and that agents reported success in 90% of the episodes in which they had duplicated an effect.
- EV-0013: FAQ blocks and structured data showed no citation effect within a domain (Preprint). An observational study of about 2 million AI-engine citations (preprint) found that FAQ blocks, structured data and Core Web Vitals had positive effects on citation in pooled data that reversed or fell to zero once domain fixed effects were applied.
- EV-0019: Skill selection precision collapses as the skill pool grows (Preprint). A preprint reports that as the pool of available skills grew from 5 to 100, the precision with which agents actually used the right skill fell from 29.6% to 3.3%.
