Skip to content

Add user confirmation for write commands#12687

Open
Chaitanya-cpc wants to merge 1 commit intocli:trunkfrom
Chaitanya-cpc:feature/confirm-write-commands
Open

Add user confirmation for write commands#12687
Chaitanya-cpc wants to merge 1 commit intocli:trunkfrom
Chaitanya-cpc:feature/confirm-write-commands

Conversation

@Chaitanya-cpc
Copy link

Closes #12624

Summary

Adds an optional confirmation step for "write" commands so users (especially those using gh with AI agents or automation) can require an extra prompt before creating PRs, issues, or deleting repos.

Changes

  • Config option confirm_write_commands: when set to enabled, the CLI will require confirmation before running selected write commands. Default is disabled so existing behavior is unchanged.
  • Environment variable GH_CONFIRM_WRITE_COMMANDS: overrides the config. Set to enabled to require confirmation, or disabled to skip it (e.g. in non-interactive scripts).
  • Helper cmdutil.RequireWriteConfirmation(f, hostname, actionDescription) used by:
    • gh pr create
    • gh issue create
    • gh repo delete
  • Behavior:
    • If confirmation is enabled and the terminal is interactive: prompt "This will . Continue? (y/n)". Cancel returns CancelError.
    • If confirmation is enabled and not interactive (no TTY): return a clear error suggesting GH_CONFIRM_WRITE_COMMANDS=disabled or gh config set confirm_write_commands disabled.
  • Docs: New option documented in gh config (via config.Options), and GH_CONFIRM_WRITE_COMMANDS added to gh help environment.

Usage

# Enable confirmation (prompt before pr create, issue create, repo delete)
gh config set confirm_write_commands enabled

# Disable for a single non-interactive run
GH_CONFIRM_WRITE_COMMANDS=disabled gh pr create --title "Fix" --body "Done"

Made with Cursor

- Add config option confirm_write_commands (enabled|disabled, default disabled)
- Add GH_CONFIRM_WRITE_COMMANDS env var to override config
- Require confirmation in gh pr create, gh issue create, gh repo delete
  when enabled; clear error when non-interactive
- Document in gh help environment

Closes cli#12624

Co-authored-by: Cursor <[email protected]>
@Chaitanya-cpc Chaitanya-cpc requested a review from a team as a code owner February 14, 2026 19:07
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Feb 14, 2026
@github-actions
Copy link

Thank you for your pull request! 🎉

This PR appears to fix the following issues that are not labeled with help wanted Contributions welcome :

As outlined in our Contributing Guidelines, we expect that PRs are only created for issues that have been labeled help wanted.

While we appreciate your initiative, please note that:

  • PRs for non-help wanted issues may not be reviewed immediately as they might not align with our current priorities
  • The issue might already be assigned to a team member or planned for a specific release
  • We may need to close this PR. For example, if it conflicts with ongoing work or architectural decisions

What happens next:

  • Our team will review this PR and the associated issues
  • We may add the help wanted label to the issues, if appropriate, and review this pull request
  • In some cases, we may need to close the PR. For example, if it doesn't fit our current roadmap

Thank you for your understanding and contribution to the project! 🙏

This comment was automatically generated by cliAutomation.

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

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User confirmation for write commands

2 participants