Skip to content

feat: improve --help output for AI agents and humans#1080

Open
patrikbraborec wants to merge 5 commits intomasterfrom
fix/help-output-ai-agents
Open

feat: improve --help output for AI agents and humans#1080
patrikbraborec wants to merge 5 commits intomasterfrom
fix/help-output-ai-agents

Conversation

@patrikbraborec
Copy link
Copy Markdown
Contributor

@patrikbraborec patrikbraborec commented Apr 14, 2026

Summary

  • Enhances --help output across all CLI commands with structured metadata (descriptions, examples, flags, environment variables) that is useful for both human users and AI agents
  • Adds interactiveNote, docsUrl, examples, and aiNote static properties to commands for richer help text
  • Refactors the help rendering system (_BaseCommandRenderer, CommandHelp, CommandWithSubcommands) to support the new structured output format
  • Renders example descriptions as shell-style # comments (matches the gh CLI convention) in both per-command EXAMPLES and the main help menu, so each example is a self-contained copy-paste block
  • Updates the main-help apify create example to its interactive form with a #-commented description, instead of the misleading apify create my-actor invocation
  • Fixes lint and format issues (object destructuring, line length)

Test plan

  • yarn lint passes
  • yarn format passes (only untracked .claude/settings.local.json fails, not part of the project)
  • yarn build succeeds
  • Verified apify <cmd> --help renders example descriptions as # comments
  • Verified apify help main menu shows the commented apify create example

Closes #1060

🤖 Generated with Claude Code

patrikbraborec and others added 2 commits April 13, 2026 16:15
Extends the command framework with examples, docsUrl, interactive, and
group metadata, reworks the main help menu with category groups, and
adds EXAMPLES + LEARN MORE sections modeled after gh. Also fixes
misleading namespace descriptions, clarifies the 'actor' entrypoint's
relationship to 'apify actor', supports 'help' as a positional arg
equivalent to --help, and normalizes sentence punctuation across all
descriptions.

Refs #1060

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added the t-c&c Team covering store and finance matters. label Apr 14, 2026
@patrikbraborec patrikbraborec added t-dx Issues owned by the DX team. and removed t-c&c Team covering store and finance matters. labels Apr 14, 2026
Per-command EXAMPLES and the main help menu now prefix example descriptions
with "# " (shell-comment style), matching the `gh` CLI convention. Each
example becomes a self-contained copy-paste block, which prevents AI agents
from mistaking description prose for part of the command.

Also updates the main-help `apify create` example to its interactive form
(dropping the stray `my-actor` positional) with a comment explaining the
flow, so users don't copy an invocation that looks incomplete.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@patrikbraborec
Copy link
Copy Markdown
Contributor Author

@TC-MO I added you as optional review, if you want to check the help commands.

@TC-MO
Copy link
Copy Markdown
Contributor

TC-MO commented Apr 15, 2026

Thank you will check in the afternoon

Copy link
Copy Markdown
Contributor

@l2ysho l2ysho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx @patrikbraborec, i found one possible problem, pls take a look

Comment thread src/entrypoints/_shared.ts
patrikbraborec and others added 2 commits April 15, 2026 14:20
The previous help-rewrite logic scanned every positional past index 0 for
the literal word "help", which hijacked commands whose own args happened
to be "help" (e.g. `actor set-value key1 help` or `actor set-value help
value1` would show help instead of writing to the key-value store).

Only treat a positional as a help trigger when it is an actual subcommand
slot: position 1 when the base command has subcommands, and position 2
only when position 1 is a real subcommand and that subcommand takes no
positional args of its own.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements the findings from the staff review of the help output
rework: prefix bare 'actor' example commands with the current
entrypoint so they stay copy-pasteable when viewed under 'apify actor',
render the interactive note on namespace commands, drop the now-unused
mapGroupBy helper, add unit tests for the help renderers, and note the
no-op path of the help-positional rewrite under the actor entrypoint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@l2ysho l2ysho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

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

Labels

t-dx Issues owned by the DX team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix --help for AI agents & humans

4 participants