| name | git-review |
| description | This skill should be used when the user asks about "code review", "pull request", "PR review", "git workflow", "branching strategy", "git flow", "trunk-based", "conventional commits", "merge conflict", "git rebase", "cherry-pick", "git bisect", "monorepo", "commit message", "PR template", or needs git workflow and code review knowledge. |
| keywords | ["code review","pull request","PR review","git workflow","branching strategy","git flow","trunk-based","conventional commits","merge conflict","git rebase","cherry-pick","git bisect","monorepo","commit message","PR template"] |
Git & Code Review
Workflow-layer skill covering branching strategies, commit conventions, PR review processes, conflict resolution, and monorepo patterns. Focuses on team collaboration best practices.
Branching Strategy Decision Tree
What's your team and release cadence?
├── Small team (1-5), continuous deployment
│ └── Trunk-Based Development
│ ├── main branch is always deployable
│ ├── Short-lived feature branches (< 1 day)
│ ├── Feature flags for incomplete work
│ └── Deploy on every merge to main
│
├── Medium team, regular releases
│ └── GitHub Flow
│ ├── main branch is always deployable
│ ├── Feature branches from main
│ ├── PR review required
│ └── Merge to main triggers deploy
│
├── Large team, scheduled releases, compliance needs
│ └── Git Flow
│ ├── main (production) + develop (integration)
│ ├── feature/* branches from develop
│ ├── release/* branches for stabilization
│ └── hotfix/* branches from main
│
└── Open source project
└── Forking Workflow
├── Contributors fork the repo
├── Feature branches in fork
└── PR to upstream main
Strategy Comparison:
| Strategy | Complexity | Best For | Risk |
|---|
| Trunk-based | Low | Small teams, CI/CD mature | Needs feature flags |
| GitHub Flow | Low-Medium | Most teams | None (good default) |
| Git Flow | High | Scheduled releases, compliance | Branch overhead |
| Forking | Medium | Open source | Sync overhead |
Default recommendation: GitHub Flow for most teams.
Conventional Commits
Format
<type>(<scope>): <description>
[optional body]
[optional footer(s)]
Types Table
| Type | When | Example |
|---|
feat | New feature | feat(auth): add Google OAuth login |
fix | Bug fix | fix(cart): correct total calculation with discounts |
docs | Documentation only | docs(api): add rate limiting to API docs |
style | Formatting, no code change | style: fix linting errors in utils |
refactor | Code change, no behavior change | refactor(db): extract query helpers |
perf | Performance improvement | perf(list): virtualize long item lists |
test | Adding or fixing tests | test(auth): add JWT expiration tests |
build | Build system or dependencies | build: upgrade to Node 20 |
ci | CI configuration | ci: add Playwright to GitHub Actions |
chore | Maintenance tasks | chore: clean up unused dependencies |
Commit Message Rules
- Subject line: imperative mood, max 72 characters
- Body: explain WHY, not WHAT (the diff shows what)
- Breaking changes: add
! after type or BREAKING CHANGE: in footer
- Reference issues:
Closes #123 or Fixes #456 in footer
feat(api)!: change authentication to use JWT
Migrate from session-based auth to JWT tokens for better
scalability across multiple server instances.
Access tokens expire in 15 minutes with refresh token rotation.
BREAKING CHANGE: All API clients must send Authorization: Bearer header
instead of session cookies.
Closes #234
PR Review Checklist
For the Reviewer
Code Quality:
Security:
Performance:
Testing:
Architecture:
For the Author
Merge Conflict Resolution
Workflow
git fetch origin
git rebase origin/main
git status
git add <resolved-file>
git rebase --continue
git rebase --abort
Conflict Prevention
- Keep feature branches short-lived (< 3 days)
- Regularly sync with main (
git rebase origin/main)
- Communicate about overlapping file changes
- Break large features into smaller PRs
Git Commands Quick Reference
Rebase (Rewrite History)
git rebase origin/main
git rebase -i HEAD~3
Cherry-Pick (Copy Specific Commits)
git cherry-pick <commit-hash>
git cherry-pick --no-commit <commit-hash>
Bisect (Find Bug-Introducing Commit)
git bisect start
git bisect bad
git bisect good <known-good-hash>
git bisect good
git bisect bad
git bisect reset
Stash (Temporary Storage)
git stash
git stash -u
git stash list
git stash pop
git stash apply stash@{2}
git stash drop stash@{0}
Other Useful Commands
git log --oneline --graph -20
git diff --stat main..HEAD
git reflog
git blame -L 10,20 file.ts
git shortlog -sn
Monorepo Patterns
| Tool | Type | Best For |
|---|
| Turborepo | Build system | Next.js / Vercel ecosystem, simple setup |
| Nx | Build system + workspace | Large monorepos, plugin ecosystem, caching |
| pnpm workspaces | Package manager | Dependency management, no build orchestration |
| npm workspaces | Package manager | Simple, no extra tools |
Turborepo Structure
my-monorepo/
apps/
web/ # Next.js frontend
api/ # Express/Fastify backend
mobile/ # React Native app
packages/
ui/ # Shared component library
config/ # Shared ESLint, TypeScript configs
db/ # Prisma schema and client
utils/ # Shared utility functions
turbo.json
package.json
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": { "dependsOn": ["^build"], "outputs": ["dist/**", ".next/**"] },
"dev": { "cache": false, "persistent": true },
"lint": {},
"test": { "dependsOn": ["build"] }
}
}
PR Template
## What
<!-- Brief description of the change -->
## Why
<!-- Motivation: why is this change needed? Link to issue. -->
Closes #
## How
<!-- Implementation approach: key decisions and trade-offs -->
## Testing
<!-- How was this tested? -->
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manually tested locally
## Screenshots
<!-- For UI changes: before/after screenshots -->
## Checklist
- [ ] Self-reviewed the diff
- [ ] No console.logs or debugging code
- [ ] Types are correct (no `any`)
- [ ] Follows existing code conventions
Git Hooks (Husky + lint-staged)
npm install -D husky lint-staged
npx husky init
{
"lint-staged": {
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
"*.{json,md,yml}": ["prettier --write"]
}
}
npx lint-staged
npx commitlint --edit $1
Code Review Best Practices
How to give feedback:
- Be specific: "This query will N+1" not "This is slow"
- Suggest alternatives: "Consider using
useMemo here because..."
- Ask questions: "What happens if
user is null here?"
- Prefix with severity:
nit:, suggestion:, blocker:
- Praise good code: "Nice pattern here!"
What to focus on (high to low impact):
- Correctness — does it do what it should?
- Security — any vulnerabilities?
- Architecture — right abstraction level?
- Performance — any obvious issues?
- Readability — can the next person understand it?
- Style — (should be automated, don't comment on this)
Common Git Mistakes
| Mistake | Symptom | Fix |
|---|
| Committing secrets | Credentials in git history | git-secrets, .gitignore, BFG to scrub |
| Giant PRs (500+ lines) | Slow review, bugs slip through | Break into smaller, focused PRs |
| Merge commits instead of rebase | Cluttered history | Use rebase for feature branches |
| Force-pushing shared branches | Teammates lose work | Only force-push YOUR branches |
| No .gitignore | node_modules, .env committed | Set up .gitignore on project init |
| Vague commit messages | "fix stuff", "updates" | Follow conventional commits format |
| Long-lived feature branches | Painful merges, divergence | Keep branches < 3 days, use feature flags |
| Not pulling before pushing | Rejected push, merge conflicts | git pull --rebase before push |
| Amending public commits | History rewrite breaks teammates | Only amend unpushed commits |
| No branch protection | Direct pushes to main | Require PR + review + CI pass |
Pre-Delivery Checklist
References
references/git-advanced.md — interactive rebase, reflog recovery, worktrees, submodules
references/monorepo-patterns.md — Turborepo and Nx deep dive, workspace configuration
references/code-review-guide.md — review strategies, feedback templates, team workflows
references/branch-strategies.md — trunk-based, GitHub Flow, Git Flow detailed comparison
examples/husky-setup.md — complete Husky + lint-staged + commitlint configuration
examples/pr-workflow.md — end-to-end PR workflow from branch to merge