PR title vs PR description — purpose differs
As engineers, we spend a surprising amount of time in Git, whether it's crafting commits, reviewing pull requests, or digging through history. Pull requests (PRs) are the lifeblood of collaborative development, and their effectiveness hinges on clear communication. Yet, a common pitfall is conflating the PR title with its description, treating them as interchangeable or giving one short shrift.
This isn't just a minor organizational nitpick; it's a fundamental misunderstanding that can lead to slower reviews, missed bugs, and a fragmented historical record. The PR title and description serve distinctly different purposes, and understanding this distinction is crucial for efficient and robust software development.
Let's break down why you need both, and how to make them work for you.
The PR Title: A Headline, Not a Novel
Think of your PR title as a newspaper headline. Its primary job is to grab attention and convey the essence of the story in as few words as possible. It's what people see first when scanning a list of open PRs, looking at a changelog, or browsing commit history.
What the Title Should Be:
- Concise and Scannable: Aim for brevity. It should be easily digestible at a glance.
- Actionable/Descriptive: Clearly state what the PR does. Is it adding a feature, fixing a bug, or refactoring code?
- Context-Rich (Briefly): Provide just enough context to understand the scope.
- Consistent: Often follows a team or project convention (e.g., Conventional Commits).
What the Title Shouldn't Be:
- A detailed explanation of why the change was made.
- A dump of implementation details.
- A placeholder like "WIP" or "Changes".
- Longer than a single, focused sentence.
Pitfalls of a Poor Title:
- Vague Titles: "Fix for bug" – Which bug? What system?
- Overly Long Titles: Makes lists unreadable and obscures the core message.
- Misleading Titles: Describes a small part of the change, not the whole.
Concrete Example:
Let's say you're adding pagination to an API endpoint.
Bad Title: pagination for users
Why it's bad: Too vague. Which endpoint? What kind of pagination?
Better Titles (following Conventional Commits):
* feat(api): Implement cursor-based pagination for /users endpoint
* Why it's good: feat indicates a new feature, (api) scopes it, and the description clearly states the what and where.
* fix(auth): Prevent session expiration on refresh token failure
* Why it's good: fix indicates a bug fix, (auth) scopes it, and the description clearly states the problem being solved.
Your title is for quick understanding, for tools that generate release notes, and for future you trying to recall the purpose of a change months later.
The PR Description: The Full Story
If the title is the headline, the description is the full article. This is where you provide all the necessary context, rationale, implementation details, and testing instructions for your reviewers. It's a critical piece of documentation for the present and the future.
The description is primarily for your reviewers. It helps them understand the scope, the impact, and the necessary steps to validate your changes without having to dive deep into the code or ask you a dozen questions.
What the Description Should Be:
- Comprehensive: Cover the what, why, how, how to test, and potential risks.
- Structured: Use headings, bullet points, and code blocks for readability.
- Contextual: Link to relevant issues, design documents, or discussions.
- Self-contained: A reviewer should ideally be able to understand and test the PR solely based on its description.
What the Description Shouldn't Be:
- A blank space.
- A repetition of the title.
- An instruction to "just look at the code."
- Outdated or incorrect information.
Key Sections to Include in a Robust PR Description:
- Summary: A slightly expanded version of your title, providing a bit more detail on the change.
- Context/Motivation: Why is this change necessary? What problem does it solve? Link to Jira tickets, GitHub issues, or design docs (e.g.,
JIRA-1234,GH-issue-567). - Implementation Details: How did you solve the problem? Highlight key architectural decisions, data model changes, new dependencies, or trade-offs made. This is where you can discuss specific files or functions if they are central to the change.
- Test Plan: Crucial for reviewers. How was this change tested by you? What steps should the reviewer take to verify it? Include specific commands, API endpoints, or UI navigation steps.
- Risk Assessment/Edge Cases: What could go wrong? What are the potential impacts on other parts of the system? Are there any known limitations or performance considerations?
- **Screenshots/D