Skip to content

Enforce bare-group-shows-help convention#271

Merged
jeremy merged 3 commits intomainfrom
bare-group-convention
Mar 11, 2026
Merged

Enforce bare-group-shows-help convention#271
jeremy merged 3 commits intomainfrom
bare-group-convention

Conversation

@jeremy
Copy link
Copy Markdown
Member

@jeremy jeremy commented Mar 11, 2026

Summary

Command groups (resource nouns with subcommands like todos, projects, todosets) should show help when invoked bare — not run a default action. This was an unwritten convention that #270 nearly violated. Now it's codified three ways:

  • Style guide: STYLE.md documents the rule and the shortcut exception
  • CI check: scripts/check-bare-groups.sh scans Go source for NewXxxCmd functions with both RunE and AddCommand, failing unless the function is in an explicit allowlist of intentional shortcuts (card, search, url, etc.)
  • E2e coverage: added "without subcommand shows help" tests for 8 command groups that were missing them

Also removes redundant RunE: cmd.Help() from boost, mcp, and tools — Cobra already shows help by default when a parent command has subcommands.

Test plan

  • bin/ci passes — new check-bare-groups target runs green
  • All 8 new e2e bare-help tests pass
  • Verified the check catches violations (tested by temporarily adding RunE to a group command)

Summary by cubic

Enforces that bare command groups show help instead of running an action. Adds a CI check, updates the style guide, expands e2e coverage, removes redundant handlers, and acknowledges the mcp CLI surface change.

  • New Features

    • Documented the rule in STYLE.md with an allowlist for shortcut commands (card, search, url, etc.).
    • Added scripts/check-bare-groups.sh and wired it into make check as check-bare-groups to block RunE + AddCommand on group parents.
    • Added “without subcommand shows help” e2e tests for auth, boost, campfire, files, messagetypes, subscriptions, templates, and webhooks.
  • Refactors

    • Removed redundant RunE: cmd.Help() from boost, mcp, and tools (rely on Cobra’s default help).
    • Added .surface-breaking entries for mcp to acknowledge the CLI surface change from removing RunE.

Written for commit fc22351. Summary will update on new commits.

Command groups (resource nouns with subcommands) must not set RunE —
bare invocation shows help via Cobra's default behavior. A new
scripts/check-bare-groups.sh validates this at CI time, with an
allowlist for intentional shortcuts (card, search, url, etc.).

Wired into `make check` as `check-bare-groups`.
@jeremy jeremy requested a review from a team as a code owner March 11, 2026 21:48
Copilot AI review requested due to automatic review settings March 11, 2026 21:49
@github-actions github-actions bot added commands CLI command implementations tests Tests (unit and e2e) docs enhancement New feature or request labels Mar 11, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 14 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/check-bare-groups.sh">

<violation number="1" location="scripts/check-bare-groups.sh:43">
P1: Non-portable BRE alternation (`\|`) silently breaks the check on macOS. BSD grep doesn't support `\|` in basic regex, so the pattern matches nothing and the script always passes — defeating its purpose for developers running `bin/ci` locally on macOS. Use `-Ec` with `|` instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Remove `RunE: cmd.Help()` from boost, mcp, and tools — Cobra shows
help by default when a parent command has subcommands and no RunE.

Add "without subcommand shows help" e2e tests for 8 command groups
that were missing coverage: auth, boost, campfire, files,
messagetypes, subscriptions, templates, webhooks.
@jeremy jeremy force-pushed the bare-group-convention branch from d85a3f9 to 888e775 Compare March 11, 2026 21:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Codifies the CLI convention that “group” commands (resource nouns with subcommands) should show help when invoked without a subcommand, rather than running a default action.

Changes:

  • Document the bare-group-shows-help rule (and shortcut exceptions) in STYLE.md.
  • Add a CI-enforced checker script and wire it into the make check pipeline.
  • Add e2e tests ensuring bare invocation shows help for several command groups; remove redundant RunE: cmd.Help() from a few commands.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/check-bare-groups.sh Adds a CI check to detect New*Cmd constructors that set both RunE and AddCommand unless allowlisted.
internal/commands/tools.go Removes redundant parent RunE that only printed help.
internal/commands/mcp.go Removes redundant parent RunE that only printed help.
internal/commands/boost.go Removes redundant parent RunE (and no-op Args) so bare invocation relies on Cobra help behavior.
e2e/webhooks.bats Adds “without subcommand shows help” coverage.
e2e/templates.bats Adds “without subcommand shows help” coverage.
e2e/subscriptions.bats Adds “without subcommand shows help” coverage.
e2e/messagetypes.bats Adds “without subcommand shows help” coverage.
e2e/files.bats Adds “without subcommand shows help” coverage.
e2e/campfire.bats Adds “without subcommand shows help” coverage.
e2e/boost.bats Adds “without subcommand shows help” coverage.
e2e/auth.bats Adds “without subcommand shows help” coverage.
STYLE.md Documents the bare-group-shows-help convention and the shortcut exception.
Makefile Adds check-bare-groups target and includes it in check.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The mcp command lost its RunE (intentionally — bare groups show help
via Cobra default), which removes CMD/FLAG/SUB entries from the CLI
surface snapshot. Add these to .surface-breaking so the check passes.
@jeremy jeremy merged commit 97efd99 into main Mar 11, 2026
26 checks passed
@jeremy jeremy deleted the bare-group-convention branch March 11, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands CLI command implementations docs enhancement New feature or request tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants