Brainfile › Guides › Automate Financial Reporting
Claude Code · Finance

How to Automate Financial Reporting
With Claude, and Check It

Describe your monthly budget vs actual report once, in plain English. Claude Code writes a script that builds it, ties its totals back to your file, and re-runs next month with one command. Every step was run on 2026-10-13; the output is shown.

Free by email: a practical Claude Code tip every Tuesday and Thursday, plus a Sunday recap.

Start here → Free 30-day trial
In this guide

Have Claude write the report script, not the report

You can paste a spreadsheet into a chat and ask for a variance commentary. You will get one, but you cannot easily check where each number came from, and next month you start again. The approach on this page is different: you describe the report in plain English once, Claude Code writes a small program that produces it, and every month after that the same program reads the new file and gives you the same kind of report. You can check the program's arithmetic, and it checks itself.

We ran every step below on 2026-10-13 with Claude Code, on sample numbers we made up for a small agency. You do not need to know how to code. You need Claude Code (a paid Claude plan; see where to run Claude Code if you would rather not use a terminal) and your figures exported as a CSV file.

Put each month's export in one folder

Make a project folder with a data folder inside it, and save each month as data/2026-09.csv, data/2026-10.csv and so on. Ours had four columns:

data/2026-09.csv (sample numbers)
account,category,budget,actual
Client retainers,Revenue,42000,44150
Project fees,Revenue,18000,12600
Contractors,Cost of sales,15000,17850
Software subscriptions,Operating expense,2400,2655
Advertising,Operating expense,3000,1200
Rent,Operating expense,4500,4500
Payroll,Operating expense,22000,22000
Travel,Operating expense,800,1940
Professional fees,Operating expense,1200,1050
Insurance,Operating expense,650,650
What broke when we tried a real-looking export

Spreadsheets often export big numbers with a thousands separator, like "1,940". We changed one cell to that and re-ran the finished script. It stopped with ERROR: 2026-07.csv line 9: budget/actual is not a number and wrote no report. That is the behaviour you want: a script that guesses is worse than one that stops. Either export plain numbers, or tell Claude what your export looks like and ask it to handle the separators.

Write the rules in CLAUDE.md

CLAUDE.md is a plain text file in your project folder that Claude Code reads at the start of every session. This is where you write down how your report works, in the words you would use with a new analyst. Ours:

CLAUDE.md
# Monthly budget vs actual report

- Data: one CSV per month in data/, named YYYY-MM.csv, with columns account,category,budget,actual.
- Never calculate numbers in the chat. Every number in a report comes from running report.py.
- Variance = actual minus budget. Revenue over budget is favourable; costs over budget are unfavourable.
- Flag a line when the variance is at least 10% of budget AND at least $500.
- Show subtotals for revenue and for costs, and net profit (revenue minus costs), budget vs actual.
- Tie-out: re-add total revenue and total costs straight from the CSV. If they do not match the
  subtotals, stop with an error and write no report.
- Commentary covers flagged lines only. Where the data does not say why, write "needs an explanation from the owner".
Write the rule you mean

Our first version asked for “total budget and total actual”. Claude did exactly that: it added revenue and costs into one total of $109,550 and then pointed out, unprompted, that the figure “isn't a profit figure”. We changed the rule to the subtotals and net profit above. Claude follows the file closely, so the file has to say what you actually want.

Ask Claude Code to build it

Open the folder in Claude Code (the desktop app's Code tab, the VS Code extension or the terminal all work) and paste this:

Prompt
Read CLAUDE.md. Write report.py: it takes a month such as 2026-09, reads data/<month>.csv, and writes reports/<month>-variance.md following CLAUDE.md. Use only the Python standard library. Then run it for 2026-09 and show me the report.

On our run Claude wrote a 181-line script using only Python's standard library, ran it, and showed the report in about half a minute. Here is the part of the September report you would read first (the report itself shows cents):

LineBudgetActualVariance
Total revenue$60,000$56,750-$3,250
(-5.4%)
Total costs$49,550$51,845+$2,295
(+4.6%)
Net profit$10,450$4,905-$5,545
(-53.1%)
Project fees
flagged
$18,000$12,600-$5,400
(-30.0%)
Contractors
flagged
$15,000$17,850+$2,850
(+19.0%)
Advertising
flagged
$3,000$1,200-$1,800
(-60.0%)
Travel
flagged
$800$1,940+$1,140
(+142.5%)

Software subscriptions were 10.6% over budget but only $255, and professional fees 12.5% under but only $150, so neither was flagged; that is the two-part rule in CLAUDE.md working. Each flagged line in the commentary reads “Needs an explanation from the owner”, because the data does not say why, and the rules told Claude not to invent a reason.

Check it before you trust it

A report you cannot check is a guess with formatting. These are the checks we ran on 2026-10-13, and they are worth repeating on your own first month:

CheckWhat happened
Re-add the CSV yourself (or with a spreadsheet SUM)Revenue $56,750, costs $51,845, net profit $4,905: all match the report
Count which lines should be flaggedOur own count gave the same four lines
Ask for a month with no file (2026-10)Stopped with “not found”, no report
Feed it a number with a thousands separatorStopped with “not a number”, no report
Break a copy of the script so it drops one line from the subtotalsStopped with “tie-out failed, no report written”

The last row is the one that matters. The tie-out re-adds the totals straight from the file, separately from the table, so a script that quietly loses a line cannot hand you a tidy report built on it.

Every month after that

Save the new month's CSV into data/ and either ask Claude Code “run the report for October”, or run the one command yourself:

Terminal
python3 report.py 2026-10

We ran it on a second sample month without changing anything: it wrote the August report, net profit $10,950 against a $10,450 budget, with one flagged line (professional fees, $1,700 over). If you want Claude to run the script without asking each time, allow that one command in .claude/settings.json:

.claude/settings.json
{
  "permissions": {
    "allow": ["Bash(python3 report.py *)"]
  }
}
Before you use real company figures

Read Anthropic's data usage page for your plan. For Free, Pro and Max accounts it says Anthropic will “train new models using data from Free, Pro, and Max accounts when this setting is on (including when you use Claude Code from these accounts)”; you can change that setting at any time. For Team, Enterprise and API accounts it says Anthropic “does not train generative models using code or prompts sent to Claude Code under commercial terms.” The same page notes that Claude Code keeps session transcripts on your computer, in plain text, for 30 days by default. A script also does not replace review: the person who signs off on the numbers should still read the report.

Where Brainfile fits

This guide is free and complete. Brainfile is the memory around it.

Nothing on this page is part of Brainfile. The rules file, prompt and checks are yours to copy, and they work without buying anything.

Brainfile is a set of files that gives Claude Code a working memory of your project and your rules, so you stop re-explaining yourself every session. The free 30-day trial pulls the Basic set into your project: the Autopilot protocol, 10 pattern files and the weekly freshness feed. No card to start, and the files you pull stay yours.

Start the free 30-day trial →

Frequently Asked Questions

Can Claude automate financial reporting?

Yes, for repeatable reports built from exported data. The reliable way is to have Claude Code write a small script from rules you describe in a CLAUDE.md file, then run that script each month. The numbers then come from the file every time, and the script can check its own totals.

Do I need to know how to code?

No. You describe the report in plain English and Claude Code writes and runs the script. You do need Claude Code, which requires a paid Claude plan, and your figures exported as CSV.

Will Claude make up numbers in the report?

Not with this setup. Every number comes from running the script on your file, and the script re-adds the totals from the file and stops with an error if they do not match. Commentary is limited to flagged lines, and where the data does not say why, it says an explanation is needed.

Does Anthropic train on my financial data?

It depends on your plan and settings. Anthropic's data usage page says Free, Pro and Max data is used for training when that setting is on, and that commercial accounts (Team, Enterprise, API) are not used to train generative models under commercial terms. Check the page for your plan before using real figures.

What if my spreadsheet export looks different?

Tell Claude. Describe the columns and any quirks, such as thousands separators or a header row on line 3, in CLAUDE.md, and ask it to update the script. In our test the script stopped with a clear error on a number written as “1,940” rather than guessing.

Not ready to start? Stay in the loop.

A practical Claude Code tip every Tuesday and Thursday, plus a Sunday recap of the week. Free.

Or start the 30-day free trial — no card required.