Module 05 · Lesson 5.1
Planning a Small Change
On this page
- What you will learn
- Why a small change needs a plan
- Worked scenario: the minimum order value request
- Finding the smallest set of edits
- Step-by-step workflow
- Turning acceptance criteria into tests first
- Using an assistant to plan, not to decide
- Conclusion and your next step
- Reusable prompt
- Expected output
- Common errors and fixes
- Validation checklist
- Hands-on exercise
- Knowledge check
- Frequently asked questions
- References
Imagine asking a builder to 'make the kitchen better'. Without a plan, they might move the sink, repaint the walls and burst a pipe. A change to software you did not write goes wrong in the same way. A short, clear plan keeps the work small and safe.
In this lesson you turn a vague request into acceptance criteria, settle the open questions with the right people, and list the smallest set of edits that does the job. You continue with the fictional Tidewell Wholesale and the minimum order value that Mapping Entry Points and Data Flow prepared. The company, roles and data are invented.
What you will learn
- Turn a vague request into acceptance criteria written as Given, When, Then.
- Settle open questions with the right person before you write any code.
- List the smallest set of edits that meets the criteria, and the files you will not touch.
- Write one test for each criterion and watch it fail before you build.
Before you start
- You can run tests and read a diff, as practised in Reviewing AI-Proposed Refactorings.
- Your notes on entry points and callers from Mapping Entry Points and Data Flow.
- A small change request you may work on, real or invented.
Why a small change needs a plan
Small changes feel safe, so people skip the plan. But in an existing codebase the risk is rarely the lines you write. It is the code around them: other callers, old customers and habits nobody wrote down. A plan is how you find those before they find you.
- Acceptance criteria
- A short list of statements that must be true when the change is done. They work like a delivery note: you tick each line against what actually arrived.
- Given, When, Then
- A way to write one criterion in three parts. Given is the starting situation, When is what happens, Then is what must follow. It reads like a tiny story with one clear ending.
- Scope
- The edge of the job. What is inside it gets done now. What is outside it is noted and left alone, like a fence round a garden bed.
- Diff
- A marked-up view of exactly which lines changed, like 'track changes' in a word processor. Reviewers read the diff, so a small diff is a kind gift to them.
The goal of planning is simple. You want to know, before you open an editor, what 'done' means, who agreed to it, and which files you expect to change. If the answer to any of these is 'I will see', stop and ask.
Worked scenario: the minimum order value request
The request reaches you as one sentence from the sales operations manager: 'Trade customers on the Standard price band should not be able to place tiny orders. Add a minimum order value.' It sounds clear. It is not. You can build at least four different things from it.
So you list your questions and take them to the people who can decide. You do not guess, and you do not ask the assistant to guess. Here is what comes back.
| Question | Who decides | Answer |
|---|---|---|
| How much? | Sales operations manager | £75.00 of goods, before VAT and delivery. |
| Which customers? | Sales operations manager | Standard band only. Volume and Contract are not affected. |
| Some old records say 'standard' in lower case. Do they count? | Sales operations manager | Yes. Compare the band ignoring letter case, because those are the same customers. |
| Which routes in? | Sales operations manager and support engineer | Portal and EDI are checked. Support's replay command is exempt, because it re-creates orders that already exist. |
| What does the customer see? | Sales operations manager | A fixed message that shows their basket total. |
| How will support spot EDI rejections? | Support engineer | A log line with the account code and no personal data. |
| Should the old £7.50 delivery charge change? | Finance systems contact | Not in this change. Raised as a separate question. |
Now you write the answers down as acceptance criteria, in Given, When, Then form. This text goes into the ticket and, later, into the pull request. The sales operations manager reads it and says 'yes, that is what I meant'. That moment is the real start of the work.
C1 Given a Standard-band customer (band compared ignoring letter case),
When an order from the portal or EDI has a goods total below £75.00,
Then it is rejected with the code below_minimum.
C2 Given a Standard-band customer and a goods total below £75.00,
When support replays the order (source replay),
Then it is accepted. Replay is exempt.
C3 Given a Volume or Contract customer,
When the goods total is below £75.00,
Then the order is accepted. The rule does not apply.
C4 Given a Standard customer,
When the goods total is exactly £75.00,
Then the order is accepted.
C5 When an order is rejected,
Then nothing is saved and no confirmation is queued.
C6 When the portal rejects an order,
Then the message reads: Orders on a Standard account must be at least
£75.00 before VAT and delivery. Your basket is £62.40. (basket filled in)
C7 When an EDI order is rejected,
Then the log records the account code and no personal data.The agreed criteria. 'Goods total' means before VAT and delivery.
Finding the smallest set of edits
With criteria agreed, ask one question: what is the least I must change to make all seven true? Start from the call path you traced. Every order, from every route, passes through create_order in orders/services.py. That is the one place where one rule reaches all callers.
| Edit | File | Why this place |
|---|---|---|
| Add the rule | orders/services.py | After price_order (the goods total exists) and before the save (nothing written yet). |
| Add the customer message | orders/messages.py | Messages already live here as constants. |
| Add a switch for the rule | tidewell/settings/base.py | So the rule can be turned on in stages. A later lesson covers this. |
| Add tests | tests/orders/test_services.py | One test per criterion, next to the existing order tests. |
| Left alone | Why |
|---|---|
api/views.py | The rule lives in shared code, so the portal view needs no change. |
dispatch/importers.py | The same reason. EDI orders reach the rule through create_order. |
invoicing/totals.py | Its lower-case band oddity is a separate decision. This change compares the band by itself. |
orders/tasks.py | The confirmation task is never reached for a rejected order. |
Spot the interaction, then raise it separately
Standard customers pay a £7.50 delivery charge when their goods are under £50.00. With a £75.00 minimum, a portal or EDI order under £50.00 can no longer exist. So that charge can only apply to replay orders. Here is a real run of the stand-in pricing code for a £40.00 order.
{'goods': Decimal('40.00'), 'delivery': Decimal('7.50')}
{'goods': Decimal('40.00'), 'delivery': Decimal('7.50')}The charge still exists in the pricing code. Whether to remove it is a money decision, so it belongs to the finance systems contact. You write it down as a separate question and do not touch it in this change. A small diff stays small because you leave such things alone.
Step-by-step workflow
Step 1: Restate the request in your own words
Write one or two sentences. Then list every word that could mean two things, such as 'order value', 'customer' or 'minimum'.
What you should see: A short statement of the request and a list of vague words.
Step 2: Collect questions and take them to the deciders
Group your questions by who can answer them: sales, finance, support, the platform team. Ask in writing so that the answers can be pasted into the ticket.
What you should see: A table of questions, deciders and answers.
Step 3: Write the acceptance criteria
Use Given, When, Then. One behaviour per criterion. Include the edges: exactly at the limit, the exempt routes, and the cases the rule must not touch.
What you should see: A numbered list of criteria the requester has agreed.
Step 4: Find every caller and side effect
Use your call-path notes. List each route into the code you will change, and each side effect, such as emails or queued jobs, that your change could trigger or skip.
What you should see: A caller list and a note of what must not happen.
Step 5: List the smallest set of edits
For each criterion, name the file and place where it will be made true. Also list the files you expect to leave alone.
What you should see: An edit table and a left-alone table.
Step 6: Write one test per criterion and watch each fail
Write the tests before the code. Run them. They should fail because the feature does not exist yet. A test you never saw fail may not test anything.
What you should see: A red test run that names every criterion.
Step 7: Park the side questions
Write down anything you noticed but will not fix here, such as the delivery charge. Give each a person to ask.
What you should see: A short 'raise separately' list.
- Request
One vague sentence
- Questions
Asked of the deciders
- Criteria
Given, When, Then
- Edit list
Files in and out
- Failing tests
One per criterion
Each stage produces something you can show to another person.
Turning acceptance criteria into tests first
Tests are the criteria in a form a computer can check. Each criterion gets one test, named so that a reader can match it to the list. This lesson shows a simplified version of the service's code, so you can run it without Django. The tests use pytest, a popular Python test tool.
| Criterion | Test name |
|---|---|
| C1 | test_standard_order_below_minimum_is_rejected (portal and edi), test_lowercase_standard_band_is_treated_as_standard |
| C2 | test_replay_orders_are_exempt |
| C3 | test_volume_and_contract_bands_are_not_affected |
| C4 | test_exactly_the_minimum_is_accepted |
| C5 | test_rejection_happens_before_anything_is_saved_or_queued |
| C6 | test_portal_message_shows_the_basket_amount |
| C7 | test_edi_rejection_is_logged_with_the_account_code |
@pytest.fixture
def low_basket(make_line):
"""Goods total 62.40: 52 packs at 1.20, below the 75.00 minimum."""
return [make_line(qty=52, unit_price="1.20")]
def test_exactly_the_minimum_is_accepted(make_customer, make_line, store, stock, rule_on):
exactly_75 = [make_line(qty=60, unit_price="1.25")]
create_order(
make_customer(), exactly_75, "portal",
stock=stock, store=store, min_order_sources=rule_on,
)
assert len(store.saved) == 1Excerpts: a helper fixture and one test. They are not next to each other in the file.
low_basketbuilds a basket worth £62.40, which is under the minimum. Tests that need a small basket share it.make_customerandmake_lineare existing fixtures. A fixture is a helper that pytest builds for a test, like a prepared tray of ingredients.min_order_sources=rule_onsays the rule is switched on for the portal and EDI. A later lesson explains the switch.exactly_75is 60 packs at £1.25. The test proves the edge: exactly £75.00 is accepted, not rejected.
Before writing any rule code, run the tests. They must fail, and the failure must be about the missing feature.
....FFFFFFFFFF.F [100%]
=========================== short test summary info ===========================
FAILED tests/orders/test_services.py::test_standard_order_below_minimum_is_rejected[portal]
FAILED tests/orders/test_services.py::test_standard_order_below_minimum_is_rejected[edi]
FAILED tests/orders/test_services.py::test_lowercase_standard_band_is_treated_as_standard
FAILED tests/orders/test_services.py::test_replay_orders_are_exempt - TypeErr...
FAILED tests/orders/test_services.py::test_volume_and_contract_bands_are_not_affected[Volume]
FAILED tests/orders/test_services.py::test_volume_and_contract_bands_are_not_affected[Contract]
FAILED tests/orders/test_services.py::test_exactly_the_minimum_is_accepted - ...
FAILED tests/orders/test_services.py::test_rejection_happens_before_anything_is_saved_or_queued
FAILED tests/orders/test_services.py::test_portal_message_shows_the_basket_amount
FAILED tests/orders/test_services.py::test_edi_rejection_is_logged_with_the_account_code
FAILED tests/orders/test_services.py::test_stage_one_enables_the_portal_only
11 failed, 5 passed in 0.07sEleven tests fail and five pass. The five that pass are the two old order tests, the two old pricing tests and the 'rule is off' test. Run times differ from machine to machine, so your timing will differ. Each failing test fails because create_order does not yet accept the new argument, which is what we expect.
How big should the result be?
When the change is finished, compare it to the plan. This is the real git diff --stat from the scratch repository for the whole change.
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(-)There are four files, exactly as planned. Of 160 added lines, 125 are tests. The other 35 are the rule, its message and the setting. If your diff has a fifth file you did not plan, find out why before you ask anyone to review it.
Using an assistant to plan, not to decide
An assistant is good at asking questions you forgot and at turning notes into Given, When, Then. It is poor at business decisions, because it has not met your sales operations manager. Treat its draft criteria as a first draft to show to the deciders.
- Paste the request and the real source of the function you plan to change. Do not paste secrets or customer data. See Sharing Code with an AI Assistant Safely.
- Ask for questions first, then criteria. Do not ask it to write code yet.
- Ask it to mark each criterion as 'stated in the request' or 'my assumption'. Every assumption is a question for a person.
- Check each proposed file against your call path. If it names a file you have not seen, open it before you agree.
Conclusion and your next step
A small change is safe when it is planned. You asked the deciders, wrote seven criteria, found the one shared place for the rule, listed the files to leave alone, and made every criterion a failing test. You also parked a side question about delivery charges instead of mixing it in.
Your next step: the plan says the new code must look like the code around it. Continue with Following Existing Conventions to see how create_order already rejects orders, and how to extend that pattern.
Further reading: the module overview Implementing Changes in an Existing Codebase shows how the five lessons fit together. The blog post Golden Master Testing: Safely Refactoring Legacy Code Without Specs explains another way to pin behaviour before you change it.
Reusable prompt
Change-request clarifier
Turns a vague request and the code you will change into questions, draft acceptance criteria and a list of files, with assumptions labelled.
I am planning a small change to an existing Python and Django service. I will NOT write code in this conversation. Act as a careful analyst, not as the decision maker.
Request, as received: "Trade customers on the Standard price band should not be able to place tiny orders. Add a minimum order value."
What I already know from my call-path notes:
- Orders reach create_order(customer, lines, source) in orders/services.py from three callers: the portal (source="portal"), an EDI importer (source="edi") and a support replay command (source="replay").
- create_order checks stock, calls price_order, then saves and queues a confirmation email.
Below is the source of create_order. Use ONLY this code.
(paste source)
Produce:
1. A list of questions I must ask people before coding, each with the role who should answer it.
2. Draft acceptance criteria in Given, When, Then form. Label each one "stated in the request" or "my assumption".
3. The smallest set of edits that would meet the criteria: file, place in the file, and reason. Also list files I should NOT touch, and why.
4. Anything you noticed that looks like a separate problem. Do not fix it. Just list it.
5. Anything you could not know from the code I pasted.Show the reusable template
Replace each {{placeholder}} with your own details.
I am planning a small change to an existing {{language}} service. I will NOT write code in this conversation. Act as a careful analyst, not as the decision maker.
Request, as received: "{{request}}"
What I already know from my call-path notes:
{{callers_and_side_effects}}
Below is the source of {{function_to_change}}. Use ONLY this code.
{{source}}
Produce:
1. A list of questions I must ask people before coding, each with the role who should answer it.
2. Draft acceptance criteria in Given, When, Then form. Label each one "stated in the request" or "my assumption".
3. The smallest set of edits that would meet the criteria: file, place in the file, and reason. Also list files I should NOT touch, and why.
4. Anything you noticed that looks like a separate problem. Do not fix it. Just list it.
5. Anything you could not know from the code I pasted.Expected output and limitations
Four parts: a list of questions with a role against each, draft criteria with assumptions labelled, an edit list with a left-alone list, and a short list of separate problems. A good answer says what it could not know.
Questions
- What is the minimum, and is it before or after VAT and delivery? (sales operations manager)
- Does it apply to the EDI importer and to the support replay command? (sales operations manager, support engineer)
- Does the band comparison ignore letter case? (sales operations manager)
Draft criteria
- C1 (assumption): Given a Standard customer, When the goods total is below the minimum, Then the order is rejected.
- C2 (assumption): Replay orders are accepted. Needs a decision.
- C3 (stated in the request): Only the Standard band is affected.
Smallest set of edits
- orders/services.py, after price_order and before the save: add the check.
- orders/messages.py: add the customer message beside the existing ones.
- tests: one test per criterion.
- Do not touch api/views.py: all callers reach the rule through create_order.
Separate problem
- price_order compares the band with "Standard" exactly. Records stored as "standard" would not match. Decide separately.
Could not know
- What the portal does with a rejection. The view was not pasted.Limitations to keep in mind
- The criteria are guesses until the deciders confirm them.
- The assistant only sees the code you paste. It cannot find callers elsewhere in the repository.
- A tidy list of files is not evidence. Check each one against your call-path notes.
- The answer will not know your team's rules for tickets, reviews or release dates.
Common errors and how to fix them
Starting to code from a one-line request
Why it happens: The request looked obvious, so nobody asked what 'minimum' or 'order value' meant.
Fix: Write questions first, take them to the deciders, and get the answers in writing before you open the editor.
Putting the rule in the portal view only
Why it happens: The portal was the first caller you found, so the rule was added there.
Fix: Search for every caller of the function you will change. Put the rule in the shared code, or add it to each caller on purpose.
Fixing a nearby oddity in the same change
Why it happens: The old £7.50 delivery rule looked wrong, and it was easy to edit while you were in the file.
Fix: Write the oddity down as a separate question for its owner. Keep this change to the agreed criteria.
Validation checklist
Tick each item once you have confirmed it.
Hands-on exercise
Plan a small change in your own repository
Choose a small change request in a repository you may work on, such as a validation rule. Write the questions, the acceptance criteria, the edit list and the left-alone list. Then write the failing tests, but not the code.
You will need
- A repository you are allowed to read and change, or a practice copy.
- A change request, real or invented, such as 'reject a comment longer than 500 characters'.
- Your call-path notes for the code you will touch, if you have them.
- 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)
- If you have no one to ask, write your question and your assumption side by side, and mark the assumption clearly.
- Search for the function name followed by an open bracket to find callers.
- Name each test after its criterion, so a reader can match them without help.
Show a model answer
A strong answer starts with a request that has two possible meanings and shows the question that separates them. Its criteria are short and each has one clear ending. It names a shared place for the rule rather than the first caller found. It lists at least one file it will not touch and one side problem it noticed but did not fix. The failing test run proves the tests check something: they fail for the right reason, and each name matches a criterion. A weak answer lists the criteria as general wishes, such as 'it should work for all customers', and has no tests, or tests that were never seen to fail.
Knowledge check
Choose an answer, then check it. Nothing is recorded — this is for you.
Show the answer and explanation
Answer: B. The words 'minimum' and 'order value' each have several meanings, and only the business owner can choose one. Coding first is tempting because the request seems clear. The assistant and a web search can give you a number, but neither can decide what your company means.
Show the answer and explanation
Answer: B. A failing run proves that the test notices the missing feature, so a later pass means something. Speed has nothing to do with it. A reviewer's habit is a reason to comply, not the reason the step matters.
Show the answer and explanation
Answer: B. The charge is a money rule that finance owns, and it is outside the agreed criteria. Removing it quietly enlarges the diff and hides a decision inside a change about something else. The assistant's opinion does not give you authority over it.
Frequently asked questions
What are acceptance criteria in simple words?
They are a short list of things that must be true when a change is finished. Think of a delivery note that you tick off against the boxes. If every line is true, the work is done.
How small is a 'small change'?
Small enough that one person can review it in a sitting and explain every line. If you cannot say why a file is in the diff, it probably does not belong. Split big ideas into several small changes.
Do I really need to ask people if the request seems clear?
Yes, because a request that looks clear often hides a choice, such as whether a limit includes tax. A five-minute question is cheaper than a week of rework. Write the answer down so everyone remembers the same thing.
Can an assistant write the acceptance criteria for me?
It can draft them and spot gaps. It cannot decide what the business wants. Show its draft to the deciders and keep only what they confirm.
- 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.
- pytest documentation(opens in a new tab)
pytest · Official documentation · The test tool used in this lesson. Check the current version's guide for installation and options.
- How to use fixtures - pytest documentation(opens in a new tab)
pytest · Official documentation · How fixtures such as make_customer are defined and shared.
- Small CLs | eng-practices(opens in a new tab)
Google · One team's reasons for keeping changes small. Useful to read as one view among several.
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.