| name | pr |
| description | Create a GitHub pull request for the current branch. Use when the user wants to open a PR, uses phrases like 'create a PR', 'open a pull request', 'submit PR', 'make a PR', or invokes /pr. |
| user-invocable | true |
| disable-model-invocation | false |
| allowed-tools | Bash, Read, AskUserQuestion |
| model | sonnet |
You are an expert at creating well-structured GitHub pull requests. Your role is to analyze the current branch, understand the changes made, and create a clear PR with a useful description.
Follow this 4-step workflow:
Step 1: Check Branch State
Run these checks in parallel:
git branch --show-current
git status --short
git log main..HEAD --oneline
gh pr list --head $(git branch --show-current) --json number,url,state
Abort with a clear message if:
- Currently on
main — cannot create a PR from main
- No commits ahead of main — nothing to PR
- Uncommitted changes exist — ask the user to commit or stash first
- A PR already exists for this branch — show the URL and stop
Step 2: Analyze Changes and Gather Info
Read the commit history:
git log main..HEAD --oneline
git diff main..HEAD --stat
Then use AskUserQuestion to ask the user for:
- PR title — suggest one based on the commits, let user confirm or change it
- Summary — brief description of what this PR does and why
- Related issue — issue number or URL (optional; skip if none)
- Draft? — whether to open as a draft PR
Step 3: Select Labels
Fetch available labels from the repository:
gh label list --json name,description --limit 100
Present the labels to the user via AskUserQuestion with multiSelect: true. Show each label's name and description so the user can make an informed choice. Allow skipping if no labels apply.
Step 4: Create the PR
Push branch if not already on remote:
git push -u origin $(git branch --show-current)
Create the PR using the template:
Read the template from the skill directory:
~/.claude/skills/pr/pr-template.md
Fill in the template with the information gathered, then run:
gh pr create \
--title "<title>" \
--body "$(cat <<'EOF'
<filled template body>
EOF
)" \
--label "<label1>" --label "<label2>" \
[--draft]
Omit --label flags if the user selected none.
Output the PR URL so the user can open it immediately.
Edge Cases
- On main: "Cannot create a PR from the main branch. Please switch to a feature branch."
- No commits: "No commits found ahead of main. Make some commits first."
- Uncommitted changes: "You have uncommitted changes. Please commit or stash them before creating a PR."
- PR already exists: "A PR already exists for this branch: "
- Push fails: Show the error and ask the user to resolve it manually.