Our paperwork lives in a repository
We run our own company's paperwork the way we would build it for a client: bank statements, invoices and the accountant's emails in one git repository, checked by three small scripts.
At a glance
- Company
- Clandestine Hours, our own
- What we built
- Three Python scripts (about 1,300 lines in total) and a written routine an AI assistant follows, all in one private git repository
- Stack
- Python · pypdf · Microsoft Graph (msal) · plain CSV, JSON and Markdown · Claude Code
- Timeline
- Statement extractor in June 2026; reconciliation and mailbox sync running by October 2026
- Result
- Seven monthly statements extracted, each balancing to the cent and each starting where the last one ended; 121 of the accountant's emails and 46 attachments archived; more than 40 supplier invoices filed by month
Clandestine Hours is a small company. Like every small company, it has paperwork: bank statements, supplier invoices, requests from the accountant, VAT deadlines. Like many, we started with a folder of PDFs and an inbox.
Now we run it the way we would for a client. Everything lives in one private git repository: a folder that records every change ever made to it. Three small scripts (short programs) do the boring checks. Here is how each one works.
Bank statements, as data
Our bank sends monthly statements as PDFs. Copying lines into a spreadsheet is the kind of task where mistakes go unnoticed.
The first surprise was that the PDF has no readable text. The bank uses its own font encoding, so a PDF library (we use pypdf) returns codes like /C4f instead of letters. Each code is one byte in hexadecimal (base 16). The script turns /C4f back into the byte 0x4f, the letter “O”, before reading anything else.
Then it reads each movement: date, description, amount. The statement doesn’t always say clearly whether a line is money in or out. So the script works it out from the running balance: if the balance went up, it’s a credit.
Finally it checks itself:
- Opening balance plus credits minus debits must equal the closing balance.
- Credits and debits must match the statement’s own totals.
- Each statement must start where the previous one ended.
If anything is off by a cent, it flags the statement. The result is statements.json: every movement, month after month, with each statement stored once by its number.
Invoices, reconciled
Reconciling means matching each bank payment to its invoice. Every supplier invoice goes into a folder for its month and gets a line in ledger.csv, a simple spreadsheet. The second script does the matching, with the rules a person would use:
- Same amount, within seven days of the invoice date. Some recurring invoices are settled on a different schedule. For those, the window runs to thirty days.
- Card payments in dollars are matched by the supplier’s name. If the bank line shows the dollar amount, it has to match exactly. If not, the euro amount has to fall within 8% of the expected conversion, and the match is marked “probable”.
- Instalments: two to four payments to the same supplier, within 120 days, that add up to one invoice.
- No invoice needed: bank fees, stamp duty and tax payments are tagged, and nobody goes looking for an invoice that doesn’t exist.
The output is a Markdown report (plain text with light formatting), regenerated on every run. The most useful part is the list of what doesn’t match. We send that list to the accountant, or we go and find the missing documents ourselves.
The accountant’s emails, in the repository
Requests from the accountant used to live in an inbox. The third script signs in to the mailbox once, through Microsoft Graph, Microsoft’s interface for programs to read Outlook mail. Signing in takes a short device code, typed into a browser. Then the script copies the relevant messages into the repository as Markdown, attachments included. It only fetches what it hasn’t saved yet. The same script downloads supplier invoices for a date range into the right month’s folder.
The questions and the documents that answer them now sit side by side, with every change kept in the history.
The routine on top
The scripts do the checking. A written routine says what to run, in what order, and what to send back. An AI assistant working in the same repository (Claude Code) follows that routine. Ask it “what does the accountant still need from us?” and the answer comes from the actual files: the open requests, the unmatched payments and the missing invoices.
Why go to the trouble
The time saved is small, perhaps an hour a month. The bigger gain is catching gaps early. Without the checks, we might only find out at the end of the year that a June invoice is missing. The checks run every time the scripts run, so catching a gap does not depend on someone remembering to look.
None of this replaces our accountant. It means the files we send them have already been checked against the bank statements. Their questions get answered from the same place the documents live.
Try this
You don’t need scripts to start. Pick one monthly check you do by hand, for example “does every payment have an invoice?”. Write down the exact steps you follow. If you can write the steps down, a script can often follow them. If you can’t, an AI agent can help you work them out. Once written, that list is the brief for automating the check.
Guide
Case study
Guide