Lesson 5 12 min

Writing Pull Requests That Get Merged

Learn to write pull requests that maintainers love to review — from clear descriptions and self-review to responding to feedback and getting your changes merged.

🔄 Recall Bridge: In the previous lesson, you mastered the Git workflow — fork, branch, commit, push. Your code is ready. Now let’s make sure your pull request gets the attention and merge it deserves.

A pull request is more than a code delivery mechanism — it’s a communication document. The best PRs make the reviewer’s job easy by explaining what, why, and how to verify. Maintainers who review dozens of PRs per week can tell immediately whether a contributor took the time to write a good description.

The PR Description Template

AI prompt to draft your PR description:

I’m opening a pull request. Here are my changes: [PASTE YOUR DIFF OR DESCRIBE]. The issue I’m addressing: [ISSUE DESCRIPTION OR NUMBER]. Draft a PR description with: (1) A clear title under 72 characters, (2) A summary of what changed and why, (3) How to test the change, (4) Any trade-offs or alternatives you considered. Match the style of recent merged PRs in this project.

PR description structure:

## What

Brief description of the change (1-2 sentences).

## Why

The problem this solves, linking to the issue.
Fixes #42.

## How

Technical approach — what you changed and why you chose this approach.

## Testing

Steps to verify the change works:
1. Run `npm test` — all existing tests pass
2. New test in `tests/parseDate.test.ts` covers timezone offsets
3. Manual test: `parseDate("2026-01-15T10:30:00+05:30")` returns correct Date

## Notes

Any context the reviewer should know — alternatives considered,
limitations, or follow-up work needed.

Self-Review Before Submitting

Before opening your PR, review your own changes as if you were the maintainer.

AI prompt for self-review:

Review this diff as if you’re a maintainer of this open source project. Check for: (1) Code that doesn’t match the project’s patterns or conventions, (2) Missing error handling that other similar code includes, (3) Edge cases that aren’t covered, (4) Unnecessary changes (whitespace, formatting) mixed in with functional changes, (5) Missing or inadequate test coverage. Be strict — it’s better to catch issues now than have a maintainer point them out.

Self-review checklist:

CheckWhy It Matters
Only relevant changesNo accidental whitespace or formatting diffs
Tests includedMost projects require tests for code changes
Follows project patternsNaming, error handling, code organization
No debugging artifactsRemove console.log, print statements, commented code
Documentation updatedIf you changed behavior, update docs to match
Commit history cleanSquash WIP commits into meaningful ones

Common Reasons PRs Get Rejected

ReasonPrevention
Didn’t read CONTRIBUTING.mdRead it before your first commit
PR is too largeKeep changes focused — one fix per PR
No testsAsk AI: “What tests should I write for this change?”
Doesn’t match project styleStudy patterns in existing code
Solves a problem no one hasOpen an issue first to discuss the approach
Mixed concernsSeparate formatting fixes from logic changes

Responding to Review Feedback

Review feedback is the most valuable part of open source contribution. Maintainers are teaching you their codebase and engineering standards for free.

Types of feedback and how to respond:

Feedback TypeExampleResponse
Style/convention“We use camelCase here”Fix immediately, thank for the note
Better approach“Use the existing helper”Refactor, explain you learned something
Clarification“Why did you change this?”Explain your reasoning in the PR comment
Design disagreement“I’d prefer a different approach”Discuss respectfully, defer to maintainer
Request for tests“Can you add a test for X?”Add the test, confirm it passes

AI prompt for understanding feedback:

A maintainer left this review comment on my PR: “[PASTE COMMENT]”. Help me: (1) Understand exactly what they’re asking for, (2) Draft a professional response, (3) Show me the code change they want. If I disagree with the suggestion, help me articulate why in a respectful way.

Quick Check: You open a PR and the maintainer responds: “Thanks for the contribution! Could you rebase on the latest main? There’s a conflict.” What do they want you to do? (Answer: Your PR branch has diverged from the project’s main branch. Run: git fetch upstream, git rebase upstream/main, resolve any conflicts, then force-push your branch with git push --force-with-lease origin your-branch. The --force-with-lease flag is safer than --force because it checks that you haven’t accidentally overwritten someone else’s changes.)

PR Size Guidelines

Smaller PRs get reviewed faster and merged more often:

PR SizeLines ChangedReview TimeMerge Rate
Small< 50 linesHours to daysHighest
Medium50-200 linesDays to a weekGood
Large200-500 linesWeeksLower
Massive500+ linesWeeks to neverLowest

If your change is large, consider splitting it into multiple PRs that can be reviewed independently.

Key Takeaways

  • A PR description is a communication document that should explain what changed, why, and how to verify — the code shows the what, but reviewers need the why and testing steps to evaluate your approach efficiently
  • Self-review your changes before submitting using AI as a strict reviewer — catching style mismatches, missing tests, and debugging artifacts before a maintainer points them out shows professionalism and respects the reviewer’s time
  • Respond to review feedback promptly and graciously — thank reviewers for catching issues, explain your reasoning when asked, and defer to maintainers on design decisions; how you handle feedback determines whether you’re welcomed back for future contributions

Up Next

In the next lesson, you’ll learn about contributions that don’t require writing application code — documentation improvements, issue triage, and translation work that every project needs.

Knowledge Check

1. You fixed a bug and want to open a PR. Your code change is 15 lines. You write a PR description: 'Fixed the bug in #42.' Is this sufficient?

2. A maintainer reviews your PR and leaves this comment: 'This works but could you use the existing validateInput helper instead of writing new validation logic? See src/utils/validate.ts.' How should you respond?

3. Your PR has been open for 2 weeks with no review. What should you do?

Answer all questions to check

Complete the quiz above first

Related Skills