| name | git:pr |
| description | This skill should be used when the user asks to "create a pull request", "make a PR", "open a pull request", "create PR", "submit for review", or mentions creating a GitHub/GitLab pull request or merge request. Enhances PR creation with fork detection and template discovery. |
Git Pull Request Creation
Enhance pull request creation with automatic fork detection, PR template discovery, and proper base branch targeting.
Quick Reference
Workflow:
- ✓ Check uncommitted changes (commit if needed)
- ✓ Verify not on mainline (must be on feature branch)
- ✓ Detect fork setup (origin vs upstream)
- ✓ Find PR templates
- ✓ Push branch (if not already pushed)
- ✓ Create PR using GitHub MCP tools
Sections: Current Git State • Core Workflow • Examples
Current Git State
- Current branch: !
git rev-parse --abbrev-ref HEAD
- Mainline branch: !
${CLAUDE_PLUGIN_ROOT}/skills/pr/scripts/detect-mainline.sh
- Has uncommitted changes: !
git diff-index --quiet HEAD -- 2>/dev/null && echo "no" || echo "yes"
- Remotes: !
git remote -v
- Commits since mainline: !
mainline=$(${CLAUDE_PLUGIN_ROOT}/skills/pr/scripts/detect-mainline.sh); git log ${mainline}..HEAD --oneline 2>/dev/null || echo "unable to determine"
Core Workflow
Follow these steps when the user requests PR creation:
1. Pre-Flight Checks
Use git state from dynamic context above.
Verify branch is not mainline:
If current branch equals mainline branch, error and suggest creating a feature branch first.
If uncommitted changes exist:
- Ask user: "You have uncommitted changes. Would you like to commit them first?"
- If yes, invoke
/git:commit skill using the Skill tool
- After commit succeeds, continue with PR process
2. Detect Fork Setup
Use remotes from dynamic context above.
Fork detection:
If both origin and upstream remotes exist, this is a fork setup:
- Push to:
origin (your fork)
- PR targets:
upstream (original repo)
- head format:
username:branch
Direct repository:
If only origin remote exists:
- Push to:
origin
- PR targets:
origin
- head format:
branch
Extract owner/repo from remote URLs for use with GitHub MCP tools.
3. Gather Context
Review commits:
Use commits since mainline from dynamic context above to understand what will be in the PR.
Check if branch is pushed:
if git ls-remote --heads $push_remote $current_branch | grep -q .; then
echo "Branch exists on remote"
local_sha=$(git rev-parse HEAD)
remote_sha=$(git rev-parse $push_remote/$current_branch)
if [ "$local_sha" != "$remote_sha" ]; then
echo "Local branch ahead of remote - need to push"
fi
else
echo "Branch not on remote - need to push"
fi
4. Find PR Templates
Search for PR templates:
templates=(
".github/PULL_REQUEST_TEMPLATE.md"
".github/pull_request_template.md"
".github/PULL_REQUEST_TEMPLATE/*.md"
"docs/PULL_REQUEST_TEMPLATE.md"
"PULL_REQUEST_TEMPLATE.md"
)
for template in "${templates[@]}"; do
if [ -f "$template" ] || ls $template 2>/dev/null; then
echo "Found template: $template"
fi
done
If template found:
- Read template content
- Use template structure for PR description
- Fill in relevant sections based on changes
If multiple templates:
- Check
.github/PULL_REQUEST_TEMPLATE/ directory
- Templates may be categorized (bug_fix.md, feature.md, etc.)
- Ask user which template applies
5. Push Branch (if needed)
If branch not pushed or outdated:
git push -u $push_remote $current_branch
If fork setup:
Verify pushing to correct remote:
- Should push to
origin (your fork)
- NOT to
upstream (original repo)
6. Create Pull Request
Prefer GitHub MCP tools over gh CLI:
Use mcp__plugin_github_github__create_pull_request tool:
owner: {pr_base_owner} # upstream owner if fork, else origin owner
repo: {pr_base_repo} # repository name
title: {pr_title} # Descriptive title
head: {your_username}:{current_branch} # If fork: user:branch
base: {mainline} # Target branch (main/master)
body: {pr_description} # PR description with template
For fork PRs:
head format: your-username:branch-name
base repository: upstream repository
- Verify you have permission to create PR to upstream
For direct repository PRs:
head format: branch-name
base repository: same repository
PR description structure:
If template found, follow it. Otherwise use:
## Summary
- Brief overview of changes (3-5 bullet points)
## Changes
- Detailed list of modifications
- What was added/removed/changed
## Testing
- How changes were tested
- Test cases covered
## Related Issues
Closes #{issue_number}
7. Return PR URL
After PR created:
- Report success to user
- Provide PR URL for viewing
- Mention any next steps (request reviewers, run CI, etc.)
Examples
Example 1: Create PR from Fork
User request: "Create a pull request for my authentication changes"
Steps:
- Check uncommitted: None ✓
- Current branch:
feat/auth, not mainline ✓
- Detect fork: Has origin + upstream → Yes, is fork
- Push target:
origin, PR base: upstream
- Check commits: 3 commits since
main
- Find template: Found
.github/PULL_REQUEST_TEMPLATE.md
- Push:
git push -u origin feat/auth
- Create PR using GitHub MCP:
- owner:
upstream-org
- repo:
project
- head:
myusername:feat/auth
- base:
main
- body: Template filled with changes
- Return: "PR created: https://github.com/upstream-org/project/pull/123"
Example 2: PR with Uncommitted Changes
User request: "Open a PR for the bug fix"
Steps:
- Check uncommitted: Has unstaged changes in
login.js
- Ask: "You have uncommitted changes. Commit them first?"
- User: "Yes"
- Invoke
/git:commit skill → Creates commit
- Detect fork: No (single remote)
- Find template: None found
- Push:
git push -u origin fix/login-bug
- Create PR using GitHub MCP:
- owner:
my-org
- repo:
my-project
- head:
fix/login-bug
- base:
main
- body: Auto-generated from commits
- Return PR URL
Example 3: PR to Non-Main Branch
User request: "Create PR targeting the develop branch"
Steps:
- Pre-flight checks: Pass ✓
- Detect fork: No
- Base branch: User specified
develop (override mainline)
- Push branch
- Create PR with base:
develop
- Return PR URL
Task Coordination
At workflow start:
- Create coordination task with TaskCreate:
- subject: "Create pull request"
- activeForm: "Creating pull request"
- metadata:
{ workflow: "pr", branch: "<current-branch>", base: "<target-branch>", startedAt: "<timestamp>" }
During workflow:
- Update task metadata for significant events (push, template found, etc.)
At workflow end:
- Update task status to completed
- Add result metadata:
{ result: { prUrl: "<url>", prNumber: <number> } }
Integration with Other Skills
This skill invokes:
/git:commit - When uncommitted changes exist
This skill is invoked by:
- Users directly when ready to create PR