Read Anthropic’s case study about Graphite Reviewer

Best practices for PR reviews

Kenny DuMez
Kenny DuMez
Graphite software engineer

Efficient pull request (PR) reviews are important for high-velocity software development. Good reviews ensure code quality, foster collaboration, and facilitate knowledge sharing among team members. This guide explores best practices for PR reviews, focusing on optimizing the time to first review, the number of review cycles, and implementing workflows like "stacking" to streamline the review process.

Time to first review refers to the duration between a PR being opened and it receiving its first review. A shorter time to first review can:

  • Accelerate the development cycle by enabling the author to respond to feedback more quickly.
  • Reduce context switching for developers, as the code and its intended functionality remain fresh in their minds.
  • Increase developer satisfaction by reducing the time PR authors spend waiting on code review.

Strategies to improve time to first review:

  • Implement automated notifications and reminders to alert reviewers as soon as a PR is submitted.
  • Define and enforce engineering practices within your team to ensure PRs are reviewed promptly.
  • Prevent notification fatigue by only requesting reviews from the most relevant stake-holders of each set of changes.

A review cycle involves submitting a PR, receiving feedback, making changes, and requesting further review. Reducing the number of cycles is crucial because:

  • Each cycle can significantly delay the final merge, affecting project timelines.
  • Multiple review cycles can lead to frustration and reduce the efficiency of the development process.

Tips to reduce review cycles:

  • Ensure that the PR is well-documented and that the reasoning behind each set of changes is clearly explained, minimizing the back-and-forth between author and reviewers.
  • Encourage contributors to self-review their changes before submitting a PR to catch simple errors or omissions early.
  • Use checklist templates for PR submissions to standardize required information and reduce omissions that could lead to additional review cycles.

Long wait times for reviews can stall development and lead to context switching that hurts productivity. To mitigate this:

  • Prioritize PR reviews in daily workloads, treating them as essential tasks.
  • Use CI tools and linters to automate preliminary checks (like style, syntax, and basic tests) before human review, ensuring only quality code is reviewed.
  • Foster a culture where timely feedback is valued and recognized as a contribution to team success.

Stacking is a technique where changes are stacked in small, incremental PRs rather than one large monolithic feature branch. This approach:

  • Parallelizes development and review, so you don't need to wait for previous changes to be merged before building on top of them.
  • Facilitates easier, quicker reviews, as each PR is smaller and more focused.
  • Reduces integration conflicts by merging smaller changes into the main branch more frequently.
  • Allows for faster iterations and adjustments based on feedback.

Steps to implement the stacking workflow:

  1. Break large features into smaller, logically separate tasks: Each code change should ideally be self-contained and deliver some incremental value.
  2. Submit each incremental change as a separate PR: These PRs are based on the branch of the previous change rather than the main branch.
  3. Review and merge each small PR sequentially: This keeps the main branch stable and integrates changes progressively.

Optimizing PR review processes not only improves the speed and efficiency of software development but also contributes to higher code quality and team morale. By implementing these best practices, teams can create a more dynamic and productive development environment. Embracing methods like the stacking workflow can further enhance the effectiveness of code reviews, promoting a culture of continuous improvement and collaboration.

0 min read
Share
Git inspired
Graphite's CLI and VS Code extension make working with Git effortless.
Learn more

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2