DEV Community

Sungsoo Youn
Sungsoo Youn

Posted on

My Revenue Metric Was Reading One Product Out of Fifteen

A field note from the autonomous Claude Code agent I run every day on one Windows PC. The numbers come from its own ledgers, not from memory.

My agent has a goal with a number on it: sales revenue over the last 30 days. Every cycle it measures that number, and if the goal isn't met, it runs one experiment to move it.

For weeks the number was zero. That was believable. The products were new, traffic was low. The agent kept running experiments on the traffic side.

How it surfaced

While fixing an unrelated bug, the agent traced where a particular button click led. The click was part of the revenue measurement. It opened the sales page of one product, the main book, and read the total from there.

The store had 15 products. The experiments at the time were pointing people to a different one, the bundle.

If the bundle had sold, the goal metric would still have said zero.

Two metrics, two populations

The strange part: the purchase-count metric, measured by a different function, already summed all 15 products. The revenue metric, written earlier when there was only one product, never grew with the store. Both were called "the store". They meant different things.

The fix

  • Open all 15 product management pages by ID, not by clicking the first matching title in a list.
  • Sum them. If any page can't be read, the result is None (unknown), not the sum of the pages that happened to load. A partial sum looks exactly like a real low number.
  • Start a new cumulative key in the ledger. The daily revenue is the difference between today's cumulative total and yesterday's. Continuing the old one-product series with a 15-product total would have produced a fake jump on day one that looked like a sale.

Then it ran the new measurement for real. All 15 products: zero. The earlier zeros had been correct, just for the wrong reason.

The rule

For every number that drives a decision, write down its population: which items does this total include? Then compare that list across every dashboard that reports "the same" thing. Mine was checked when the code was written and never again, while the thing it described grew from one product to fifteen.

I later found the same shape in two more places: a goal description that still listed two sales channels eight days after a third had been added to the measuring code, and a day-over-day comparison that subtracted totals of different item sets. The fix was the same each time. Name the population, and refuse to compare numbers whose populations differ.


Want the whole system? The book has 11 chapters plus 4 ready-to-use templates (CLAUDE.md starter, memory files, auditor checklist, measurement guide) and a hands-on section for every chapter. It's $19 as a PDF: https://dbsoul.gumroad.com/l/autonomous-ai-agents-claude-code

Not sure yet? The first three chapters are free, same PDF format: https://dbsoul.gumroad.com/l/autonomous-ai-agents-claude-code-free-sample

Questions about the setup are welcome in the comments — I'll answer with what actually happened, not theory.

Top comments (0)