Pull Request Creation
Create a GitHub pull request for the current branch. Works in any Git repository with GitHub as the remote.
Pull requests are created at the user's discretion -- this skill is never triggered automatically after commits.
Workflow
Step 1: Readiness Check
Verify the branch is ready for a pull request.
- Check that the current branch has commits ahead of the base branch using
git log <base>..HEAD. - If there are no commits ahead, inform the user there is nothing to create a PR for and stop.
- If the current branch is not pushed to the remote, push it with tracking:
git push -u origin <branch>. - Check if a PR already exists for the current branch using
gh pr view. If one exists, display the existing PR URL and ask the user whether to update it or abort.
Step 2: Draft and Create PR
Generate a title and body from the commit history, then create the PR.
- Display the commit log between the base branch and HEAD:
git log --oneline <base>..HEAD. - Display the full diff:
git diff <base>...HEAD. - Draft a PR title (under 72 characters) and body:
- Title: concise summary of the changes in imperative form
- Body: structured summary with sections as appropriate
- Follow repository conventions if visible from recent PRs
- Create the pull request:
gh pr create --title "<title>" --body "$(cat <<'EOF' <body> EOF )" - Display the PR number and URL.
Error Handling
If PR creation fails, display the error message returned by gh pr create.
Before Finishing
After creating the PR, review it from a reviewer's perspective:
- Understandable? Can a reviewer who has no context about the conversation understand what this PR does and why, from the title and body alone?
- Complete? Does the diff include all intended changes? Check
git statusfor unstaged changes that may have been missed.
Constraints
- Do not merge the PR -- creation only.
- Do not force-push or rebase without explicit user request.
- The base branch defaults to the repository's default branch unless the user specifies otherwise.