my-notes

Code_Reviews_and_Approvals

1 min read

Code Reviews and Approvals

Best practices for reviewing code.


πŸ“Š Review Flow

graph LR
    A[PR Created] --> B[Reviewers Assigned]
    B --> C[Review Changes]
    C --> D{Approve?}
    D -->|Yes| E[Merge]
    D -->|No| F[Request Changes]
    F --> G[Author Updates]
    G --> C

πŸ”§ CLI Review Commands

Request Review

gh pr edit 123 --add-reviewer username

Adds reviewer to PR.


Approve PR

gh pr review 123 --approve

Approves the pull request.


Approve with Comment

gh pr review 123 --approve --body "LGTM!"

Approves with message.


Request Changes

gh pr review 123 --request-changes --body "Please fix the validation logic"

Requests changes before merge.


Comment Only

gh pr review 123 --comment --body "Have you considered..."

Adds comment without approval.


View Review Status

gh pr view 123

Shows review status.


πŸ“‹ Review Checklist

What to Check


πŸ’¬ Review Comments

Good Comment Examples

Consider extracting this into a function for reusability.
This might cause N+1 queries. Consider using eager loading.
Nice solution! Much cleaner than the previous approach.

Avoid These

This is wrong.
Why did you do this?

Use constructive language instead.


πŸ“ CODEOWNERS

Create .github/CODEOWNERS:

# Default
* @team-lead

# By path
/src/frontend/ @frontend-team
/src/api/ @backend-team

# By type
*.js @js-experts
*.py @python-team

Auto-assigns reviewers by path.


βš™οΈ Branch Protection

Require Approvals

Set in repo settings:

  • Require 1-2 approving reviews
  • Dismiss stale reviews on new commits
  • Require review from code owners

πŸ’‘ Tips

Small PRs

Keep PRs small (< 400 lines) for better reviews.

Self-Review First

Review your own PR before requesting others.

Be Timely

Review within 24 hours when possible.



#github #review #approval #codereview

Built with mdgarden