Create a pull request using git and GitHub CLI. Handles the full workflow from committing changes to opening a PR. Use when creating a PR, opening a pull request, submitting changes for review, or pushing a branch for review. Keywords: pull request, PR, create PR, open PR, submit PR, push for review, code review
Install
npx skillscat add wcygan/dotfiles/create-pr Install via the SkillsCat registry.
Create Pull Request Workflow
End-to-end workflow for creating a pull request from local changes.
Pre-flight Checks
Before creating a PR, verify:
# Check for uncommitted changes
git status
# Verify on correct branch (not main/master)
git branch --show-current
# Check remote is set
git remote -vWorkflow Steps
1. Ensure Clean Working State
# Stage all changes (or specific files)
git add -A
# Or selectively:
git add src/feature.ts tests/feature.test.ts
# Commit with descriptive message
git commit -m "feat: add user authentication flow"Commit message conventions:
feat:- New featurefix:- Bug fixdocs:- Documentationrefactor:- Code refactoringtest:- Adding testschore:- Maintenance
2. Create Feature Branch (if not already on one)
# Create and switch to new branch
git checkout -b feat/user-auth
# Or from a specific base
git checkout -b feat/user-auth origin/mainBranch naming:
feat/description- Featuresfix/description- Bug fixesdocs/description- Documentationrefactor/description- Refactoring
3. Push Branch to Remote
# Push and set upstream
git push -u origin HEAD
# Or explicit branch name
git push -u origin feat/user-auth4. Create Pull Request
Interactive (recommended for first-time):
gh pr createWith options:
gh pr create \
--title "feat: Add user authentication" \
--body "## Summary
Adds user authentication flow with JWT tokens.
## Changes
- Add login endpoint
- Add session management
- Add auth middleware
## Testing
- [x] Unit tests pass
- [x] Manual testing complete
Closes #123"As draft:
gh pr create --draft --title "WIP: User authentication"With reviewers and labels:
gh pr create \
--title "feat: Add user auth" \
--reviewer teammate1,teammate2 \
--label enhancement,auth \
--assignee @me5. Verify PR Created
# View the PR
gh pr view --web
# Or check status
gh pr statusQuick One-Liner
For simple changes when already on a feature branch:
git add -A && git commit -m "feat: description" && git push -u origin HEAD && gh pr create --fillThe --fill flag auto-populates title from commit and body from commit messages.
Common Scenarios
From Issue
# Create branch from issue
gh issue develop 123 --checkout
# Make changes, then...
git add -A && git commit -m "fix: resolve issue #123"
git push -u origin HEAD
gh pr create --title "Fix #123: Description" --body "Closes #123"Update Existing PR
# Make more changes
git add -A && git commit -m "address review feedback"
git push
# PR updates automaticallyRebase Before PR
# Update with latest main
git fetch origin
git rebase origin/main
# Force push if needed (only on feature branches!)
git push --force-with-leaseChecklist Before Creating PR
- ✅ Tests pass locally
- ✅ Code is formatted/linted
- ✅ Commit messages are clear
- ✅ Branch is up-to-date with base
- ✅ No unintended files staged
- ✅ PR title describes the change
- ✅ PR body explains why, not just what
Error Recovery
Wrong branch:
# Move commits to new branch
git checkout -b correct-branch
git checkout main
git reset --hard origin/mainForgot to branch:
# Already committed to main? Move to feature branch
git branch feat/my-feature
git reset --hard origin/main
git checkout feat/my-featureNeed to amend last commit:
git add -A
git commit --amend --no-edit
git push --force-with-lease # If already pushed