ChatFin/Pick the Accounts to Flag in Flux, With Claude

Pick the Accounts to Flag in Flux, With Claude

By Ashok ManthenaPublished 5 Nov 20266 min read
You need
A trial balance with August 2026, September 2026 and September 2025, as CSV
Tested with
Claude Sonnet 5.5, made-up data, 5 Nov 2026
Result
All 59 accounts the rule settles match the key, both runs

60 accounts, 15 built on the edges

On 5 Nov 2026 we gave Claude a rule with two limits, a change of more than 10 percent and more than 5,000.00.

The rule: more than 10 percent and more than 5,000.00

Flag an account when September 2026 is more than 10 percent and more than 5,000.00 away from August 2026, in either direction. The percent is measured against August.

Fifteen of the 60 accounts were built on the boundaries: a change of exactly 10 percent, exactly 5,000.00 and one cent over it, an August of zero, a sign that flips, and accounts that pass one limit and fail the other. The figures are made up.

trial_balance_activity.csv and flux_flags.csv

The script Claude wrote reads trial_balance_activity.csv and writes flux_flags.csv.

Columns in trial_balance_activity.csv
ColumnUsed for
account, account_name, typeRow key and account type
aug_2026, sep_2026The two months compared. Revenue is a negative number
sep_2025Context only. The rule does not use it

Ask Claude for a plan first

Attach your own export with the columns above and paste this.

Prompt 1: plan
I run the monthly flux review for our controller. I have one file, trial_balance_activity.csv, with 60 accounts and these columns: account, account_name, type, aug_2026, sep_2026 and sep_2025. Revenue accounts carry credit balances as negative numbers.

Before anyone writes commentary I need the list of accounts that get commentary. My rule: flag an account when September 2026 is more than 10 percent and more than 5,000.00 away from August 2026, in either direction. The percent is measured against August. The sep_2025 column is there for context.

Do not write code yet. Break the job into numbered steps. For each step say what could go wrong. Then list anything in my rule that is unclear.

Run 1 gave eight steps and run 2 gave seven, each with eight unclear points, and both named the accounts that sit on a limit.

Run 1 listed Rent (exactly 10.00 percent), Training and development (exactly -10.00 percent) and Interest income (exactly 5,000.00), and said a float calculation could flag or skip them at random. Five of the eight needed our answer:

  • An August of zero. The percent is undefined. Run 1 asked whether Postage, which moves from 0 to 6,200.00, is flagged. Run 2 said it would flag it, since any move off zero is an infinite percent, and left the call to us.
  • Sign flips. Freight out and Translation services start negative and end positive. Both runs measured the percent against the size of August.
  • Whether "more than" is strict, and whether both limits must hold. Both read it as strict and as "and".
  • Rounding. Run 1 asked whether the tests use exact figures or figures rounded to the cent, and cited Relocation, which passes the dollar limit by one cent. Run 2 asked whether the percent is tested as displayed (10.0) or exact.
  • Whether September 2025 plays any part. Both treated it as context only, and run 1 asked whether a year-over-year swing should flag anything.

We left every one of these open and told Claude to use its plan.

Ask Claude to build it

Prompt 2: build and run
Good. Use that plan. Write one Python script, standard library only, that reads the file and writes flux_flags.csv with one row per account: account, account_name, aug_2026, sep_2026, change, pct_change, flagged (Y or N). Use exact decimal arithmetic. Never change my file. Run it, then show me every flagged account with its change and percent, and the number flagged.

Claude Sonnet 5.5 (claude-sonnet-5-5) answered both prompts as two turns of one Claude Code session with the CSV in a working folder, and again in a new session.

Run 1's script is 64 lines of Python and run 2's is 47, both standard library only with money as Decimal. Each flagged 17 of the 60 accounts, wrote 60 rows, and said it had used its own defaults for the unanswered questions.

Eight accounts on or near a limit
AccountAugustSeptemberChangePercent changeFlagWhy
6160 Rent80,000.5088,000.558,000.0510.00NoExactly 10 percent is not more than 10 percent
7010 Interest income30,000.0035,000.005,000.0016.67NoExactly 5,000.00 is not more than 5,000.00
6310 Relocation30,000.0035,000.015,000.0116.67YesOne cent over
6460 R&D tools100,000.00110,010.0010,010.0010.01YesOne hundredth of a percent over
6190 Training70,000.0063,000.00-7,000.00-10.00NoDown exactly 10 percent
6230 Freight out-2,000.001,500.003,500.00175.00NoSign flips, but only 3,500
6300 Translation-8,000.006,000.0014,000.00175.00YesSign flips, 14,000 apart
6070 Postage0.006,200.006,200.00blankYesAugust is zero. The rule does not say

Both runs flagged Postage, the only account of the 60 where the rule gives no answer. Each wrote its percent as blank and flagged it on the dollar limit alone.

Checks: a key, 26 edge files, 3,000 random accounts

1. A key kept out of the working folder

Our own code applied the rule to all 60 accounts with exact decimals, and kept the key out of the folder we told Claude to work in.

We checked the change on every account, the percent on every account with a non-zero August, and the flag on the 59 accounts the rule settles. Neither run differed from the key anywhere, and both flagged the same 17.

The key is our reading of the rule, with the 15 boundary accounts chosen by us.

2. Edge cases

26 small files went through both scripts.

Edge case results
What we sentWhat happened
The exact 10 percent row, then 10.01 percentNo, then yes. Both runs
A change of 5,000.00, then 5,000.01No, then yes
August 0.00 and September 5,000.00; then 5,000.01; then 3,000.00No, yes, no. The percent is left blank
August 0.01 and September 5,000.02Yes, with a percent of 50,000,100.00
August -8,000.00 and September 6,000.00Yes at 175 percent, so the percent is taken against the size of August
A credit balance from -400,000.00 to -452,000.00Yes, -13.00 percent
Amounts typed 1e4 and 2e4Read as 10,000 and 20,000
An amount in quotes with a thousands separator, "80,000.00", or n/a in SeptemberBoth scripts stop with a Python error and write nothing. The error does not say which account
A blank AugustRun 1 stops with the same Python error. Run 2 stops with a plain message, blank aug_2026 for account 1
The same account number twiceBoth stop, each with a message about the duplicate

In Python float arithmetic the change on the Rent row is 8,000.050000000003 and the percent is 10.000000000000004, so a float version flags Rent. Both of Claude's scripts used exact decimals and left Rent off.

3. 3,000 random accounts against our own exact version

We made 3,000 random accounts. Of them, 869 sit within 0.06 points of the 10 percent line, 587 within 1.00 of the 5,000 line, and 145 have an August of zero, 65 of those with a September over 5,000.

Of the 2,855 accounts with a non-zero August, a float version of the rule would have flagged the wrong account on 5. Both scripts matched our exact version on every one of them.

They flagged all 65 August-zero accounts over 5,000, as they did Postage. The key and both scripts apply the same one-sentence rule, so the match does not test the rule itself.