pr
Pull request operations using GitHub CLI. Trigger when user wants to list PRs ("show open PRs"), view PR details ("view PR 123"), create PRs ("create a pull request"), review/merge PRs ("merge PR", "approve PR"), or view PR diffs ("show PR diff", "what files changed in PR").
When & Why to Use This Skill
This Claude skill enables seamless management of GitHub Pull Requests (PRs) using the GitHub CLI (gh). It streamlines the software development lifecycle by allowing users to list, view, create, review, and merge pull requests directly through natural language commands. By providing instant access to PR diffs and file changes, it enhances developer productivity and accelerates the code review process within a unified workflow.
Use Cases
- 1. Streamlined Code Reviews: Quickly list open pull requests and inspect detailed diffs to provide feedback or approvals without leaving the terminal or chat interface.
- 2. Automated PR Creation: Efficiently initiate new pull requests from local branches with automated title and body population based on commit history.
- 3. Lifecycle Management: Manage the end-to-end PR process, including status tracking, label management, and merging using various strategies like squash or rebase.
- 4. Change Impact Analysis: Deep-dive into specific file modifications within a PR to verify implementation details and ensure code quality standards are met.
| name | pr |
|---|---|
| description | Pull request operations using GitHub CLI. Trigger when user wants to list PRs ("show open PRs"), view PR details ("view PR 123"), create PRs ("create a pull request"), review/merge PRs ("merge PR", "approve PR"), or view PR diffs ("show PR diff", "what files changed in PR"). |
Pull Request Operations
Manage pull requests with the gh CLI.
Prerequisites
GitHub CLI must be installed and authenticated:
gh auth status
Quick Reference
gh pr list # List open PRs
gh pr view 123 # View PR details
gh pr create --fill # Create PR from commits
gh pr merge 123 --squash # Merge PR
gh pr diff 123 # View diff
List PRs
gh pr list --state open
gh pr list --author @me
gh pr list --label "needs-review"
View PR Details
gh pr view 123
gh pr view 123 --json title,body,state,files
Create PR
gh pr create --title "Feature" --body "Description"
gh pr create --fill # Use commit messages
Review and Merge
gh pr review 123 --approve
gh pr review 123 --approve --body "LGTM"
gh pr merge 123 --squash
gh pr merge 123 --merge
View PR Diff
gh pr diff 123
gh pr diff 123 -- path/to/file.go # Specific file
Helper Script: View PR Files
List or view files changed in a PR:
# List changed files
python3 scripts/view_pr_files.py 123 --list
python3 scripts/view_pr_files.py https://github.com/user/repo/pull/123 --list
# View full diff
python3 scripts/view_pr_files.py 123 --diff
# View specific file content from PR branch
python3 scripts/view_pr_files.py 123 --file path/to/file.go
Fallback (if script fails)
# List changed files
gh pr view 123 --json files --jq '.files[].path'
# View diff
gh pr diff 123
# Get file content from PR branch
gh pr view 123 --json headRefName --jq '.headRefName'
gh api repos/{owner}/{repo}/contents/{path}?ref={head_ref} --jq '.content' | base64 --decode