Last modified: 2026-10-11 02:07:28 (PDT)
This chapter covers the social side of writing code together: opening pull requests, reviewing each other’s work, and responding to review feedback.
Every pull request involves several people, each with a distinct role.
The issue creator reports a bug, suggests a feature, or requests other improvements. In projects with external contributors, the issue creator often cannot assign issues to developers and is typically distinct from the PR author.
The author opens the PR, writes a clear description, and links it to the relevant issue with Closes #N in the PR body. The author implements review feedback and resolves merge conflicts before re-requesting review.
The reviewer reads the diff, checks the code for correctness and style, and either approves or requests changes.
The merger executes the final merge once the PR is approved and all CI checks pass. This is often the same person as the reviewer.
The assignee is listed in the “Assignees” field on GitHub to indicate who is currently responsible for the PR. This field clarifies ownership and tracks who should be addressing open feedback.
A PR steward keeps the review queue healthy. The steward monitors open PRs, assigns reviewers when none are assigned, follows up on stalled reviews, and helps resolve disagreements between authors and reviewers. This is typically a rotating duty for a senior contributor or release manager. The p5.js project documents how it structures this role in its steward guidelines.
A focused pull request is one self-contained change that addresses just one thing. Writing focused PRs has several benefits:
As a guideline, 100 lines is usually a reasonable size for a PR, and 1000 lines is usually too large. The number of files matters too: a 200-line change in one file might be fine, but the same change spread across 50 files is usually too large.
When you submit a pull request, include a detailed title and description. A comprehensive description helps the reviewer and provides valuable historical context.
PR title: The title should be a short summary, ideally under 72 characters, that is specific enough for future developers to understand the change without opening the full PR.
Poor titles that lack context:
Better titles that summarize the actual change:
PR description body: The description should give the reviewer the context they need to understand the change. Consider including:
Closes #123 or Related to #456The Files changed tab on GitHub also lets you add inline comments that explain non-obvious changes. Those notes live in the PR metadata, not in the source files, so they are a good place to explain this change without cluttering the code with temporary rationale.
For non-obvious technical decisions, proactively explain your reasoning in commit messages and PR descriptions. Do not make reviewers ask why you chose a particular approach.
Common situations that require explanation:
@v2), version tags (for example @v2.9.4), or commit SHA pins (for example @abc1234...) and why. For example: “Using @v2 (moving tag) to receive bug fixes within the major version while maintaining stability.”This proactive communication reduces review back-and-forth and helps future maintainers understand the decision later.
Before requesting a pull request review from the PIs, obtain fresh approvals from:
This requirement applies both to the initial PI review request and to later re-review requests after revisions.
When requesting a review (whether in Microsoft Teams, email, or GitHub), always provide a direct hyperlink to the pull request (see Direct Hyperlinks in Internal Correspondence). Do not make reviewers search for the PR they are asked to review.
Focused PRs should include related test code. A PR that adds or changes logic should add or update tests for the new behavior. Pure refactoring PRs should also be protected by tests. If tests do not already exist for code you are refactoring, add them in a separate PR first to confirm that behavior stays unchanged.
It is usually best to do refactorings in a separate PR from feature changes or bug fixes. For example, moving and renaming a function should generally be separate from fixing a bug in that function. That separation makes it much easier for reviewers to understand what each PR actually changes.
Small cleanups, such as a local variable rename, can travel with a feature or bug fix. Large refactorings should not.
GitHub lets you create a pull request template in a repository so everyone starts with the same PR body structure.
To add one:
Create new file.pull_request_template.md or PULL_REQUEST_TEMPLATE.md in the repository root, .github/, or docs/. For multiple templates, use .github/PULL_REQUEST_TEMPLATE/. See GitHub’s pull request template documentation.Here is an example template:
# Description
## Summary of change
Please include a summary of the change, including any new functions added and example usage.
## Related Issues
Closes #(issue number)
Related to #(issue number)
## Testing
Describe how this change has been tested.
## Checklist
- [ ] Tests added/updated
- [ ] Documentation updated
- [ ] Code follows project style guidelines
## Who should review the pull request?
@usernameWhen implementing a sequence of interdependent features or multi-stage refactorings, stack pull requests to keep each change small and focused (see Section 1.3 for detailed stack creation, CI, and merging guidelines).
A stacked pull request workflow breaks large or multi-step code changes into a linear chain (or stack) of smaller, dependent pull requests (“About Stacked Pull Requests,” n.d.).
In a pull request stack:
main).Each pull request in the stack isolates the diff for its specific layer, displaying only the changes between its branch and the layer beneath it.
Stacked pull requests provide several practical advantages:
When using stacked pull requests, follow these guidelines:
GitHub provides native platform support for managing and merging pull request stacks:
main) automatically apply to every pull request in the stack, ensuring consistent quality across every layer.When submitting code to colleagues or reviewing theirs, use practices that keep feedback constructive and specific. The Tidyverse code review principles (Tidyverse Team 2023) are a strong baseline for R projects. As noted in the Tidyverse guide’s acknowledgments, the guide is a modified fork of Google’s Code Review Developer Guide.
The primary purpose of code review is to improve the overall code health of the project over time. Reviewers should balance the need to make forward progress with the need to maintain code quality.
The key principle is to approve a PR once it clearly improves the codebase, even if it is not perfect. There is no such thing as perfect code. There is only better code.
To keep reviews moving, bookmark GitHub’s review-requested page and check it regularly, ideally at least daily:
YOUR-USERNAME with your GitHub username.Checking these pages regularly helps keep PRs from languishing in the queue.
When reviewing code, be courteous, clear, and helpful:
Poor comment: “Why did you use this approach when there is obviously a better way?”
Better comment: “This approach adds complexity without clear benefits. Consider using [alternative approach] instead, which would simplify the logic and improve readability.”
Code review is also a mentoring tool. As a reviewer:
In general, the author is responsible for fixing the PR, not the reviewer. Point out problems clearly, but do not feel obligated to design every solution. Sometimes it is better to name the issue and let the author work out the implementation details.
For very small tweaks, such as typo fixes or comment additions, use GitHub’s suggestion feature so the author can accept the change directly in the UI.
When reviewing pull requests in R package repositories, you can usually ignore .Rd files in man/. These files are generated automatically by {roxygen2} from roxygen comments in the source.
Why ignore .Rd files?
.R source files.What to review instead:
Review the roxygen comments in the .R source files. These begin with #' and appear immediately before function definitions.
If the repository has a preview workflow such as pkgdown or Quarto, review the rendered preview as well. The workflow should post a PR comment with a link to the preview build.
In GitHub’s Files changed view, you can click the three dots (...) next to a file and choose View file to hide it from the diff. That helps you focus on the meaningful changes.
Review pull requests created by GitHub Copilot coding agents using the same standards as any other PR, but watch for a few agent-specific issues.
Workflow approval requirements:
Review focus areas:
Iterating on Copilot PRs:
When you find issues in a Copilot PR, you can either:
Direct edits are often faster for small fixes such as typos, formatting, or tiny adjustments.
Best practices:
Once you receive a review from a human reviewer, you are obligated to respond promptly: typically within a week, unless there are extenuating circumstances. Address each of the reviewer’s comments individually. You aren’t obligated to agree with every comment; you are entitled to ask clarifying questions, raise objections, or ask to defer it to a later pull request.
When a reviewer leaves a comment on your code, respond to each one with exactly one of these:
Never ignore a review comment. Always reply—even if only to say you filed a follow-up issue.
Before requesting a new review round, resolve every comment thread whose underlying item is settled:
If you need the reviewer to weigh in or clarify a specific point, leave that thread open and state explicitly in your reply that you are awaiting their guidance.
Avoid closing a pull request and “starting over” on the same issue. Doing so disrupts the conversation between authors and reviewers, creates confusion, and leads to repeated work. Instead, keep iterating on the open pull request, where the review history stays attached to the code it discusses.