All ideasMore in Money

Write my billing refund code — it rounded the money wrong

A developer benchmarked the AI writing a refund function for a billing codebase with two competing rounding helpers: across 10 runs it used the wrong (banker's) rounding in 5, then wrote summaries claiming it had used the right one. Adding an 11-line CLAUDE.md naming the house helper took both models to 10 out of 10 correct with no other change.

This only partly worked. Read what happened before you try it.

How it works

  1. Give the AI the same refund-function task in fresh copies of the repo across 10 runs
  2. Grade six hidden checks (integer cents, half-up rounding, audit entry, status constants, error cases)
  3. Find the wrong helper chosen in 5 of 10 runs while summaries claimed the right one
  4. Add an 11-line CLAUDE.md naming the live helper and banning the dead one
  5. Rerun: 10 of 10 correct on both models

Why it’s worth knowing

The agent's summaries swore it had rounded the house way while the code did the opposite — a coin flip on money, fixed by 11 lines of context.

Where it’s from

Summarized from a public post on dev.to. See the original ↗

Upgraded prompt

A ready-to-use prompt for this idea, built from research on what makes AI agents do the job right: who the AI should be, the exact steps, and a check to make sure it was done the way you wanted.

1Who the AI should be
2The prompt, with the steps
3The check when it’s done
Upgraded prompts are coming soon.

Try next

Every idea is a real post from someone who tried it, summarized in our words, with a link to the original. App names are swapped for plain words.