From an already-pushed branch: open the pull request with body, labels, reviewers and issue refs. Use when the user says \"create PR\", \"open pull request\", or \"submit for review\".
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Git Pr?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/laurigates-git-pr)
---
created: 2026-01-21
modified: 2026-11-13
reviewed: 2026-06-10
name: git-pr
description: "From an already-pushed branch: open the pull request with body, labels, reviewers and issue refs. Use when the user says \"create PR\", \"open pull request\", or \"submit for review\"."
user-invocable: false
allowed-tools: Bash(bash *), Bash(git status *), Bash(git diff *), Bash(git log *), Bash(git branch *), Bash(git remote *), Bash(git push *), Bash(git fetch *), Bash(git rev-list *), Bash(gh pr *), Bash(gh issue *), Bash(gh repo *), Read, Grep, Glob, TodoWrite
---
# Git PR
Create pull requests with comprehensive descriptions and proper issue linkage.
## When to Use This Skill
| Use this skill when... | Use the alternative when... |
|---|---|
| Opening a PR from a pushed branch with description, labels, and issue refs | Use `github-pr-title` if you only need to author or fix the conventional title |
| Selecting a base branch, draft mode, or reviewers as part of PR creation | Use `git-push` first if the branch has not been pushed to remote yet |
| Going from a pushed branch to an open pull request | Use `git-commit` first if there are uncommitted changes locally |
| Inserting `Fixes #N` / `Closes #N` issue references into the PR body | Use `git-commit-push-pr` for the consolidated commit + push + PR macro |
## Workflow
> **Before creating the PR**, check whether any post-merge follow-up actions are needed (migrations, deployments, config changes, runbook updates). Create a GitHub issue for each and link them in the PR description. See [REFERENCE.md](REFERENCE.md) § Post-Merge Follow-up Issues.
### 1. Assess PR Readiness
Run the data-gathering script. It fetches the base ref, computes the ahead-count
against `origin/main`, probes for an existing PR (via the `state` field — never
`merged`), scans for stacked dependents, and audits closing keywords:
```bash
bash "${CLAUDE_SKILL_DIR}/scripts/git-pr.sh" --home-dir "$HOME" --base origin/main
```
Parse `STATUS=` and `ISSUES:` from the output. Read `PR_READY` (false when
`AHEAD_COUNT=0` — nothing to PR), `EXISTING_PR` (a number means `gh pr view` /
`gh pr edit` instead of creating), `CURRENT_BRANCH`, `STACK_PARENT` /
`DEPENDENT_PR=<n>` (see [REFERENCE.md](REFERENCE.md) § Stacked PRs), and `BODY_NOT_AUTOCLOSING` (see
Step 5). Authoring the PR body remains your job.
### 2. Analyze Commits
**CRITICAL:** Always compare against `origin/main` (not local `main`) to avoid including commits that haven't been merged to the remote. Local `main` may be ahead of `origin/main` with unrelated commits.
```bash
# Fetch latest remote state
git fetch origin main
# Always use origin/main as base reference
base_ref="origin/main"
git log $base_ref..HEAD --format='%H %s'
# Extract issue references
git log $base_ref..HEAD --format='%B' | grep -oE '#[0-9]+' | sort -u
# Get diff stats
git diff $base_ref...HEAD --stat
```
### 3. Identify Post-Merge Follow-ups and Create Issues
Before creating the PR, scan for any actions required **after** the PR is merged (deployments, migrations, config changes, external docs). For each:
Example `gh issue create` call: [REFERENCE.md](REFERENCE.md#follow-up-issue-example-step-3).
Keep a list of created issue numbers to link in the PR body.
### 4. Create PR
Write the PR body to a tempfile with the `Write` tool, then pass it via `--body-file`. This sidesteps shell quoting entirely — backticks, code fences, and shell metacharacters are preserved byte-for-byte. See the **Body content** rule in `github-issue-writing` for the canonical guidance and the threshold for when bare `--body "..."` is still acceptable.
```bash
# 1) Write tool → /tmp/pr-body.md (no shell escaping involved)
# 2) gh pr create --body-file
gh pr create \
--title "feat(scope): add feature" \
--body-file /tmp/pr-body.md
```
For a short body, `--body-file -` with a quoted heredoc also works: [REFERENCE.md](REFERENCE.md#short-bodies-over-stdin-step-4).
Body content of `/tmp/pr-body.md` — the squash body follows the repo's
`squash_merge_commit_message`: `COMMIT_MESSAGES` uses the branch commits' messages and `PR_BODY` the PR body; read it with `gh api repos/{owner}/{repo} --jq .squash_merge_commit_message` rather than assuming. On a `PR_BODY` repo a
squash-merged PR's body **is the commit body on `main`** and release-please
parses it. Rebase is the default merge method, but
single-commit and fixup-carrying PRs squash, so write every body as a commit
message: prose first, footers last, no checklists, headings or reviewer-only
notes. Method rule and body lint: `github-pr-title` →
[merge-strategies.md](../github-pr-title/merge-strategies.md).
```markdown
Add retry with backoff to the webhook dispatcher so transient 5xx
responses from receivers no longer drop events.
- Retry up to 5 times with jittered exponential backoff
- Record final failures in the dead-letter table
Follow-up: #456 (run migration after deploy), #457 (prod config)
Fixes #123
Refs #456
```
Rules for the footer paragraph (last block, one per line, no blank lines):
| Line | Effect under squash |
|------|---------------------|
| `Fixes #N` / `Closes #N` | Closes issue on merge |
| `Refs #N` | Link only |
| `BREAKING CHANGE: <what breaks>` | **Major** bump — only when intended |
| `Release-As: X.Y.Z` | Forces version |
Never start a line with `feat(…):` / `fix(…):` in the footer block unless you
mean an additional changelog entry. Reviewer instructions (test steps,
screenshots) go in a PR comment, not the body.
### 5. Verify Closing Keywords
After the PR is created, audit the body: every issue referenced by number must
have a matching `Fixes` / `Closes` / `Resolves` keyword. Issues mentioned only
in a markdown table or prose will not auto-close on merge.
Re-run the data-gathering script against the just-created PR's body (write it to
a tempfile first, or pass the fetched body) — it emits `BODY_REFERENCED`,
`BODY_CLOSING`, and `BODY_NOT_AUTOCLOSING`:
```bash
gh pr view --json body --jq .body > /tmp/pr-body-check.md
bash "${CLAUDE_SKILL_DIR}/scripts/git-pr.sh" --home-dir "$HOME" --body-file /tmp/pr-body-check.md
```
If `BODY_NOT_AUTOCLOSING` is non-empty, edit the PR body with `gh pr edit <num> --body-file ...`
to add `Fixes #N` / `Closes #N` lines for any issue this PR is meant to close.
`Related: #N` is correct for issues the PR references but does not close —
those should not appear in the warning if you re-run the check.
## PR Title Format
Use conventional commit format (`github-pr-title`):
```
<type>(<scope>): <subject>
```
**The scope is required.** Write `type(scope): …` — `docs(readme): update install steps`, never a bare `docs: update install steps`. The Conventional Commits spec lets you omit the scope; this house convention does not (`.claude/rules/conventional-commits.md`). Take it from the component or plugin the change touches.
Examples:
- `feat(auth): add OAuth2 support`
- `fix(api): handle null response`
## PR Options
| Option | Command |
|--------|---------|
| Draft | `gh pr create --draft` — requires a [`## Draft status`](#draft-status) section |
| Labels | `gh pr create --label "enhancement"` |
| Reviewers | `gh pr create --reviewer user1,user2` |
| Base branch | `gh pr create --base develop` |
| Assignee | `gh pr create --assignee @me` |
## Draft status
A PR opened with `--draft` ends its body with a `## Draft status` section: what
is incomplete, and the exact condition for `gh pr ready`. A draft without one
gives nobody a reason to mark it ready, and an automated PR sweep surfaces it
instead of readying it. Run `gh pr ready` yourself once the work is complete.
How to record a blocking PR (same repo or another repo): [REFERENCE.md](REFERENCE.md#draft-status-dependencies).
## Pre-merge Verification
Pre-merge checks and post-merge steps stay out of the PR body: [REFERENCE.md](REFERENCE.md#pre-merge-verification).
## Output
On success, report:
```
Created PR #42: feat(auth): add OAuth2 support
URL: https://github.com/org/repo/pull/42
Related Issues:
Fixes #123
Refs #456
Status: Open
```
## Error Handling
| Error | Solution |
|-------|----------|
| Branch not pushed | Push first or use main-branch pattern |
| PR exists | `gh pr view` or `gh pr edit` |
| No commits | Commit changes first |
## Quick Reference
Full `gh pr` command table (view, edit, list, stacked-PR merge, follow-up issues): [REFERENCE.md](REFERENCE.md#quick-reference).
## Agentic Optimizations
| Context | Command |
|---------|---------|
| PR readiness | `gh pr view --json number,state 2>/dev/null` |
| Commits | `git log origin/main..HEAD --format='%s'` |
| Issue refs | `git log origin/main..HEAD --format='%B' \| grep -oE '#[0-9]+'` |
| Verify auto-close | `gh pr view <num> --json body --jq .body \| grep -oiE '(closes\|fixes\|resolves)[[:space:]]+#[0-9]+'` |
| Stacked-PR safety check | `gh pr list --base <head> --state open --json number,title,headRefName` |
| Create follow-up issue | `gh issue create --title "[Chore] ..." --body-file /tmp/follow-up.md` |
| Create PR | `gh pr create --title "..." --body-file /tmp/pr-body.md` |
For the full PR description template, main-branch push pattern, stacked-PR merge rules, and the post-merge follow-up issue workflow, see [REFERENCE.md](REFERENCE.md).