Skip to main content

Pull requests are a form of documentation

3 min read
: Pull requests capture not just what changed, but who, why, and what alternatives were considered. Treat every PR as a time capsule for future contributors.

We often think of pull requests purely as a code review mechanism, but they are also an organic and natural form of documentation. I can’t count the number of times I’ve spelunked historic GitHub PRs to understand the context around a feature or product decision.

Pull requests capture not just what change was made, but who made it, why, and what alternatives were considered. They create a cross-linked web of context for others, and capture the discussion around the change, which is often an equally valuable technical artifact.

When I write a PR, I write it not just with the immediate reviewers in mind, but how it will read for outsiders down the line who might land on in from search results or a cross reference. Beyond documentation, PRs are a great place for your colleagues to ask the type of “dumb questions” that gives you the confidence to ship.

To that end, here are a few practices I follow when authoring pull requests to ensure I’m capturing sufficient context for myself and future contributors:

  • Descriptive title - Avoid the default Update FILE.md and instead use the title to capture the essence of the change in a way that is clear when scanning a list of PRs
  • Brief description of the change - Right up front, add a quick TL;DR describing the “what” of the change for others landing on the PR from search or a cross link so that they can quickly understand the change
  • Ensure the body describes the “why” - Equally essential as the “what” is the “why”. Why is this change being made? What problem does it solve? What alternatives were considered? What are the trade-offs? What are the risks? Be sure to include relevant links.
  • Enough context - So that others outside your team (or yourself years from now) can understand the change. Think of it as a time capsule or a message in a bottle to your future self and future contributors.
  • @mention responsible team - if not automatically requested via CODEOWNERS. Not only does this bring visibility to the PR, it also makes ownership clear by explicitly calling out the responsible team. Be sure to include why you’re @mentioning the team (what action is requested, if any) so that it’s surfaced in the notification.
  • CC or fixes related issues - to create a trail of breadcrumbs to improve discoverability and allow others to opt-in to additional context. As an added bonus, it will auto close the tracking issue for you.
  • Task lists - To reflect the current state of the PR - for example “TODO: add tests” and to capture process
  • Screenshots or animated GIFs - to illustrate UI changes without requiring other to spin up a dev environment
  • In-line documentation - Linking back to the PR from the code itself for especially complex or nuanced changes
  • Review your own PR - Comment in line to highlight specific changes for reviewers that you’re less confident on.
  • Discrete changes - Avoid bundling unrelated changes into a single PR which can hinder future discovery and understanding. Bonus use atomic, descriptive commits within the PR.

Yes, organic documentation takes slightly more time, but it’s less overhead than keeping static documentation up to date, and I promise you, it’s well worth it - your future self (and future coworkers) will thank you.

For even more tips, check out how to write the perfect pull request on the GitHub Blog.

Originally published May 19, 2023 View revision history
Share

More to explore

15 rules for communicating at GitHub

16 min read

How GitHub uses issues and chat for async communication — fifteen rules that eliminate the 'you had to be there' problem in corporate workflows.

Intro to GitHub for non-technical roles

10 min read

GitHub isn't just for developers. A practical guide for non-technical roles to follow along, collaborate, and track work with confidence.

Manage like an engineer

8 min read

If issues, pull requests, and project boards are the best way to develop software, should they not also be the best way to manage software development?

Why everything should have a URL

15 min read

When knowledge lives in people's heads and inboxes, it doesn't scale. Giving decisions and processes URLs makes context discoverable, async, and opt-in.

Leaders show their work

10 min read

Great leaders don't just communicate decisions—they explain how and why. Without that context, every decision sounds like "because I said so."

Ben Balter

I'm Ben Balter — I write here about engineering leadership, open source, and showing your work. I was the Director of Hubber Enablement at GitHub, where I helped thousands of GitHubbers do their best remote work. Before this role: Chief of Staff for Security, enterprise PM, and GitHub's first Government Evangelist. Before GitHub: attorney, Presidential Innovation Fellow, and member of the White House's first agile development team. More about the author →

Follow along: Bluesky LinkedIn

This page is open source Help improve this article on GitHub