gh-pr-close
npx machina-cli add skill dceoy/github-cli-agent-skills/gh-pr-close --openclawFiles (1)
SKILL.md
1.7 KB
GitHub PR Close
When to use
- The user asks to close a PR without merging.
- PR is abandoned, superseded, or no longer needed.
- Cleaning up stale PRs.
Inputs to confirm
- PR number, URL, or branch name.
- Whether to delete the associated branch.
- Optional closing comment.
- Target repo if not current (
--repo OWNER/REPO).
Workflow
- Verify auth:
gh --version gh auth status - Check PR state first:
gh pr view 123 --json number,title,state,headRefName - Close the PR:
gh pr close 123 gh pr close 123 --comment "Closing: superseded by #456" gh pr close 123 --delete-branch - Verify closure:
gh pr view 123 --json state,closedAt
Examples
# Close PR without comment
gh pr close 123
# Close with explanation
gh pr close 123 --comment "No longer needed after refactoring."
# Close and delete branch
gh pr close 123 --delete-branch --comment "Superseded by #200"
Flags reference
| Flag | Description |
|---|---|
-c, --comment | Leave a closing comment |
-d, --delete-branch | Delete local and remote branch after close |
Notes
- Closed PRs can be reopened with
gh pr reopen. - Use
--delete-branchto clean up feature branches. - Arguments accept number, URL, or branch name.
References
- GitHub CLI manual: https://cli.github.com/manual/
gh pr close --help
Source
git clone https://github.com/dceoy/github-cli-agent-skills/blob/main/skills/gh-pr-close/SKILL.mdView on GitHub Overview
gh-pr-close closes a GitHub pull request without merging using the gh CLI. It supports adding a closing comment, optionally deleting the associated branch, and can target a different repository with --repo when needed.
How This Skill Works
The workflow authenticates with gh, queries the PR state, then issues gh pr close with optional --comment and --delete-branch flags. Finally, it verifies the closure by re-checking the PR state.
When to Use It
- User asks to close a PR without merging
- PR is abandoned, superseded, or no longer needed
- Cleaning up stale PRs
- Delete the associated branch after closing
- Close a PR in a different repo with --repo
Quick Start
- Step 1: Verify authentication with gh --version and gh auth status
- Step 2: Identify the PR to close using PR number, URL, or branch name
- Step 3: Run gh pr close <id> with optional --comment and --delete-branch, then gh pr view to verify
Best Practices
- Confirm you have the correct PR reference (number, URL, or branch) before closing
- Provide a clear --comment for future context
- Use --delete-branch only when it's safe to remove the branch
- Specify --repo if closing a PR outside the current repository
- Verify closure with gh pr view to ensure state is closed
Example Use Cases
- gh pr close 123
- gh pr close 123 --comment No longer needed after refactoring
- gh pr close 123 --delete-branch --comment Superseded by #200
- gh pr close https://github.com/OWNER/REPO/pull/456 --comment Closing after review
- gh pr close 456 --repo otherowner/otherrepo --comment Closing in a forked repo
Frequently Asked Questions
Add this skill to your agents