Method
How I run finance work with an AI agent.
I do revenue accounting at a marketplace company, and I do it with an AI agent. The agent writes the queries and the code. A saved script does the arithmetic. Nothing is posted or sent until I have reviewed it. This page is the method, with a worked example you can run.
- I decide what's needed
- The question, the system it comes from, and the period.
- The agent writes the code
- It writes the query and the script, and drafts the explanation.
- Code does the arithmetic
- Run it twice on one file and the answer is the same.
Why split it this way.
Ask a language model to add up the same column twice and it can give you two answers. A saved script can't. That decides the design: any step with one right answer is done by code that can be run again, and the model's job is to find the data, write that code and explain what came out.
It also makes the work reviewable. A reviewer doesn't have to trust me or the model. They can read the script, run it on the same file and get the same number.
Six steps, every time.
Once a recurring task is scripted, it follows the same six steps. The agent reaches into a system twice: once to pull the rows, and once to read the total the result has to match.
- 01
Ask Me
The question, the source and the period.
- 02
Pull Agent
The agent writes the query in that system's own language and runs it, or I export the report myself. Either way the rows are saved as a file, with the row count and the source's own total written down beside them.
- 03
Calculate Script
Filter, group and total, in code. The agent never types an amount or adds one up itself.
- 04
Build Script
The journal, the workpaper and the import file, built by code.
- 05
Check Script
The result has to equal the source's own total. If it doesn't, the run stops and produces nothing.
- 06
Review and post Me
A person reviews and posts, every time. Some connectors are able to create a record; none does it without my say.
How the agent reaches the systems.
Where a system has a connector, the agent reaches it through MCP (the Model Context Protocol), the open standard that lets an AI assistant use other software. A connector signs in as me, so the agent sees only what my login can see. Most connector tools only read; the few that can write are used only on my say, one write at a time.
A script never uses a connector. However the rows arrive, they are saved as a file first, and the script does its math on the file. Once a query is right, it is saved and reused, so the same question gets asked the same way every month.
Finished means someone else can run it.
I hold a script to seven tests before I call it finished.
- The period is an argument. Two different months run with no edit to the file.
- Inputs come from one named folder. Someone new can find and place them using only the runbook.
- The whole task is one command. The runbook has a single line to type.
- It ties to the source, or it stops. Feed it a file with a row missing and it must refuse and write nothing.
- Errors are written for an accountant. They say what is wrong and what to do about it, with no stack trace.
- It has a runbook. It lists the inputs, the command, the sign of a good run, the steps a person takes afterwards, and what to do if it stops.
- It is safe to run twice. A second run cannot create a duplicate, and each run's outputs stay in the period's folder as evidence.
Rates and mappings sit in a settings block at the top, so changing a rate never means reading code. The last test is a person, not a document: a colleague runs the task from the runbook without my help.
A worked example you can run.
This one was written for this page. A small shop has received goods it hasn't been billed for, and at month end it has to book what it owes. The shop, its suppliers and every amount are invented.
There are two inputs: the month's receiving log, saved as a file, and a note of what the receiving system itself showed at the export, which was 12 rows and 9,962.00 not yet invoiced. One command runs the task.
$ python accrue_receipts.py --month 2026-10
October 2026: receipts.csv has 12 rows (the receiving system reported 12).
5 receipts not yet invoiced, total 9,962.00 (the receiving system reported 9,962.00).
Journal RNI-2026-10 balances: debits 9,962.00, credits 9,962.00.
Tied. Wrote out/2026-10/journal.csv and out/2026-10/run_log.json for review. Nothing has been posted. Delete one line from the file and run it again.
$ python accrue_receipts.py --month 2026-10
STOPPED. receipts.csv has 11 rows, but the receiving system reported 12 for October 2026.
The export is incomplete or was filtered. Export the receiving log again and re-run.
Nothing was written. The script counts the rows and adds up the open receipts itself, then compares both with what the source reported. Its 7 tests cover a short file, a changed amount, a repeated receipt, a receipt from another month and a quantity that isn't a number. Run it twice and the two output files are identical, byte for byte.
The script, its sample files, its tests and its runbook are in this site's repository.
A second check that can't see the first.
Before a figure goes into a journal or to another person, a second agent derives it again. It is given two things: the claim, and where the source is. It never sees how the number was first worked out, so it can't follow the same wrong turn.
It answers in a fixed form: the source it read and when that source last changed, the figure it got, the difference, and one of three verdicts: matches, does not match, or cannot verify. Then it lists what it was unable to check.
Reading the same export twice counts as one check. A real second check starts from a second source.
The agent prepares. I click.
- For email, messages, shared files and the ledger, the agent stages the draft. I send, post or approve it.
- Agreeing with the content is not permission to write it somewhere. Those are two separate yeses.
- A write to anything shared is rehearsed first. I read exactly what it will change, and then it runs as its own step.
- Every claim the agent makes is labeled verified, inferred or speculation, with its source and the time it was read.
- Before it tells me something is missing, it has to search for it.
What the agent knows before it starts.
Each session starts with a short file of the facts every task needs, plus the rules for the folder the work is in. A recurring task also has a saved procedure: its steps, its checks, and the points where it must stop for a person.
The rules come from mistakes. When I correct the agent, the correction is saved, and the ones that keep proving useful become standing rules it reads at the start of every session.
The standard behind all of it.
These lines are in my own standing instructions to the agent, for work and for everything else on this site.
No guessing. No inferring. No unstated assumptions.
Figures carried over from a summary, a subagent or an earlier session are unverified until re-derived from the source; tie any recomputed total to the source's own control total.
Always state what was checked and what was not checked. If a gap in analysis exists, name it.
The agent I use is Claude, mostly through Claude Code. The method doesn't depend on either: any agent that can run code, use connectors and follow a rules file fits the same frame.
Get in touch
Want to see any of this run? Write to me.
I'm happy to walk through how any of these were built. For Item2 or the trip app, email is the fastest way to reach me.