GitHub Pull Request Skill
When to use this skill
Use this skill when you need to create a pull request for current changes in a repository. It provides a structured workflow for gathering PR details, filling templates, and executing the creation via available tools.
Workflow
- •Identify Base Branch: Determine the target base branch for the pull request (usually
main,master, or as specified by the user or repository settings). - •Analyze Changes: Compare the current
HEADcommit against the base branch to understand the scope of changes.- •Use
git diff base...HEAD --statandgit log base...HEADto gather information.
- •Use
- •Check for Templates: Check if there's a pull request template in the repository.
- •Common locations:
pull_request_template.md,.github/pull_request_template.md, or inside.github/PULL_REQUEST_TEMPLATE/.
- •Common locations:
- •Fill the Template:
- •Automatically populate the template using information from the commit logs and diff.
- •If any required information cannot be confidently filled (e.g., "Related Issue Number", "Testing Steps" if not obvious), mark these as "PENDING" and inform the user.
- •Review with User:
- •ALWAYS show the filled template to the user for review.
- •Explicitly mention any sections that need manual filling.
- •Create Pull Request:
- •ONLY after the user approves the description, proceed to create the PR.
- •Use tools in this order of precedence:
- •GitHub MCP Server: Use
github.create_pull_requesttool if available. - •GitHub CLI (gh): Run
gh pr create --title "..." --body "..." --base <base> --head <head>. - •GitHub REST API (curl): Use
curlto POST to/repos/{owner}/{repo}/pulls.
- •GitHub MCP Server: Use
Tools and Commands
GitHub CLI (gh)
bash
# Get default branch gh repo view --json defaultBranchRef -q .defaultBranchRef.name # Create PR gh pr create --title "PR Title" --body-file pr_body.md --base main
GitHub REST API (curl)
If using curl, ensure you have a GITHUB_TOKEN environment variable.
bash
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer \$GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/{owner}/{repo}/pulls \
-d '{"title":"Title","body":"Body","head":"head-branch","base":"base-branch"}'
Examples
Pull Request Preview and Approval Request
The agent should present the filled template to the user like this:
I have prepared the following pull request description based on your changes and the repository's template.
Title: feat: add user authentication module
Body:
Summary
This PR adds a new authentication module using JWT.
Changes
- •Added
src/auth/directory- •Implemented login and logout endpoints
- •Updated
README.mdwith setup instructionsPending Information
- • Related Issue Number: Please provide the issue number this PR addresses.
- • Testing Steps: I have listed basic steps, but please verify if additional scenarios are needed.
Do you approve this description? Once approved, I will create the pull request.
Validation Steps
- •Template Check: Verify that
pull_request_template.md(or equivalent) was searched for and loaded if present. - •Content Analysis: Confirm that the PR description includes a summary of changes based on git logs/diffs.
- •User Approval: Confirm the agent displayed the filled template and received explicit approval before PR creation.
- •Success Confirmation: Verify the PR was successfully created by checking tool output or PR list.