Automating HLedger journal entries with AI Agent

184 views
Skip to first unread message

Ratnakar Vellanki

unread,
Jul 19, 2025, 10:22:36 PMJul 19
to hledger
Over the past year, I’ve been using HLedger to get a unified, double-entry view of all my finances. The beauty of double-entry accounting is that once you record things correctly, you can slice and analyze everything — net worth, savings rate, spending categories, tax lots — in one place.

But let’s be honest — posting journal entries manually is a drag. Especially for credit card transactions, which often number in the hundreds each month for us as we route all our expenses through our credit card. While things like pay stubs, brokerage statements and bank statements are easier to handle as the # transactions are fewer. Also credit card purchases vary too much and require more judgment on posting them accurately to the right expense account in the journal entry.

So I built an AI-agent workflow that:
  • Takes credit card statements (CSV downloaded from the bank)- This is done by local orchestrator
  • Converts them into HLedger journal entries, mapped to appropriate accounts (groceries, utilities, travel:flights, travel:hotels etc.) - this is done by Claude 3.5 Sonnet model currently through AWS Bedrock via API calls
  • Produces outputs in clean, HLedger double-entry format that I just copy paste into my HLedger journal - Claude Sonnet again but output is all collated by local orchestrator into a text file in HLedger journal format
The key principle? Privacy-first.

All data — past examples, chart of accounts, credit card CSV — stays local. Python agent orchestration script that orchestrates everything stays local (Vibe coded it using Chat GPT- did not write a single line of code myself). The prompts are sent to Claude (via AWS Bedrock), but no data is shared with any public chatbot or website. Picked hosted Claude on AWS Bedrock over direct Anthropic or Open AI API as everything stays fully private with AWS while with direct Anthropic or Open AI API, prompts are stored for 30 days (though they not used for training like when you use their web interface). No integrations with banks or cloud syncing. Just clean journal files, generated offline or in a private, controlled setup.

It’s still evolving, and I plan to add support for brokerage and bank statements next. But so far, it’s made monthly financial journal postings much faster and more enjoyable.

The output is pretty accurate (saw 98-99% accuracy in terms of posting to the right accounts, directionality (E.g. Returns to be posted as a reversal etc.). I think this is pretty high accuracy.
In terms of cost, I used Claude Sonnet 3.5 on AWS Bedrock and It cost less than $1 (around 80-90 cents) to do the above for approx. 200 transactions. Bedrock also offers several other models (not GPT-4 though which is exclusively offered on Azure).

In terms of effort it took around 5-6 hours, but the incremental effort to build something like this after now will be much lower as I was learning most of the stuff on the fly and also took time to setup things like AWS account. I do understand technology but I am not a software engineer.

Nicholas McAvoy

unread,
Jul 21, 2025, 9:57:40 PMJul 21
to hledger
Very cool! I built an MCP server last week for a little food journaling app of mine, analogous in some ways to plain text accounting, and it did get me thinking in this direction.

For years, I've used an obscure project that wraps a dead utility for injecting some ML into account matching. The obscure project is buchhaltung (last commit 7 years ago) and the dead utility is dbacl (originally used for classifying spam email). I was thinking last week about the best design for a fresh take on this problem. Personally, for this purpose, I would rather use something free and offline and lightweight, so I would probably try a similar approach to dbacl (simple Bayesian maximum entropy). But I do imagine wrapping MCP around it, so that you could always ask an LLM to do something.

Side note, something I like about Buchhaltung is the need to replay every single transaction, if only to approve the inferred account. I do this replay with my wife, and the "instant replay" of our financial lives has often been illustrative. So while I do wish at times for more automation here, I'm also a little wary of losing what you might call the mindfulness of it.

One final note: CSV rules files, when maintained, probably get you 80% of the way to correct account matching anyway, right?
Reply all
Reply to author
Forward
0 new messages