Creates a pull request from current changes. Commits changes logically, finds PR templates, and opens the PR using the gh CLI. Best used after completing work.
You are now in PR creation mode. Your job is to take the current uncommitted changes (or unpushed commits), organize them into logical commits, and create a well-structured pull request.
The user invoking this skill is their confirmation. Do not ask for additional confirmation before committing, pushing, or creating the PR—just do it.
Important: This skill is typically invoked at the end of a session after you've already made changes. You likely already have context about what was changed and why—use that knowledge rather than re-analyzing diffs unnecessarily.
gh CLI is installed and authenticatedGet the minimal info needed to proceed:
# Get branch, status, and remote in one command
git rev-parse --abbrev-ref HEAD && git status --short && git remote get-url origin
From the remote URL, extract owner and repo.
If you already have context from this session about what changed and why, use it. Otherwise, review the changes:
git diff --stat # Overview of files changed
git diff -- path/to/file.ts # Full diff for specific files if needed
Group related changes into logical commits. Each commit should:
For a single logical change:
git add -A
git commit -m "Add user authentication endpoint"
For multiple logical changes, commit separately:
# First logical group
git add src/auth.ts src/types/auth.ts
git commit -m "Add authentication types and handler"
# Second logical group
git add src/routes.ts
git commit -m "Wire up auth routes"
# Third logical group
git add tests/auth.test.ts
git commit -m "Add authentication tests"
Commit message guidelines:
# Push to remote (set upstream if needed)
git push -u origin HEAD
Look for PR templates in standard locations:
# Check common template locations
for f in \
.github/pull_request_template.md \
.github/PULL_REQUEST_TEMPLATE.md \
docs/pull_request_template.md \
pull_request_template.md \
PULL_REQUEST_TEMPLATE.md \
.github/PULL_REQUEST_TEMPLATE/*.md; do
[ -f "$f" ] && echo "Found: $f"
done
If a template exists, read it and use its structure. If multiple templates exist (in .github/PULL_REQUEST_TEMPLATE/), choose the most appropriate one based on the change type (feature, bugfix, etc.).
Title: Create a concise title that summarizes the PR:
CLI:, feat:)Body: Generate a comprehensive PR description:
Use the commit messages and diff to write accurate, helpful descriptions.
On Windows: Backticks in --body strings get mangled by PowerShell escaping. Always write the PR body to a temp file and use --body-file instead:
# Write body to temp file, create PR, clean up
gh pr create --title "Your PR title" --body-file pr-body.md --base main
rm pr-body.md
On macOS/Linux:
# Create the PR
gh pr create \
--title "Your PR title" \
--body "Your PR body" \
--base main
If the base branch is not main, detect it:
# Get default branch
gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'
After creation, display the PR URL to the user.
If there are no uncommitted changes and no unpushed commits:
gh pr view)If working directly on main/master:
# Create a feature branch first
git checkout -b feature/descriptive-name
Then proceed with commits.
Check if a PR already exists for this branch:
gh pr view --json url 2>/dev/null && echo "PR already exists"
If so, just push the new commits - the PR will update automatically.
If the branch is behind the base:
# Fetch and check
git fetch origin main
git log HEAD..origin/main --oneline
If there are upstream changes, prefer merging by default:
git merge origin/main
Only rebase if the user explicitly requests it. After resolving any conflicts, continue with the push.
After successfully creating the PR, provide:
Analyzing changes...
Found 5 modified files across 2 logical changes:
Creating commits:
✓ feat: add rate limiting middleware (3 files)
✓ test: add rate limiting tests (2 files)
Pushing to origin/feature/rate-limiting...
✓ Branch pushed
Finding PR template...
✓ Using .github/pull_request_template.md
Creating pull request...
✓ PR #142 created: https://github.com/owner/repo/pull/142
Summary:
- 2 commits pushed
- PR created against main