gh-pr
Create a GitHub Pull Request for the current branch with labels and reviewer assignment
Create or manage a GitHub Pull Request for the current branch:
-
Check for existing PR:
gh pr view --json url,number 2>/dev/null- If a PR already exists, skip to step 3 (labels) and mention the existing PR URL
-
Create the PR (if no existing PR):
- Ask if the user wants to create a GitHub Pull Request
- If yes:
- Check if the branch has been pushed (if not, push it first with
git push -u origin <branch>) - Determine the base branch:
git remote show origin | grep 'HEAD branch' - Analyze all commits on this branch vs the base branch to generate a PR title and description
- Write the PR description as a concise paragraph explaining the change (not bullet points)
- Title and voice: Read and follow the guidelines in
skills/commit-msg/SKILL.mdfor the PR title and writing voice - Do not include a test plan section in the PR description
- Create the PR:
gh pr create --title "<title>" --body "<description>" - Present the PR URL to the user
- Check if the branch has been pushed (if not, push it first with
-
Suggest and apply labels:
- Get available labels from the repository:
gh label list --json name,description --limit 100 - Get labels currently on the PR:
gh pr view <pr-number> --json labels --jq '.labels[].name' - Analyze the changes and select 3-4 most relevant labels to suggest based on:
- Type of change (bug fix → "bug", new feature → "enhancement", etc.)
- Files modified (e.g., package.json → "dependencies", .github/ → "github_actions")
- Components affected (e.g., API changes → "manifest", UI changes → "ui/ux")
- Use AskUserQuestion with multiSelect: true showing:
- The 3-4 suggested labels as options (pre-analyze which are most relevant)
- User can select "Other" to type additional label names
- If PR already has labels, mention them in the question text
- Apply selected labels:
gh pr edit <pr-number> --add-label "label1,label2"
- Get available labels from the repository:
-
Request a review:
- Get top contributors to the repository (excluding current user):
gh api repos/{owner}/{repo}/contributors --jq '.[].login' | head -10 - Get the current GitHub username:
gh api user --jq '.login' - Filter out the current user from the contributors list
- Present the top contributors using AskUserQuestion and ask who should review the PR
- Include a "Skip - don't request review" option
- If user selects a reviewer:
gh pr edit <pr-number> --add-reviewer "<username>"
- Get top contributors to the repository (excluding current user):