Git PR Workflow
A repeatable, disciplined workflow for turning work-in-progress code into a clean pull request ready for review. Covers branch hygiene, commit quality, and PR description best practices.
When to Activate
Activate this skill when:
- You've finished a feature or fix and are ready to open a PR
- You need to prepare a branch for code review
- You want to ensure your PR passes CI before review
Workflow
Phase 1: Branch & Commit Hygiene
Clean up the branch before opening the PR.
Steps:
- Run
git statusto confirm working tree is clean - Run
git log origin/main..HEAD --onelineto review commits - Squash or reword any "WIP", "fix typo", or noise commits with
git rebase -i origin/main - Ensure each commit has a clear imperative message:
Add user auth, notadded stuff - Run
git diff origin/mainfor a final sanity check
Before moving on:
- No WIP commits remain
- All commits have clear messages
- No unintended files are staged
Phase 2: CI Pre-flight
Run tests locally before pushing.
Steps:
- Run the test suite:
pytest/npm test/ project-specific command - Run the linter:
ruff check ./eslint ./ equivalent - Fix any failures — do NOT push a red branch
- Push the branch:
git push -u origin HEAD
Before moving on:
- All tests pass locally
- Linter reports no errors
Phase 3: PR Description
Open the PR with a description that makes reviewers' lives easy.
Steps:
- Open the PR on GitHub / GitLab
- Title: imperative mood, under 60 chars —
Add OAuth2 login flow - Body: use this structure:
## What [1-3 bullets: what changed] ## Why [Context: issue link, ticket, or motivation] ## How to Test [Checklist of manual test steps] ## Screenshots (if UI change) - Link to any related issues:
Closes #123 - Assign reviewers and labels
Before moving on:
- PR title follows convention
- Description has What / Why / How to Test
- Reviewers assigned
Quality Checklist
- Branch is rebased on top of
main - No merge conflicts
- CI is green after push
- PR description complete
- Self-reviewed the diff one more time
Examples
Example 1: Feature PR
Working on a new login page. After finishing:
git rebase -i origin/main→ squash 4 commits into 1:Add OAuth2 login pagepytest→ all passgit push -u origin feature/oauth-login- Open PR: title
Add OAuth2 login page, link to issue #88 - Assign 2 reviewers, add label
feature
Example 2: Bug Fix PR
Fixed a null pointer in the payment service:
- Single commit already clean:
Fix null pointer in PaymentService.charge npm test→ passesgit push, open PR titledFix null pointer in PaymentService- Body explains the root cause and how to reproduce before the fix
Anti-patterns
- ❌ Opening a PR from
maindirectly - ❌ Pushing without running tests first
- ❌ PR descriptions that just say "fixes bug"
- ❌ 47-commit PRs with no squashing
- ❌ Assigning reviewers before CI is green
Integration
This skill works well with:
software-development/code-review— for what reviewers will checksoftware-development/systematic-debugging— if CI fails after push
Generated by Skill Factory — example output