Open
Description
Describe the feature or problem you'd like to solve
Currently, gh pr close
requires explicitly specifying a PR number or URL.
As commands like gh pr create
allow user to do operation without explicitly specifying the pr number, gh pr close
without pr number to close pr associated with current branch should be allowed.
When working on a feature branch, developers often know they want to close "their" PR (the one associated with the current branch) but need to look up the PR number first.
# Current required usage
$ gh pr close 123
$ gh pr close https://github.com/owner/repo/pull/123
# What happens without arguments
$ gh pr close
cannot close pull request: number, url, or branch required
Usage: gh pr close {<number> | <url> | <branch>} [flags]
Flags:
-c, --comment string Leave a closing comment
-d, --delete-branch Delete the local and remote branch after close
This is inconsistent with other PR commands that can operate on the current branch's PR automatically.
Proposed solution
Allow gh pr close
to work without arguments by automatically detecting and closing the PR associated with the current branch:
$ gh pr close
✓ Closed pull request #123 (feature/new-login-flow)
Benefits:
- Improved developer experience: Eliminates the friction of looking up PR numbers
- Consistency: Aligns with existing commands like
gh pr ready
,gh pr draft
, andgh pr merge
that already support this pattern - Reduced context switching: Developers can stay in their terminal workflow without needing to check the web UI or run additional commands
- Fewer errors: Reduces mistakes from manually typing wrong PR numbers