Reproduce Before You Fix
Meera sends a message: "Kitty says I've paid way more than I have." The fastest-looking move is to paste that into the assistant with "fix the balances". It will change something plausible, and you will have no way to tell whether it fixed Meera's problem, a different problem, or nothing. Debugging starts before any fix.
The rule
No fix until you can make the bug happen on purpose.
A bug you can trigger whenever you like is half solved. To get there, pin down four things:
- Steps. Exactly what was done, in order.
- Expected. What should have happened, according to the spec.
- Actual. What happened instead, with real numbers.
- Smallest case. The shortest set of steps that still shows the bug. Strip away every expense, flatmate and click that does not matter.
Then catch the bug in a test. A failing test is the bug held still: the assistant can run it, you can see when it turns green, and it stays in the suite to stop the bug returning.
def test_editing_an_expense_replaces_it():
flat = make_flat(["Asha", "Ravi", "Meera"])
expense = add_expense(flat, paid_by="Meera", paise=30000, note="groceries")
edit_expense(flat, expense, paise=33000)
assert total_paid(flat, "Meera") == 33000Now your prompt can be precise: "This test fails: Meera's total is 63000 instead of 33000. Make it pass without editing the test."