Sub topic 10
Write a clear title and description
This chapter assumes you have already pushed a feature branch to your fork and opened a pull request (PR), as covered in the previous chapter. It covers what you write in the PR's title and description, because reviewers read these first and they decide how quickly your change gets attention.
Why the text matters
A maintainer often reviews many PRs a day. They cannot tell why your change exists by looking at the diff alone. A clear title and description answer three questions before they open a single file:
- What does this change do?
- Why is it needed?
- How can I check that it works?
The title also becomes part of the project history. Many projects squash-merge PRs, which turns the PR title into the commit message on the default branch.
Write the title
Keep the title short, specific, and in the imperative mood, the same style as a commit message. Aim for about 50 to 70 characters. First check the project's contribution guidelines, because some projects require a prefix such as fix: or docs:.
| Weak title | Better title |
|---|---|
| Update README | Fix typo in README installation section |
| Bug fix | Handle empty input in parse_config |
| Changes from review | Add retry limit to HTTP client |
The weak titles describe nothing a reviewer can act on. The better ones name the area and the effect.
Structure the description
A good description is short and follows a predictable order. Many repositories provide a PR template, and GitHub fills it in automatically when you open the PR. If one exists, use it and complete every section. If not, use this layout:
## What
Corrects the misspelled `pip instal` command in the installation steps.
## Why
Copying the command from the README fails with "unknown command".
Fixes #142
## How I tested
Ran the corrected command in a fresh virtual environment. It
installed the package without errors.
## Notes
Only README.md changed. No code is affected.Link the issue
Writing Fixes #142, Closes #142, or Resolves #142 in the description links the PR to the issue. When the PR is merged into the default branch, GitHub closes the issue automatically. Use a plain See #142 or Related to #142 if the PR only partly addresses the issue and you do not want it closed.
Explain the why, not only the what
The diff already shows what changed. Use the description for what the diff cannot show: the problem, the reason you chose this approach, and any alternative you rejected. If the change is visible to users, add a before and after example or a screenshot.
Keep the scope honest
State what the PR does not do. If you noticed a related problem and left it alone, say so in one line. This stops reviewers from asking you to expand the PR, and it keeps the change focused. If the description needs the word "also" more than once, consider splitting the work into separate PRs.
Draft PRs and unfinished work
If you want early feedback on work that is not ready, open the PR as a draft. A draft signals that you do not expect a full review yet. Mark it "Ready for review" when you are done. Do not put "WIP" in the title as a substitute, since a draft is blocked from merging and a title is not.
Common mistakes
- Leaving the description empty or keeping the default text unedited.
- Writing a title that repeats the branch name, such as
fix-readme-typo. - Forgetting to link the issue, so it stays open after the merge.
- Pasting a long log of every commit instead of summarizing the change.
- Claiming the change is tested without saying how.
You can edit the title and description at any time after opening the PR. Update them if review feedback changes the approach, so the final text matches what gets merged.
Exercise
Your PR fixes issue #58 and you want GitHub to close that issue automatically when the PR is merged. What should you write in the description, and what should you write instead if the PR only fixes part of the issue?
Show answer
Write a closing keyword such as "Fixes #58" (or "Closes #58" or "Resolves #58") in the description. If the PR only partly addresses the issue, write "See #58" or "Related to #58" so the issue stays open after the merge.
Exercise
Rewrite the title "Changes" for a PR that adds input validation to the signup form.
Show answer
Any short, imperative, specific title works, for example "Validate email format in signup form".