Debug existing code · 60 minutes · use any AI tool

Practice round 2: The March billing report

Debug an invoice totals module that finance says does not match the ledger. Finding the real cause of a bug report, using the rules the code is meant to follow, and proving the fix.

Time
60 minutes
Task
Debug existing code
Language
Python 3.10 or newer, standard library only
In the zip
9 files of existing code, 7 visible tests, 7 extra checks

Download invoices.zip 12.1 KB

The brief

Finance says the March billing report does not match the ledger. A few customers' amounts are off by a cent or two, and the March total is off as well. They need a corrected report before the month end close.

Find and fix what is wrong in the invoices package so that the report matches the ledger. Keep the public functions and their arguments; the report script and two other teams call them. Returning Decimal amounts is fine.

Write down what you found and what you changed in NOTES.md as you go, as you would in a pull request description. If you are not sure whether something is a bug, say what you would ask finance.

Ground rules

  • Set a timer for 60 minutes before you open your AI tool, and stop when it rings.
  • Use your own agent (Claude Code, Codex, Cursor or any other). Work the way you would at work.
  • Python 3.10 or newer, standard library only. No installs.
  • Do not open the checks folder until your timer has stopped.

Running it

python -m unittest
python -m invoices.report data/march_2026.csv 2026 3

Some tests in tests/test_totals.py fail on the code as it stands. Those failures are the part of the bug report finance could pin down.

The existing code

  • invoices/totals.py line, document, customer and monthly totals
  • invoices/money.py rounding and formatting
  • invoices/tax.py tax rates
  • invoices/models.py documents and line items
  • invoices/loader.py reads the billing export
  • invoices/report.py prints the report
  • docs/FINANCE_RULES.md the rules the ledger follows
  • data/march_2026.csv the March export

When the timer stops

Run the extra checks first. Then start a new session of your agent in the same folder and paste the review prompt from REVIEW.md, filling in the path to the transcript of the session you just finished. The full rubric descriptions are in the file; this is the shape of the prompt:

You are reviewing my coding session from a 60 minute practice round. The brief is in README.md. Read the
session transcript at <path to this session's transcript> and judge how I worked, not how the code looks.

For each of the five dimensions below:
1. Quote two or three exact lines from my prompts, or name exact actions (a rejected edit, a command I ran, a
   file I opened), as evidence. Give the time or position in the transcript for each.
2. Say whether the evidence reads as strong, middling or weak, using the descriptions below, and why.
3. If the transcript does not show enough to judge, say "not enough evidence" instead of guessing.

1. Breaking the problem down: Turning a loose brief into a plan you own, then handing the AI one well defined step at a time.
2. Context given to the AI: Supplying the facts the AI cannot guess: the constraint in a config file, the rule in a document, how the system is deployed, the helper that already exists.
3. Verifying output: Checking that what the AI produced is right before relying on it.
4. Correcting the AI: Noticing when the AI goes wrong, stopping it, and steering it back precisely, or doing the small fix by hand.
5. Tradeoff reasoning: Naming the options, choosing one for a reason tied to this system, and saying what was given up.

Then list the three moments that most helped me and the three that most cost me, each with its quote, and one
thing to do differently in the next round. Do not invent quotes. If you cannot find a line, say so. Do not give
an overall score.

For counts such as prompts, rejected edits and test runs, drop the transcript on the transcript stats tool. It reads the file in your browser and uploads nothing.

Every file in the zip
  • openbook_invoices/README.md
  • openbook_invoices/REVIEW.md
  • openbook_invoices/checks/__init__.py
  • openbook_invoices/checks/check_totals.py
  • openbook_invoices/data/march_2026.csv
  • openbook_invoices/docs/FINANCE_RULES.md
  • openbook_invoices/invoices/__init__.py
  • openbook_invoices/invoices/loader.py
  • openbook_invoices/invoices/models.py
  • openbook_invoices/invoices/money.py
  • openbook_invoices/invoices/report.py
  • openbook_invoices/invoices/tax.py
  • openbook_invoices/invoices/totals.py
  • openbook_invoices/tests/__init__.py
  • openbook_invoices/tests/test_totals.py