| name | pr-workflow |
| description | Guide pull request creation, review process, CI gates, and merge strategies. Use when the user creates a PR, asks about PR templates, review workflows, CODEOWNERS setup, or merge strategies. Apply when running gh pr create.
|
Pull Request Workflow
Structure PRs for effective code review, automated CI validation, and clean merge history.
When to Use
- Creating a pull request with
gh pr create or GitHub UI
- Setting up PR templates for a repository
- Configuring CODEOWNERS for automatic review assignment
- Choosing between squash, merge, and rebase merge strategies
- Reviewing or improving an existing PR workflow
Core Patterns
PR Creation with gh CLI
Always analyze changes before creating a PR:
git log main..HEAD --oneline
git diff main...HEAD --stat
git push -u origin feature/AUTH-123-add-sso
gh pr create --title "feat(auth): add SSO login via SAML" --body "$(cat <<'EOF'
## Summary
- Add SAML-based SSO authentication flow
- Integrate with identity provider discovery endpoint
- Store SSO sessions with configurable TTL
## Changes
- `src/auth/sso.ts` โ SAML assertion parsing and validation
- `src/auth/routes.ts` โ New `/auth/sso/callback` endpoint
- `src/config/sso.ts` โ SSO provider configuration schema
## Test Plan
- [ ] Unit tests for SAML assertion parsing
- [ ] Integration test with mock IdP
- [ ] Manual test with Okta sandbox
- [ ] Verify session expiration behavior
Closes #142
EOF
)"
PR Template
Create .github/pull_request_template.md in the repository:
## Summary
<!-- 1-3 bullet points describing WHAT changed and WHY -->
## Changes
<!-- List key files changed and what was modified -->
## Test Plan
<!-- How to verify this works correctly -->
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing steps documented
## Screenshots
<!-- If UI changes, include before/after screenshots -->
## Checklist
- [ ] Tests added/updated
- [ ] Documentation updated (if needed)
- [ ] No breaking changes (or noted in description)
- [ ] Self-reviewed the diff
CODEOWNERS Setup
Create .github/CODEOWNERS to auto-assign reviewers:
* @org/engineering-leads
src/components/ @org/frontend
src/pages/ @org/frontend
src/styles/ @org/frontend
src/api/ @org/backend
src/services/ @org/backend
src/models/ @org/backend
Dockerfile @org/devops
docker-compose.yml @org/devops
.github/workflows/ @org/devops
terraform/ @org/devops
src/auth/ @org/security @org/backend
src/crypto/ @org/security
Merge Strategy Selection
gh pr merge 123 --squash
gh pr merge 123 --merge
gh pr merge 123 --rebase
| Strategy | Best For | Result |
|---|
| Squash | Feature PRs, messy history | Single commit on main |
| Merge | Release branches, audit trails | Merge commit + all commits |
| Rebase | Clean PRs with good commits | Linear history, no merge commit |
Draft PRs and Review Process
gh pr create --draft --title "WIP: refactor auth module"
gh pr ready 123
gh pr create --reviewer "alice,bob" --title "feat: add caching layer"
gh pr edit 123 --add-reviewer "alice"
gh pr checks 123
gh pr view 123
Review workflow stages:
- Draft PR โ Open early for visibility, not ready for review
- Ready for Review โ All CI passing, self-reviewed, description complete
- Changes Requested โ Address feedback, push new commits (do not force-push)
- Approved โ Merge when CI is green and approvals are met
- Merged โ Delete the source branch
CI Gates Configuration
Example GitHub Actions workflow for PR validation:
name: PR Checks
on:
pull_request:
branches: [main, develop]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run lint
- run: npm run typecheck
- run: npm test -- --coverage
- run: npm run build
Configure branch protection to require these checks before merging.
Anti-Patterns
What NOT to Do
- Giant PRs: PRs over 400 lines are hard to review and likely to hide bugs. Split into smaller, focused PRs.
- No description: A PR with just a title gives reviewers no context. Always include summary, changes, and test plan.
- Force-pushing during review: Reviewers lose context of what changed between review rounds. Push new commits instead.
- Merging with failing CI: Never override CI checks to merge faster. Fix the failures.
- Self-approving: Even solo developers benefit from CI gates. Do not bypass required reviews.
gh pr create --title "updates"
git rebase -i HEAD~5
git push --force
git commit -m "fix: address review feedback on input validation"
git push
Quick Reference
PR Creation Checklist:
1. git log main..HEAD โ review all commits
2. git diff main...HEAD --stat โ verify changed files
3. git push -u origin <branch> โ push with tracking
4. gh pr create โ with title, body, reviewers
PR Title Format:
<type>(<scope>): <description> (matches commit conventions)
PR Body Sections:
## Summary โ WHAT and WHY (1-3 bullets)
## Changes โ Key files and modifications
## Test Plan โ How to verify correctness
## Screenshots โ Before/after for UI changes
Merge Strategy:
Feature PRs -> squash merge
Release branches -> merge commit
Clean linear PRs -> rebase merge
Files to Set Up:
.github/pull_request_template.md โ PR template
.github/CODEOWNERS โ Auto-assign reviewers
.github/workflows/pr-checks.yml โ CI gates
Commands:
gh pr create --draft โ Early visibility
gh pr ready 123 โ Mark ready for review
gh pr checks 123 โ Verify CI status
gh pr merge 123 --squash โ Squash merge