On this page · 8 sections
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 Error does not name a next step. Error does not name a next step 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 <rule-id> 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 about the same pattern as this rule. They don’t test the rule itself.
Constraints stated only in prose produce silent failures on live APIs
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.
Preprint: not yet peer reviewed
Error text that names the next tool lifts recovery
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%.
Preprint: not yet peer reviewed
Naming recovery tools is the active ingredient in failure receipts
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.
Preprint: not yet peer reviewed
Idempotency keys cut duplicate writes from 28% to 4%
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.
Preprint: not yet peer reviewed
FAQ blocks and structured data showed no citation effect within a domain
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.
Preprint: not yet peer reviewed
Skill selection precision collapses as the skill pool grows
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%.
Preprint: not yet peer reviewed
Related guides
Agent error recovery: design the path back
Agent error recovery in practice: what a failure response must say, when a retry is safe, how to handle partial completion, and when to escalate.
Guide
Agentic Resource Discovery, implemented
Agentic Resource Discovery explained: what ARD is, how /.well-known/ard.json relates to MCP's ai-catalog.json, and a worked example you can copy to publish your own.
Guide
Agent tool catalogues need a pruning strategy
How to design an agent tool catalogue: why selection gets harder as an MCP tool catalog grows, three ways to prune it, and how to name neighbouring tools.
Guide
