Skip to content

Module 05 · Lesson 5.5

Writing a Reviewable Pull Request

35 minUpdated 19 Nov 2026Part of Implementing Changes in an Existing Codebase · Existing Project Engineering
On this page
  1. What you will learn
  2. What a pull request is and what a reviewer needs
  3. Worked scenario: the pull request for the minimum order value
  4. Keeping the diff small and the commits tidy
  5. Step-by-step workflow
  6. Using an assistant to draft the description
  7. Conclusion and your next step
  8. Reusable prompt
  9. Expected output
  10. Common errors and fixes
  11. Validation checklist
  12. Hands-on exercise
  13. Knowledge check
  14. Frequently asked questions
  15. References

Imagine handing a colleague a parcel with no label. They must open it, work out what is inside and decide if it is safe. A pull request without a good description is that parcel. A good description is the packing list: what is inside, why it was sent and what to check first.

In this lesson you write the pull request for the minimum order value change, using everything from this module: the criteria, the conventions, the assistant's diff and the flag. The example continues with the fictional Tidewell Wholesale, after Feature Flags and Staged Rollout. The company and data are invented.

What you will learn

  • Explain what a pull request is and what a reviewer needs from it.
  • Write a description with summary, criteria, scope, risk, test evidence, rollout and an assistant-use note.
  • Check your own diff for stray files and noise before asking anyone to review it.
  • Keep the change small, with commits that tell the story.

Before you start

What a pull request is and what a reviewer needs

A pull request is a request to merge your branch into the main code. Teammates read it, comment and approve it, or ask for changes. The name comes from asking the owner of the main code to 'pull' your work in. Some tools call it a merge request.

Branch
A separate line of work, like a copy of a document you edit without touching the original until the edit is approved.
Reviewer
A person who reads your change to find mistakes, risks and unclear parts before it is merged. A second pair of eyes, like a proofreader.
Commit
One saved step of work with a short message. A tidy commit is a single idea.
Test evidence
Proof that the checks were run and what they showed, pasted as real output, not a promise.

A reviewer has limited time and does not know what is in your head. They need to answer four questions fast. What does this do? Why? What could it break? How do I check it? Your description should answer them in that order.

Part of the descriptionThe question it answers
Title and summaryWhat is this, in one or two sentences?
Linked criteriaWhat was agreed, and who agreed it?
ScopeWhich files changed, and which are deliberately untouched?
RiskWhich callers and customers could be affected?
Test evidenceHow do I know it works?
Rollout and rollbackHow does it go live, and how do we undo it?
Assistant-use noteWhat was written by an assistant, and what did a person check?
Seven parts. Each one saves the reviewer a question.

Worked scenario: the pull request for the minimum order value

Here is the full description for the change. Every number in it comes from the real runs in this module. There are no screenshots, because the change adds a message and no new screen. The wording is an example. Adapt it to your team's template.

Markdownpull-request.md
Title: Add a minimum order value for Standard accounts (portal first, then EDI)

## Summary
Orders from Standard-band accounts with a goods total below £75.00 (before VAT and delivery) are rejected with the code below_minimum. The rule is OFF by default. It is switched on per order source with the setting MIN_ORDER_VALUE_SOURCES.

## Acceptance criteria
Agreed with the sales operations manager before coding. The full text is in docs/changes/min-order-value.txt.
- C1 Standard band, band compared ignoring case, below £75.00, from portal or edi: rejected. Tests: test_standard_order_below_minimum_is_rejected, test_lowercase_standard_band_is_treated_as_standard
- C2 Replay orders exempt. Test: test_replay_orders_are_exempt
- C3 Volume and Contract not affected. Test: test_volume_and_contract_bands_are_not_affected
- C4 Exactly £75.00 accepted. Test: test_exactly_the_minimum_is_accepted
- C5 Nothing saved or queued on rejection. Test: test_rejection_happens_before_anything_is_saved_or_queued
- C6 Portal message with the basket amount. Test: test_portal_message_shows_the_basket_amount
- C7 EDI rejections logged with the account code only. Test: test_edi_rejection_is_logged_with_the_account_code

## Scope
Changed (4 files):
     orders/messages.py            |   4 ++
     orders/services.py            |  29 +++++++++-
     tests/orders/test_services.py | 125 ++++++++++++++++++++++++++++++++++++++++++
     tidewell/settings/base.py     |   3 +
     4 files changed, 160 insertions(+), 1 deletion(-)
Not changed on purpose: api/views.py, dispatch/importers.py (the rule is in the shared create_order), invoicing/totals.py and orders/tasks.py.

## Risk
- Callers: the portal (source portal), the EDI importer (edi) and the replay command (replay) all reach create_order. Replay is exempt.
- EDI customers could see rejections they do not expect. EDI is therefore switched on in a second stage, after they are told.
- Departure from a convention: the new rule compares the band ignoring letter case. price_order compares it exactly. That is unchanged, and is a separate decision.
- Not decided here: with a £75.00 minimum, the £7.50 delivery charge for goods under £50.00 can only apply to replay orders. Raised with the finance systems contact as a separate question.

## Test evidence
The tests were written first and failed (11 failed, 5 passed) before the rule existed. After the change:
    ................                                                         [100%]
    16 passed in 0.07s
Timings vary between runs.

## Rollout and rollback
- Default: off. Merging changes nothing for customers.
- Stage 1: MIN_ORDER_VALUE_SOURCES = {"portal"}.
- Stage 2: {"portal", "edi"}, after EDI customers are told.
- Rollback: set it to an empty set and deploy. There is no data change to undo.
- Cleanup: remove the setting after stage 2 is calm, in a separate change.

## Assistant use
- Generated by an assistant: first version of the rule, the message and the EDI log line.
- Changed by me: the condition now checks that the order's source is in the setting and is not replay. The generated version was missing the replay exemption and ignored which source was enabled.
- Rejected: an edit to invoicing/totals.py that changed the band comparison. It is out of scope.
- Every hunk was read, and the full suite was run.

## Screenshots
None. The change adds a message and no new screen.

The description, as you would paste it into the pull request.

Read it as a reviewer would. In under two minutes you know the purpose, the agreed rules, the four files, the risks and the way back. You also see what is not decided here, which stops a long argument in the comments about the delivery charge.

Keeping the diff small and the commits tidy

A small diff is quicker to review and easier to undo. Before you ask for review, read your own diff the way a stranger would. Look for files you did not mean to change, leftover debugging lines and whitespace noise. These three commands take a minute. This is their real output for the finished change.

Reviewing your own change (real)Captured from a real run
$ git log --oneline main..1266115
1266115 Reject Standard orders below the minimum order value (off by default)

$ git diff --name-only main..1266115
orders/messages.py
orders/services.py
tests/orders/test_services.py
tidewell/settings/base.py

$ git diff --check main..1266115; echo "exit code: $?"
exit code: 0
  • git log --oneline main..1266115 lists the commits that the pull request would add. Here there is one, with a message that says what it does. The code 1266115 is that commit's short name in the scratch repository, so yours will differ.
  • git diff --name-only lists the files. Compare it with the edit list from your plan. These four match the plan exactly.
  • git diff --check looks for stray whitespace problems. An exit code of 0 and no text means it found none.

What to leave out

  • Formatting-only changes to lines you did not otherwise touch.
  • Renames and moves, which hide real changes inside a sea of edits.
  • Fixes for oddities you noticed. Write them as separate notes or tickets.
  • Generated files, logs and personal editor settings.

For commit messages, say what the commit does in the imperative, like 'Add' or 'Reject'. Some teams follow a naming style such as Conventional Commits. Follow whatever your project already uses.

Step-by-step workflow

  1. Step 1: Read your own diff first

    Run the three commands above. Remove stray files, debug lines and formatting noise. Check that every changed file is on your plan.

    What you should see: A clean diff that matches the edit list.

  2. Step 2: Run the full test suite

    Run everything, not only the new tests. Keep the output, because you will paste it.

    What you should see: A real test run to paste.

  3. Step 3: Write the summary and link the criteria

    Say what the change does in two sentences, then link each agreed criterion to the test that checks it.

    What you should see: A summary and a criteria table.

  4. Step 4: State the scope

    List the files changed and the files deliberately left alone. A reviewer who sees the second list trusts the first.

    What you should see: A scope section.

  5. Step 5: Name the risks and what you did not decide

    List the callers, the customers who could notice and the departures from conventions. List the open questions for others.

    What you should see: A risk section with owners for open questions.

  6. Step 6: Describe rollout and rollback

    Say what the default is, the stages, and how to undo the change. Be specific about the setting and the order.

    What you should see: A plan a stranger could follow at a bad moment.

  7. Step 7: Add the assistant-use note and ask for review

    State what was generated, changed and rejected. Then ask for review and say which part you most want checked.

    What you should see: A pull request that is ready for a reviewer.

From finished change to pull request
  1. Self-review

    Files, noise, checks

  2. Full tests

    Real output

  3. Description

    Scope, risk, evidence

  4. Rollout plan

    Stages and rollback

  5. Assistant note

    Generated, changed, rejected

Check first, describe second, ask third.

Using an assistant to draft the description

An assistant can turn your notes into a tidy description. It will also invent. It may claim that a test exists when none does, or write 'no risk' because that sounds reassuring. So give it facts, and check every claim against your own evidence.

  • Give it the diff stat, the real test output, your criteria and your assistant-use note. Do not give it secrets.
  • Tell it to use only the facts you pasted and to write 'not provided' for anything missing.
  • Check that each test name in the description exists in the file.
  • Check that the risks include callers it could not see, and add them yourself.
  • Remove vague phrases such as 'minor change' or 'low risk' unless you can show why.

Conclusion and your next step

You now have a full small-change routine. You planned with criteria, followed the existing conventions, directed an assistant on a narrow task, shipped behind a flag and wrote a pull request that a reviewer can judge in minutes. Each step kept the change small and the risk visible.

Your next step: apply the routine to a real change in your own repository for the module assignment. Then move on to the next module, Dependency Upgrades and Migrations, where the same habits help you move a system to newer libraries safely.

Further reading: the module overview Implementing Changes in an Existing Codebase, and the practical project Legacy Reporting Module Modernisation, where you can use these habits on a larger piece of work.

Reusable prompt

Pull request description drafter

Turns your diff stat, test output, criteria and assistant-use note into a pull request description, with gaps labelled and no invented claims.

I have finished a small change and need a pull request description. Use ONLY the facts below. If something is missing, write "not provided". Do not invent tests, callers, risks or results.

Change: minimum order value for Standard accounts in a Python service, switched on per source with a setting that is off by default.
Acceptance criteria (agreed with the sales operations manager): (paste C1 to C7)
Diff stat: (paste the output of git diff --stat)
Files deliberately not changed: api/views.py, dispatch/importers.py, invoicing/totals.py, orders/tasks.py
Test output: (paste the real output of the full test run)
Callers I know of: portal, edi importer, replay command
Open question for another team: the 7.50 delivery charge now only applies to replay orders
Rollout: stage 1 portal, stage 2 portal and edi after customers are told; rollback = empty set
Assistant use: (paste my note of what was generated, changed and rejected)

Write these sections: Summary, Acceptance criteria with the test that checks each, Scope, Risk, Test evidence, Rollout and rollback, Assistant use, Screenshots.
Keep each section short. Then list any claim you could not support from the facts above.
Show the reusable template

Replace each {{placeholder}} with your own details.

I have finished a small change and need a pull request description. Use ONLY the facts below. If something is missing, write "not provided". Do not invent tests, callers, risks or results.

Change: {{one_line_change}}
Acceptance criteria (agreed with {{role_who_agreed}}): {{criteria}}
Diff stat: {{git_diff_stat_output}}
Files deliberately not changed: {{files_left_alone}}
Test output: {{real_test_output}}
Callers I know of: {{callers}}
Open question for another team: {{separate_questions}}
Rollout: {{rollout_and_rollback}}
Assistant use: {{generated_changed_rejected_note}}

Write these sections: Summary, Acceptance criteria with the test that checks each, Scope, Risk, Test evidence, Rollout and rollback, Assistant use, Screenshots.
Keep each section short. Then list any claim you could not support from the facts above.

Expected output and limitations

A short description with the eight sections, built only from the facts you gave, plus a closing list of claims it could not support. It should reuse your test names and your numbers, not new ones.

Sample responseIllustrative — your output will differ
Title: Add a minimum order value for Standard accounts

Summary
Standard-band orders below 75.00 goods are rejected with below_minimum. Off by default; enabled per source by a setting.

Acceptance criteria
C1 ... C7, each with the test you named.

Scope
4 files changed (from your diff stat). Not changed: api/views.py, dispatch/importers.py, invoicing/totals.py, orders/tasks.py.

Risk
- Callers: portal, edi importer, replay command.
- Open question for another team: the 7.50 delivery charge now only applies to replay orders.

Test evidence
(your pasted output)

Rollout and rollback
Stage 1 portal, stage 2 portal and edi. Rollback: set the setting to an empty set.

Assistant use
(your note)

Screenshots
Not provided.

Claims I could not support
- None of the callers outside the three you listed were checked.

Limitations to keep in mind

  • It cannot run your tests, so it can only repeat the output you paste.
  • It may add reassuring words such as 'low risk' that you cannot back up. Remove them.
  • It does not know your team's template or review rules.
  • It cannot see callers you did not mention, so the risk section needs your own search.

Common errors and how to fix them

A description that only says 'adds minimum order rule'

Why it happens: The author knows the context and forgets the reviewer does not.

Fix: Add scope, risk, test evidence and rollback. Answer the four reviewer questions in order.

A pull request that mixes the change with cleanup

Why it happens: Tidying nearby code felt quicker than opening a second pull request.

Fix: Keep the cleanup for a separate pull request. Check git diff --name-only against your plan.

Test evidence that is a claim, not output

Why it happens: Writing 'all tests pass' is quicker than pasting a run.

Fix: Paste the real output of the full suite, and say that timings vary.

Validation checklist

Tick each item once you have confirmed it.

Hands-on exercise

Write the pull request for your own small change

Take the small change you planned, built and flagged in this module. Write the pull request description with all seven parts, and review your own diff first.

You will need

  • Your finished change on a branch, with tests.
  • Your acceptance criteria and the edit list from your plan.
  • Your assistant-use note, if you used an assistant.
  • The prompt template from this lesson, if your rules allow its use with your code.

Acceptance criteria

Your work is done when every one of these is true.

Hints (3)
  • Run git diff --name-only against your base branch and compare it with your edit list.
  • Write the rollback first. If it is hard to explain, the change may be too big.
  • Ask a colleague to read the description for two minutes and tell you what they still do not know.
Show a model answer

A strong answer starts with a plain summary that a non-expert can follow. Its criteria table links each agreed rule to a named test. The scope shows the real files and says what was left alone. The risk names callers and a departure from a convention, and records a question for someone else without trying to settle it. The test evidence is pasted output with a note that timings vary. The rollback is a single step. The assistant-use note says what was generated, changed and rejected. A weak answer says 'small change, tests pass', has no list of callers and gives the reviewer nothing to check.

Knowledge check

Choose an answer, then check it. Nothing is recorded — this is for you.

  1. 1.Which part of a pull request description best helps a reviewer judge risk?
    Show the answer and explanation

    Answer: B. Risk comes from who and what the change can reach, so naming callers and open questions lets the reviewer check them. The story of how you worked is tempting but does not show impact. 'Minor' is an opinion with no evidence, and the tool's name tells the reviewer nothing about risk.

  2. 2.You notice messy code next to your change while writing the pull request. What is best?
    Show the answer and explanation

    Answer: B. Unrelated edits enlarge the diff and mask the real change. Combining the two feels efficient but makes review harder and the change harder to undo. A vaguely named commit is worse because it hides the cleanup.

  3. 3.What counts as good test evidence in a description?
    Show the answer and explanation

    Answer: C. Real output shows which tests ran and how many passed, and the reviewer can compare it with their own run. A bare claim cannot be checked, and a picture of an icon does not say what was tested.

Frequently asked questions

What is a pull request?

It is a request to merge your branch of changes into the main code. Teammates read it, comment and approve it or ask for changes. It is the last check before your work goes in.

How long should a pull request description be?

As short as it can be while answering what, why, what could break, how to check and how to undo. One page is usually enough. Long stories belong elsewhere, such as in a design note.

Why does a small pull request matter?

Reviewers can read a small change carefully and spot mistakes. They skim large ones. A small change is also easier to undo if it causes trouble.

Should I tell reviewers I used an AI assistant?

Yes, if your team allows assistants. Say what it generated, what you changed and what you rejected. It tells reviewers where to look harder, and it shows that a person checked every line.

Written by
PromptFable Editorial
Last updated 19 Nov 2026
Review
Reviewed by Waseem Nadir, Technical Reviewer
Last reviewed 27 Nov 2026

References

Primary sources for the technical details in this lesson. Vendor platforms change — check the official page if anything here looks different from what you see.

PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.