Create a PR from current branch with unpushed commits. Use when the user wants to open or create a pull request, push and PR a branch, or invokes /prp-pr.
68
83%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Base branch override: $ARGUMENTS
Create a well-formatted pull request from the current branch, using repository PR templates if available, with a clear summary of changes.
Golden Rule: PRs should tell reviewers what changed and why. Use existing templates when available.
Determine the base branch for PR target and diff comparison:
$ARGUMENTS contains a branch name or --base <branch>, use that valuegit symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'git remote show origin 2>/dev/null | grep 'HEAD branch' | awk '{print $NF}'mainStore as {base-branch} — use this value for ALL comparisons, diff commands, and PR creation. Never hardcode main or master.
# Current branch (must not be {base-branch})
git branch --show-current
# Check for uncommitted changes
git status --short
# Verify we have commits to PR
git log origin/{base-branch}..HEAD --onelineDecision Tree:
| State | Action |
|---|---|
| On {base-branch} | STOP: "Cannot create PR from {base-branch}. Create a feature branch first." |
| Uncommitted changes | WARN: "You have uncommitted changes. Commit or stash before creating PR." |
| No commits ahead | STOP: "No commits to create PR from. Branch is up to date with {base-branch}." |
| Has commits, clean | PROCEED |
gh pr list --head $(git branch --show-current) --json number,urlIf PR exists:
PR already exists for this branch: {url}
Use `gh pr view` to see details or `gh pr edit` to modify.PHASE_1_CHECKPOINT:
# Check common template locations
ls -la .github/PULL_REQUEST_TEMPLATE.md 2>/dev/null
ls -la .github/pull_request_template.md 2>/dev/null
ls -la .github/PULL_REQUEST_TEMPLATE/ 2>/dev/null
ls -la docs/pull_request_template.md 2>/dev/nullIf template found:
If no template:
# Get commit messages for PR body
git log origin/{base-branch}..HEAD --pretty=format:"- %s"
# Get detailed commit info
git log origin/{base-branch}..HEAD --pretty=format:"%h %s%n%b" --no-merges# Files changed
git diff --stat origin/{base-branch}..HEAD
# Get list of changed files
git diff --name-only origin/{base-branch}..HEADFrom commits, derive title:
{type}: {description} (e.g., "feat: Add user authentication")Common prefixes:
| Prefix | Usage |
|---|---|
feat: | New feature |
fix: | Bug fix |
refactor: | Code restructuring |
docs: | Documentation |
test: | Adding tests |
chore: | Maintenance |
PHASE_2_CHECKPOINT:
# Push with upstream tracking
git push -u origin HEADIf push fails:
--force-with-lease if rebased (warn user first)PHASE_3_CHECKPOINT:
Read the template and fill in each section based on:
#123 or Fixes #123 in commits)gh pr create \
--title "{title}" \
--base "{base-branch}" \
--body "$(cat <<'EOF'
## Summary
{1-2 sentence description of what this PR accomplishes}
## Changes
{List of commit summaries}
- {commit 1}
- {commit 2}
## Files Changed
{Count} files changed
<details>
<summary>File list</summary>
{list of changed files}
</details>
## Testing
- [ ] Type check passes
- [ ] Tests pass
- [ ] Manually verified
## Related Issues
{Any linked issues from commit messages, or "None"}
EOF
)"From commit messages, find patterns like:
Fixes #123Closes #123Relates to #123#123Include these in the PR body under "Related Issues".
PHASE_4_CHECKPOINT:
# Get the created PR info
gh pr view --json number,url,title,state# Check PR status
gh pr checksPHASE_5_CHECKPOINT:
## Pull Request Created
**PR**: #{number}
**URL**: {url}
**Title**: {title}
**Base**: {base-branch} <- {current-branch}
### Summary
{Brief description of what the PR contains}
### Changes
- {N} commits
- {M} files changed
### Files
{List of changed files}
### Checks
{Status of any CI checks, or "Pending"}
### Next Steps
- Wait for CI checks to pass
- Request review if needed: `gh pr edit --add-reviewer @username`
- View PR: `gh pr view --web`# Suggest rebasing first
git fetch origin
git rebase origin/{base-branch}
# Then push with lease
git push --force-with-lease<!-- required -->)# If .github/PULL_REQUEST_TEMPLATE/ directory exists
ls .github/PULL_REQUEST_TEMPLATE/gh pr create --draft --title "{title}" --body "{body}"1142738
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.