Skip to content

feat(cli): usage errors show a hint for known wrong commands #4860

Done

Description

@dan-petty

Problem or Motivation

Some names fail with no Click suggestion, and agents try again and again. devops pr merge and devops gh pr merge failed 53 times in 23 sessions; only a person merges (AGENTS.md), so no such command will come. devops roadmap show|list|view|status|get failed 49 times in 45 sessions; the commands are roadmap explain <n> and roadmap inbox. devops openspec validate|list failed 37 times; these are commands of the upstream openspec CLI. devops pr show|info failed 14 times (pr view). Gate row names typed as devops ci <row> failed 25 times (the form is devops ci --only <row>). devops ai cost-report failed 8 times; the MCP tool ai_cost_report is the command devops ai cost report.

Tracker #4833, child 10. The owner asked on 2026-11-11 to fix the devops gh issue name and to record such errors for a later analysis of missing flags, features and aliases. The counts come from a study of Claude Code, Kilo, Antigravity and Loki records from 2026-09-23 to 2026-11-11.

Proposed Solution & Architectural Design

Add a data table usage_hints.yaml (command path, typed name, hint text, reason by_design, other_tool or other_name) and one rule for devops ci: a typed name that is a gate row gets the --only form from the gate registry. The group class of item usage-error-capture prints the hint as one line after Click's error, keeps exit code 2, and records hinted=true in the ledger. A hint runs no command and is not an alias. The old plural names of the rename get no hint, because Click already suggests the new name. Open tool: Click has only difflib suggestions and no hint table, so this is built; cost about 100 lines and the table, about 0.30 USD on the DeepSeek implement path and 1 day elapsed.

Target Subsystem

SDLC, Git & PR Governance (CLI usage errors: the root group class).

Existing Tool Considered

Click has only difflib suggestions and no hint table, so this is built. Cost: about 100 lines and the table, about 0.30 USD on the DeepSeek implement path, and 1 day elapsed.

Acceptance Criteria

devops pr merge 1 exits 2 and prints Click's error and one hint line that says only a person merges. devops roadmap show 1 names devops roadmap explain. devops openspec validate names openspec validate and devops openspec check. For each gate row, devops ci <row> names devops ci --only <row>. devops ai cost-report names devops ai cost report. A test fails when a hint names a command that does not resolve through core/command_resolver.py, and when the table holds a name that Click already suggests.

Dependencies

Merge first: #4839.

Source: #4833

Alternatives check of 2026-11-21: none.
Tool: none found.
Reason: Searches found only click-didyoumean, which re-adds Click's difflib subcommand suggestion, and thefuck, which corrects typed shell lines; neither offers a hint table, cross-group lookup, by-design or other-tool hints, or control of Click's option list.

Lacks:

  • No configurable hint table keyed by typed command word
  • No cross-group whole-word lookup across command tree
  • No by-design, other-tool or gate-row hint reasons
  • No control over Click's Possible options or help-flag filtering
  • click-didyoumean only repeats Click's existing difflib suggestion

Proposed design

Problem statement

Agents type command names that do not exist, and Click gives no suggestion for most of them: the study found 1,258 usage errors, and 838 had no suggestion line. A person merges pull requests, so devops pr merge will never exist, and the roadmap, openspec, ci, gh and ai names differ from what agents type. This item adds a hint table at src/devops_cli/core/usage_hints.yaml and a computed cross-group lookup. They print one hint line after Click's usage error, keep exit code 2, and record hinted in the usage-error ledger. #5451 already made each gate row a devops ci command, so this item keeps only the ci list and ci --list hints and changes no ci help.

Acceptance criteria

Requirement: Hint after a usage error

The root group SHALL print one hint line after Click's usage error when the typed command word or option has a row in the hint table.

Scenario: A by-design name gets a hint

  • WHEN A user runs devops pr merge 1.
  • THEN The process exits 2, prints Click's usage error, and prints one hint line that says only a person merges a pull request.

Requirement: Synonym rows for roadmap

The CLI SHALL name devops roadmap explain <n> or devops roadmap inbox when the typed name is one of roadmap show, list, view, status or get.

Scenario: roadmap show names roadmap explain

  • WHEN A user runs devops roadmap show 1.
  • THEN The hint line names devops roadmap explain <n>.

Requirement: Synonym rows for pr

The CLI SHALL name devops pr view <n> when the typed name is pr show or pr info.

Scenario: pr show names pr view

  • WHEN A user runs devops pr show 1.
  • THEN The hint line names devops pr view <n>.

Requirement: Other-tool row

The CLI SHALL name the other tool's command and the devops command that does the same work when the reason of a row is other_tool.

Scenario: openspec validate names both commands

  • WHEN A user runs devops openspec validate.
  • THEN The hint line names openspec validate and devops openspec check.

Requirement: Cross-group lookup

The CLI SHALL print Did you mean: <path> when the typed command word exactly matches a command in another group, or matches it after a split at - or _.

Scenario: ai cost-report resolves to ai cost report

  • WHEN A user runs devops ai cost-report.
  • THEN The hint line prints Did you mean: devops ai cost report.

Requirement: Whole-word match only

The CLI MUST print no cross-group hint when the typed word is only part of a command name.

Scenario: A prefix gets no computed hint

  • WHEN A user runs a command word that is a prefix of a real command name and matches no whole word.
  • THEN The output holds Click's error and no Did you mean line from the cross-group lookup.

Requirement: No help flag in possible options

The CLI MUST leave --help and -h out of the Possible options list of an unknown option error.

Scenario: An unknown option error hides the help flags

  • WHEN A user runs a command with an unknown option.
  • THEN The Possible options list holds no --help and no -h.

Requirement: Short option list

The CLI SHALL print every option of the command on the error line when an unknown option has no close match and the command has 6 options or fewer.

Scenario: gh issue view lists its options

  • WHEN A user runs devops gh issue view 1 --bogus and the command has 6 options or fewer.
  • THEN The error line lists every option of the command, --repo included.

Requirement: Missing option help

The CLI SHALL add the help line of the missing option to a Missing option error.

Scenario: A missing option prints its help

  • WHEN A user runs a command that requires an option and gives none.
  • THEN The error prints the help text of that option.

Requirement: ci list prints the rows

The CLI SHALL print the gate row names in one line when a user types devops ci list or devops ci --list.

Scenario: ci --list names each row

  • WHEN A user runs devops ci --list.
  • THEN The process exits 2 and prints the name of each row of the gate registry in one line.

Requirement: Interim rows for the gh flags

The CLI SHALL name the devops gh api endpoint that returns the same data for --json, --jq, --comments and --search typed on gh issue view|list and gh pr view|list.

Scenario: --json names the gh api endpoint

  • WHEN A user runs devops gh issue view 1 --json number.
  • THEN The hint line names devops gh api repos/{owner}/{repo}/issues/<n>.

Requirement: Interim row for comment

The CLI SHALL name the devops gh api comment command for comment typed in the pr and gh pr groups.

Scenario: pr comment names the gh api command

  • WHEN A user runs devops pr comment 1 --body hi.
  • THEN The hint line names devops gh api repos/{owner}/{repo}/issues/<n>/comments -X POST -F body=@<file>.

Requirement: Hint runs no command

A hint MUST run no command of the CLI and MUST NOT act as an alias.

Scenario: A hinted error runs nothing

  • WHEN A user runs a hinted wrong command.
  • THEN No command of the CLI runs and the process exits 2.

Requirement: Ledger records the hint

The usage-error ledger MUST record hinted: true for an error that got a hint.

Scenario: A hinted error is in the ledger

  • WHEN A hinted usage error occurs.
  • THEN The ledger record for the error holds hinted: true.

Requirement: Hint target resolves

A test MUST fail when a hint names a devops command that does not resolve through core/command_resolver.py.

Scenario: The table test resolves each target

  • WHEN The test suite runs over the hint table.
  • THEN Each hint target that names a devops command resolves, and the test fails on one that does not.

Requirement: No duplicate of Click's suggestion

A test MUST fail when a hint row names the same target that Click already suggests for the typed name.

Scenario: A row that repeats Click's suggestion fails

  • WHEN The test suite runs over the hint table.
  • THEN A row whose Click suggestion target equals the hint target fails, and a row with a different target passes.

Requirement: Spec states the hint line and the hinted field

The command-telemetry spec SHALL state that one hint line follows the error box when the typed name has a hint and that the record holds hinted.

Scenario: The spec holds the hint line and the field

  • WHEN The change adds the hint line and the hinted field.
  • THEN openspec/specs/command-telemetry/spec.md states the hint line after the error box, the exit code 2 and the hinted field, and the openspec row passes.

Requirement: Generated telemetry doc names the hinted field

The pull request SHALL regenerate docs/TELEMETRY.md from the generator text that names the hinted field.

Scenario: The docs check passes

  • WHEN The generator text of the usage-error record names hinted.
  • THEN docs/TELEMETRY.md holds hinted and the docs row of Static Analysis passes.

Existing Tool Considered

No open, maintained tool covers the need. Typer 0.28 and Click 8.5.1 already print difflib near-miss suggestions and Possible options, but they have no hint table, cross-group word lookup, gate-row rule or control of the option list. click-didyoumean (MIT, last activity 2024-03-24) only re-adds the difflib subcommand suggestion, and thefuck (MIT, last activity 2022-01-02) corrects a shell line, not a Click usage error. Build the hint table and the group-class hooks: about 6k tokens to build, about 1k tokens each month to keep and fix, about 0.30 USD on the DeepSeek implement path, and 1 day of elapsed time.

Key questions

  • Where does the hint data live?: A YAML table src/devops_cli/core/usage_hints.yaml holds each row with the command path, the typed name, the hint text and the reason (by_design, other_tool or other_name). The package reads it with importlib.resources.files("devops_cli.core"), as it reads its other data files, and a computed lookup runs beside the table. (best practice) [sources: src/devops_cli/roadmap/duplicate_eval.py:42, pyproject.toml:22]
    • Chosen: YAML table plus a computed lookup. The table names hints that no lookup finds, such as another tool's command or a by-design rule. The lookup covers names that the table does not list.
    • Rejected: Computed lookup only. It cannot name openspec validate or state a by-design reason.
    • Rejected: One hand row for each name. The set grows with each command and each MCP tool name, so the table goes stale.
  • Which hint does devops pr merge give?: A by_design hint. Only a person merges a pull request, so the agent opens the pull request and asks a person to merge it. (best practice) [sources: AGENTS.md:21]
    • Chosen: by_design hint. AGENTS.md gives the merge to a person only, so no such command will come.
    • Rejected: alias to devops pr ready. Readiness is not a merge, and a hint is not an alias.
    • Rejected: add a pr merge command. AGENTS.md forbids an agent merge, so the command would break the rule.
  • How does the CLI find a command in another group?: It walks the command tree for an exact match of the typed word, or of the word split at - or _, and prints Did you mean: <path>. Only whole-word matches count. (best practice) [sources: src/devops_cli/core/command_resolver.py:95]
    • Chosen: whole-word tree lookup. It finds ai cost report for cost-report with no wrong hint.
    • Rejected: difflib near-miss. Click already runs it and gave lint for ci list, a command with another effect.
    • Rejected: hand rows for other paths. It misses each new command and each MCP tool name.
  • What does the item do with Click's own suggestions?: It keeps them and filters them. It removes --help and -h from the Possible options list, prints the full option list when an unknown option has no close match and the command has 6 options or fewer, and adds the help line of a missing option. A hint row whose target equals Click's suggestion is refused, and a row whose target differs stays, so ci list keeps its row even though difflib suggests lint. (best practice) [sources: src/devops_cli/telemetry/usage_errors.py:181, docs/TELEMETRY.md:238, tests/telemetry/snapshots/test_usage_errors.ambr:9]
    • Chosen: keep and filter Click's suggestions. Only 420 of 1,258 errors showed a line, and the small groups have few options to list.
    • Rejected: replace Click's suggestion machinery. It works for most names, and a replacement adds risk for no gain.
    • Rejected: drop Click's suggestions. The suggestion names the new command after a rename, and the ledger records it.
  • Does this item keep the ci <row> rule?: No. feat(ci): each check row is a devops ci command #5451 is merged: CHECK_ROW_NAMES holds every row and _register_row_commands registers one devops ci <row> command for each row that has no hand-written command, so a typed row name works. This item keeps only the ci list and ci --list hints. [sources: src/devops_cli/commands/ci.py:120, src/devops_cli/commands/ci.py:2983, src/devops_cli/commands/ci.py:1685]
  • Does the item add the gate row names to the devops ci --only help?: No. feat(ci): each check row is a devops ci command #5451 already sets the help from CHECK_ROW_NAMES, so docs/commands/ci.md and docs/MCP_TOOLS.md hold every row. This item changes no help text and regenerates no CLI reference for it. [sources: src/devops_cli/commands/ci.py:1685, docs/commands/ci.md:17, docs/MCP_TOOLS.md:693]
  • Which command does the MCP tool ai_cost_report map to?: devops ai cost report. [sources: docs/commands/ai.md:2063, src/devops_cli/commands/ai_cost.py:495]
  • Which command does a gh flag hint name?: The devops gh api endpoint that returns the same data. devops gh api forwards -X, -f and -F to gh through allow_extra_args, so the comment hint devops gh api repos/{owner}/{repo}/issues/<n>/comments -X POST -F body=@<file> is a real command. [sources: src/devops_cli/commands/gh.py:1443, src/devops_cli/commands/gh.py:1506, src/devops_cli/github/request_classifier.py:188]
  • Which open, maintained tool covers the need?: None. Typer 0.28 and Click 8.5.1 already print difflib near-miss suggestions and Possible options, but they have no hint table, cross-group word lookup, gate-row rule or control of the option list. click-didyoumean (MIT, last activity 2024-03-24) only re-adds the difflib subcommand suggestion, and thefuck (MIT, last activity 2022-01-02) corrects a shell line, not a Click usage error. The hint table and the group-class hooks are built for about 6k tokens, about 1k tokens each month to keep and fix, about 0.30 USD on the DeepSeek implement path, and 1 day of elapsed time. (best practice) [sources: pyproject.toml:12, pyproject.toml:13]
    • Rejected: click-didyoumean. It has no table, no cross-group lookup, no gate-row rule and no option control.
    • Rejected: thefuck. It runs in the shell and last changed on 2022-01-02.
    • Chosen: build the table and the group hooks. No tool covers the need. Cost: about 6k tokens and 1 day.
  • Does the item add a hint for gh status?: No. devops gh status is already a command that prints GitHub's operational status, and feat(gh): gh status, label list and secret list run gh #5228 will make it a pass-through to gh status; a hint to Statuspage health would name a different meaning. A hint is only for an unknown name. (best practice) [sources: docs/commands/gh.md:52, docs/CLI_REFERENCE.md:346]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/cli
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/cli. The (cli) scope of the title gives the scope.
    • Priority: P2-Medium. It reduces 186 recorded failed attempts but does not block any workflow.
    • Value: Medium. It saves agent and human time by pointing to the correct command after a wrong one is typed.
    • Effort: Low. The body states about 100 lines plus a data table, roughly 1 day of work.
    • Related: fix(ai): the knowledge base names only commands, options and components that exist #920, which asks for a different change. Both ensure correct command names reach the user, but #920 fixes the knowledge base text while this adds a new hint line to CLI error output.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Re-scope (owner direction of 2026-11-12). The title stays.

    New scope

    This item can start now. Its one dependency, #4839, is closed. It does not wait for the pass-through items of tracker #4833: 149 of its 192 failures in the study are hints that no other item changes (pr merge 53, roadmap show|list|view|status|get 49, ci <row> 25, pr show|info 14, ai cost-report 8).

    Changes to the hint table:

    No ci list command comes with this item: 3 errors in 7 days is below the proposal threshold of #4840 (5 errors on 3 days).

    Acceptance Criteria (changes)

    • devops ci --list and devops ci list exit 2 and print the gate row names in one line.
    • devops ci --help lists the row names under --only.
    • The test that resolves each hint target through core/command_resolver.py passes.

    Dependencies

    None. Start now. It changes the help of devops ci --only in the generated command reference, so it is the first pull request of the one-at-a-time list of #4833.

  6. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    New evidence of 2026-11-13 (review of failing CLI calls), and five scope points. This item comes before the interim hints that #4855 and #5227 need.

    Counts

    • Local usage-error ledger, 28 hours to 2026-11-13: only 10 of 341 rows had a Click suggestion, and some of them were wrong: --head gave --help 3 times, ci list gave lint.
    • Claude Code transcripts, 2026-10-16 to 2026-11-13: only 420 of 1,258 usage errors showed a "Did you mean" or "Possible options" line. 447 of 1,258 had a help request in the next 3 calls.
    • Words that exist under another path: benchmark (ai benchmark) 2, ai mcp (mcp), roadmap step implement (roadmap implement).
    • MCP tool names typed as CLI paths: ai cost-report 9, ai ast-graph, version 2 (28 errors, 8 sessions).
    • Synonyms: roadmap show 23, roadmap view 5, roadmap issue 3, roadmap list 2, pr show 10, pr status 3, pr info 2 (48 errors, 40 sessions, mostly once per session).

    Scope points

    1. Computed cross-group lookup. On an unknown command, walk the command tree for an exact match of the word, or of the word split at - or _ (cost-report to ai cost report), and print Did you mean: devops ai benchmark?. Only whole-word matches, so no wrong hint. This replaces most hand rows for other paths and MCP names.
    2. No --help or -h in "Possible options". Remove them from Click's list.
    3. Short option list. When an unknown option has no close match and the command has 6 options or fewer, print the full option list on the error line. For example, gh issue view has only --repo.
    4. Missing option help. A Missing option error adds the help line of that option.
    5. Interim rows for the pass-through items:

    Change of one rule: the ci <row> row moves to #5451, which makes each check row a devops ci command. Then a typed row name works, and no hint is necessary. The ci list and ci --list rows stay here.

    Measure: the share of unknown_command records with a correct hint goes up (the suggestion field of the ledger). Repeats of the same wrong word in one session go to 0. Wrong --help hints go to 0.

  7. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches found only difflib-based did-you-mean helpers for Click, chiefly click-didyoumean (a DYMGroup that adds near-miss subcommand suggestions with a cutoff and max_suggestions), which is exactly the suggestion Click already prints and which the issue puts out of scope. No tool provides a data-driven hint table with hint text and reasons, a cross-group word lookup (cost-report → ai cost report), a gate-row rule, or control over option suggestions, so the hint table and root group class have to be built.

    Tool: none found

    Lacks:

    • click-didyoumean only re-adds difflib near-miss suggestions for subcommand names, which Click already prints and the issue excludes from the hint table
    • no table of typed name -> hint text with a reason (by_design, other_tool, other_name)
    • no cross-group or word-split lookup, so ai cost-report, ai ast-graph or version cannot resolve to their real paths
    • no rule that turns a gate row name typed as devops ci <row> into the --only form from the gate registry
    • no hint that names another tool's command (openspec validate) or a synonym (pr show -> pr view)
    • no handling of Click's option suggestions, such as dropping --help/-h or printing the short option list on an unknown option
    • no exit-code-2 hint line after Click's error and no hinted field in the usage-error ledger

    Tools considered:

    Searches run:

    • python click "did you mean" command suggestion library, results: 5
    • click-didyoumean pypi, results: 5
    • typer unknown command suggestion custom hint error message plugin, results: 5
    • click-didyoumean github click-contrib, results: 5
    • "click" plugin suggest similar command "did you mean" pypi package fuzzy match command name, results: 5
    • thefuck command line correction tool github, results: 5
    • python library suggest correct command name typo CLI argparse difflib maintained, results: 5
    • click-didyoumean, results: 5
    • click extension custom unknown command error hint table yaml command path, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  8. added
    status/ready
    and removed
    status/new
    on Nov 15, 2026
  9. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at ca62d6a (see proposed design in issue body).

  10. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 25, 2026
  11. removed
    status/in-review
    owner/agent
    on Nov 25, 2026
  12. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 06:00 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/clisource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions