get-pr-number

Determines pull request number, state, and URL for a Git branch using the GitHub CLI.

8|7|Updated Feb 14, 2023
One-click install
npx skills add https://github.com/eclipse-slm/slm --skill get-pr-number-eclipse-slm
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: get-pr-number
Source: https://github.com/eclipse-slm/slm/tree/main/.agents/skills/get-pr-number
Command: npx skills add https://github.com/eclipse-slm/slm --skill get-pr-number-eclipse-slm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When automating CI checks, code reviews, or changelog updates, you often need to know which pull request corresponds to the current Git branch. Manually looking up PR numbers, handling forks, and dealing with edge cases like detached HEAD states or multiple PRs per branch is error-prone and repetitive. ## Core Features & Use Cases - PR Lookup by Branch: Queries the GitHub CLI (gh pr list) to find the PR number, state, title, and URL associated with any branch. - Fork-Aware Resolution: Integrates with the get-upstream-info skill to query the upstream repository using fork-qualified branch names (e.g., owner:branch), so PRs are found where they actually exist. - Edge-Case Handling: Detects detached HEAD states, warns on protected branches (main, master, devel, stable-*), prefers OPEN PRs when multiple exist, and validates gh CLI availability and authentication. - Use Case: A SonarCloud remediation workflow needs PR-specific issues. Invoke this skill to get PR_NUMBER and PR_URL for the current branch, then fetch only the issues tied to that pull request. ## Quick Start Ask the assistant to find the pull request number and status for the current Git branch using the gh CLI.

Frequently Asked Questions about get-pr-number

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find the pull request number for a Git branch?▼

Run gh pr list with the --head flag set to your branch name and --repo set to the target repository. The JSON output includes the PR number, state, title, and URL, which you can parse with jq.

How to look up a PR in the upstream repository from a fork?▼

Use gh pr list --repo with the upstream owner/repo path and qualify the branch as fork-owner:branch, for example octocat:feature-x. This finds PRs opened from your fork against the upstream repository.

Does gh pr list work in a detached HEAD state?▼

No. In detached HEAD state there is no branch name to query, so the lookup fails. Check out a branch first with git checkout <branch-name> before running the PR query.

What happens when multiple PRs exist for the same branch?▼

The lookup prefers an OPEN pull request when several exist for one branch. If none are open, it falls back to the most recent PR and warns about the other matches.

Why does gh pr list return an empty result for my branch?▼

An empty result means no PR exists for that branch in the queried repository. Verify the branch is pushed to the remote, confirm you are querying the upstream repo rather than your fork, or create a PR with gh pr create.