<type>/<short-description>
feature/- New features or enhancementsfix/- Bug fixesrefactor/- Code refactoring without functionality changesdocs/- Documentation changestest/- Test additions or modificationschore/- Maintenance tasks (dependencies, tooling)perf/- Performance improvements
feature/user-authentication
fix/login-redirect-loop
refactor/extract-auth-middleware
docs/update-api-documentation
test/add-checkout-e2e-tests
chore/upgrade-dependencies
Follow Conventional Commits (conventionalcommits.org):
<type>(<scope>): <subject>
<body>
<footer>
feat, fix, refactor, docs, style, test, chore, perf, ci, build
feat(auth): add Google OAuth login
fix(api): resolve race condition in token refresh
refactor(db): extract query builder into utility
docs: update deployment guide
test(checkout): add E2E tests for payment flow
✅ DO:
- Use imperative mood ("add" not "added")
- Be concise but descriptive
- Include scope when relevant
- Reference issue numbers in footer
❌ DON'T:
- Add "Co-Authored-By" or AI attribution
- Use emojis in commit messages
- Write vague messages ("fix bug", "update code")
- Commit directly to main/master
# Always start from updated main
git checkout main
git pull origin main
# Create feature branch
git checkout -b feature/user-roles- Write code
- Add tests
- Update documentation
Critical: Run these BEFORE every commit:
# Format code
npm run format # or: go fmt ./...
# Run linter
npm run lint # or: golangci-lint run
# Run tests
npm test # or: go test ./...
# Build
npm run build # or: go build ./...If any check fails, fix it before committing.
# Stage changes
git add .
# Commit with conventional message
git commit -m "feat(roles): add RBAC with 3 role types"# First push
git push -u origin feature/user-roles
# Subsequent pushes
git pushUse GitHub CLI or web interface:
# Using gh CLI
gh pr create --title "feat: Add user roles with RBAC" \
--body "## Summary
Implements role-based access control with 3 roles:
- Admin (full access)
- Editor (read/write)
- Viewer (read only)
## Changes
- Database migration for roles table
- RBAC middleware
- Permission checking utilities
- E2E tests for all roles
## Testing
- All E2E tests pass
- Manual testing completed
- No breaking changes"Three-Layer Review:
- You - Self-review before requesting
- Peer - Team member review
- AI - Automated checks + AI code review
Review Checklist:
- ✅ Code follows project conventions
- ✅ Tests are comprehensive
- ✅ Documentation is updated
- ✅ No security issues
- ✅ Performance impact considered
- ✅ Breaking changes documented
Never let AI merge PRs.
After approval:
# Squash merge (preferred for clean history)
gh pr merge --squash
# Or use GitHub web interface# Delete local branch
git checkout main
git pull
git branch -d feature/user-roles
# Remote branch deleted automatically by GitHub- ✅ Small: 100-300 lines changed
⚠️ Medium: 300-500 lines- ❌ Large: 500+ lines (split into multiple PRs)
## Summary
[What this PR does]
## Changes
- [List of changes]
## Testing
- [How it was tested]
## Screenshots (if UI changes)
[Add screenshots]
## Breaking Changes
[List any breaking changes]
## Related Issues
Closes #123
Relates to #456# Make requested changes
# ... edit files ...
# Commit changes
git add .
git commit -m "refactor: apply review feedback"
git push
# PR automatically updates# Update your branch with latest main
git checkout feature/my-feature
git fetch origin
git rebase origin/main
# Resolve conflicts if any
# ... fix conflicts ...
git add .
git rebase --continue
# Force push (branch is already remote)
git push --force-with-lease# Last commit only
git commit --amend -m "feat(auth): add OAuth support"
git push --force-with-lease
# Older commits (use interactive rebase)
git rebase -i HEAD~3
# Change "pick" to "reword" for commits to fix
# Save and edit messages
git push --force-with-lease# Save work in progress
git stash save "WIP: implementing user roles"
# Switch branches
git checkout main
# Return and restore
git checkout feature/user-roles
git stash pop- Never commit directly to main
- Never merge your own PR without review
- Never commit code that fails tests
- Never commit secrets or credentials
- Never force push to main
- Commit messages follow conventional format
- PRs include tests for new code
- PRs update relevant documentation
- Branches deleted after merge
- Commits are atomic (one logical change)
- ❌ AI cannot merge PRs
- ❌ AI cannot approve PRs
- ✅ AI can create branches
- ✅ AI can commit code
- ✅ AI can push branches
- ✅ AI can open PRs
# Set your identity
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
# Default branch name
git config --global init.defaultBranch main
# Rebase by default when pulling
git config --global pull.rebase true
# Prune deleted remote branches
git config --global fetch.prune true
# Use better diff algorithm
git config --global diff.algorithm histogramgit config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.cm commit
git config --global alias.lg "log --graph --oneline --all"Key Takeaways:
- Clear branch naming and commit conventions
- Pre-commit checks are mandatory
- Small, focused PRs
- Three-layer review process
- Humans merge, AI executes
Prev: Scaling to Large Projects | Next: Documentation Strategies