Skip to content

gh repo delete: warn or error when --yes is ignored without an explicit owner/repo #12033

Description

@Shion1305

Description

The help for gh repo delete says:

For safety, when no repository argument is provided, the --yes flag is ignored and you will be prompted for confirmation. To delete the current repository non-interactively, specify it explicitly (e.g., gh repo delete owner/repo --yes).
Deletion requires authorization with the delete_repo scope. To authorize, run gh auth refresh -s delete_repo.

However, when I run gh repo delete --yes (from inside a repository) there is no warning that --yes is being ignored. This made it hard to understand why the command wasn’t behaving non-interactively.

Steps to Reproduce

  1. cd into any local Git repository that is connected to GitHub.

  2. Run:

    gh repo delete --yes
  3. Observe that the command prompts interactively (as designed) but does not warn that --yes is ignored in this mode.

Actual Behavior

  • --yes is silently ignored when no owner/repo argument is provided.
  • No warning or error is shown, so users may assume --yes should make it non-interactive.

Expected Behavior

  • If --yes is passed without an explicit owner/repo, the CLI should at least warn, or preferably error, explaining why it can’t proceed non-interactively.

Suggested Fixes (any of these would help)

  1. Warn and continue interactively (most conservative):

    • Print to stderr:

      Warning: --yes is ignored when no repository is specified.
      To delete non-interactively, run: gh repo delete OWNER/REPO --yes
      
  2. Error out (clearer for scripts/CI):

    • Exit non-zero with:

      Error: --yes requires an explicit repository argument (OWNER/REPO) for safety.
      
  3. Docs/UI nudge in the prompt:

    • If the prompt appears while --yes was provided, append a one-line note:

      Note: --yes is ignored without an explicit repository. Use: gh repo delete OWNER/REPO --yes
      

Rationale

Silently ignoring a flag is surprising and makes troubleshooting slower. A warning or error would:

  • Align behavior with the help text.
  • Prevent confusion for users expecting non-interactive deletion.
  • Help CI scripts fail fast with a clear message rather than hanging on a prompt.

Activity

  1. BagToad commented on Oct 27, 2025

    @BagToad
    Member

    Hey @Shion1305, thanks for this! ✨

    All good points, and very reasonable solutions 🤔 I'm not sure which option is best but I think I lean towards the option 1 you've presented. I don't think it would hurt to print a message on stderr when --yes is ignored. I think it would make sense to only print this message to stderr when we can't prompt because we have another message that prints when we cannot prompt, see below.

    I also want to note that if we can't prompt, we do currently give an error and exit in this case - so that should cover the transparency in CI case:

    // Ignore --yes when no argument provided to prevent accidental deletion
    if len(args) == 0 && opts.Confirmed {
    if !opts.IO.CanPrompt() {
    return cmdutil.FlagErrorf("cannot non-interactively delete current repository. Please specify a repository or run interactively")
    }
    opts.Confirmed = false
    }

    cc @babakks since we worked on this safety feature together - WDYT?

  2. github-actions commented on Oct 27, 2025

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as a feature request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  3. Shion1305 commented on Oct 28, 2025

    @Shion1305
    ContributorAuthor

    Hey @BagToad, thanks for the positive feedback! I’d love to take this on if you’re okay with it. Could you assign me? I can open a PR this week.

  4. onsni commented on Oct 28, 2025

    @onsni
  5. babakks commented on Oct 28, 2025

    @babakks
    Member

    I agree with @BagToad that we should just print a warning in interactive mode. The other case is already covered with a non-zero exit code and message. I'll put down the A/C in the next comment.

  6. babakks commented on Oct 28, 2025

    @babakks
    Member

    Acceptance Criteria

    Given I'm running gh interactively from a cloned repo directory
    When I run gh repo delete --yes
    Then I see the below warning message on stderr and then the prompt to confirm the repo name:

    Warning: `--yes` is ignored since no repository was specified
    
  7. added and removed on Oct 28, 2025
  8. babakks commented on Oct 28, 2025

    @babakks
    Member

    @Shion1305 I just added help wanted Contributions welcome to this. So, feel free to submit a PR for it.

  9. added a commit that references this issue on Oct 28, 2025
    7083f6d
  10. added a commit that references this issue on Oct 29, 2025
    119085c
  11. added a commit that references this issue on Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementa request to improve CLIgh-reporelating to the gh repo commandhelp wantedContributions welcome

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions