# Give your AI agent a ledger: the bea accounting CLI is here

You already hand your AI agent your codebase, your terminal, and your hardest debugging sessions. Now hand it your books — with every entry it drafts passing through a preview you approve and a validator that checks the math. The `bea` command-line tool installs in two commands, works on plain-text ledger files on your own machine, and needs no account for local bookkeeping.



## Install it in two commands

There are two published ways to get the same command. Pick the one that fits your machine, then confirm it answers with its version:

```console
$ uv tool install beancount-io
$ brew install bex-co/tap/bea
$ bea --version
bea 0.3.1
```

The Python distribution is `beancount-io` and the executable it installs is `bea`. The output above is from version 0.3.1, the current release when this article was last checked on 2026-11-01; a newer release prints its own number. The `uv` path works anywhere with Python 3.12 or newer; the Homebrew path covers macOS and Linux. The full walkthrough lives on the [install page](/for-ai-agents), with the same steps in the [CLI quick start](/docs/Basics/bea-cli).

## Your agent's first task takes minutes

You do not need a new agent, a plugin, or a platform migration. Paste this into the shell-capable AI agent you already use, in a fresh empty demo directory:

> You have shell access and the `bea` CLI installed. First run `bea --help` and read what it offers. Then, in a NEW empty demo directory (do not touch any existing ledger): 1) create a USD ledger opening Assets:Checking at 1000 on 2026-08-01; 2) add a 12.50 USD purchase narrated "Coffee" to Expenses:Dining on 2026-08-02; 3) run `bea check`; 4) report the Assets:Checking balance together with the exact BQL query you used. Expected result: 987.50 USD.

The same steps as plain commands:

```console
$ bea --no-input init demo-books --currency USD --date 2026-08-01 --opening-balance "Assets:Checking 1000"
$ cd demo-books
$ bea add transaction --date 2026-08-02 --narration "Coffee" --posting "Expenses:Dining 12.50" --posting "Assets:Checking"
$ bea check
$ bea query "SELECT account, sum(position) WHERE account = 'Assets:Checking' GROUP BY account"
```

Expected result: `Assets:Checking` holds **987.50 USD** — 1000 minus 12.50, validated by `check` and reported back with the query that computed it. When your agent hands you that number, it has done its first closed loop: draft, validate, report. The [agent guide](/docs/Solutions/accounting-with-ai-agents) builds on the same loop with two fuller recipes — importing a bank CSV with preview-first review, and answering a balance question from query output.

## What you need, and who this fits

A terminal, a network connection, and either Homebrew or `uv` with Python 3.12 or newer. Local import, query, report, and check commands need no Beancount.io account, and your ledger files stay in a directory you choose as plain text you can diff, back up, and version-control.

This fits technical founders keeping their own startup books, independent developers who already live in a terminal, and agent builders looking for a ledger an AI can draft changes against without silent writes. If your books already live in a cloud product, the honest answer is different — see the comparison section below.

## The hosted path is optional and separate

Nothing above needs an account or sends your ledger anywhere. Two extras do, and both are deliberately separate from installing the CLI:

- **`bea ask`** answers questions about a local ledger through the hosted AI service. It needs the ask extra — `uv tool install 'beancount-io[ask]'` — plus your Beancount.io credentials. The default installation omits the AI dependencies until you ask for them.
- **The MCP server and hosted ledgers** likewise sign in with your Beancount.io account to authorize access. Agent skills for Beancount live in the product repository and load into your agent separately — installing the CLI does not install or configure them.

Start local; connect hosting only if you want it.

## Proof: one agent, three rows, checked books

A launch claim is only as good as its reproduction. So alongside the CLI ships a synthetic three-row challenge with an answer derived from arithmetic before any report ran: books open on 2026-09-01 with 1000 USD in checking, the statement carries a 2000.00 USD client payment, a −29.00 USD hosting bill, and a −12.50 USD cafe visit, and the expected answers are **2958.50 USD** in checking (`1000 + 2000 − 29 − 12.50`) and **1958.50 USD** of September profit (`2000 − 29 − 12.50`).

An installed-CLI verifier runs the whole loop in a fresh temporary directory: preview reports 3 ready and writes nothing, the first apply writes 3 entries, an identical reimport writes 0 with ledger bytes preserved, an unbalanced write (−5 checking against +4 dining) exits 1 with bytes preserved, and `check` returns valid. The exact inputs are downloadable as <a href="/downloads/agent-accounting/main.bean" download>main.bean</a>, <a href="/downloads/agent-accounting/statement.csv" download>statement.csv</a>, and <a href="/downloads/agent-accounting/rules.toml" download>rules.toml</a>.

Then one real agent ran the same challenge: client `muse` 1.1.1 (Muse Code) with model `muse-spark-1.3-contributor`, headless, 22 tool calls, exit 0, no human interventions — and critically, **no `rules.toml` supplied**, so the agent derived its own categorization. It previewed 3 ready, applied 3 entries, ran a clean check, and reported 2958.50 USD checking and 1958.50 USD September profit, both re-verified afterwards against the independent expected values. The full record — actual prompt, every tool call, and the one real failure it diagnosed itself (a sandboxed cache lock, fixed by pointing `XDG_CACHE_HOME` inside the workdir) — is published as the [recorded run](/bean-labs/research-logs/2026/09/10/can-your-agent-balance-these-books), with the raw <a href="/downloads/agent-accounting-run/agent-run.transcript.md" download>transcript</a> alongside it.

The terminal session below is a **deterministic replay** of that run's working path, rebuilt from the canonical downloads by <a href="/downloads/agent-accounting-run/demo-replay.sh" download>demo-replay.sh</a> — it re-enacts the commands, so it embeds the categorization rules for determinism rather than re-deriving them. The captured output in <a href="/downloads/agent-accounting-run/demo-replay.txt" download>demo-replay.txt</a> carries the same information as watching it. The excerpt below was captured on `bea 0.3.1` on 2026-11-01. `bea check` prints nothing when the books balance, so its empty output and exit 0 are the pass:

```console
$ bea --version
bea 0.3.1
$ bea import (preview)
csv → Assets:Checking: 3 ready, 0 exact duplicates, 0 possible duplicates
$ bea import --apply
Wrote 3 entries to $WORK/books/main.bean.
$ bea check
$ bea balance Assets:Checking
    Checking                                      2,958.50 USD
$ bea report income-statement -t 2026-09
Net Profit: 1,958.50 USD
checking: 2958.50 USD (expected)
profit: 1958.50 USD (expected)
REPLAY OK: preview 3/0, applied 3, check clean, 2958.50 / 1958.50 USD.
```

Two honest limits travel with this evidence. It is CLI-output verification of one run of one client on synthetic data — not a model benchmark, and it claims nothing about other clients or unattended production use. And a passing `check` proves the ledger balances, never that the agent picked the right account for the cafe: category judgment is the agent's, structural validation is `bea`'s. A three-row toy tests the loop, not the judgment.

## Choosing between tools

If you are picking a ledger for agent workflows rather than sold on this one, read the [five-tool comparison](/compare/best-accounting-tools-for-ai-agents): Beancount.io, Xero, QuickBooks Online, Puzzle, and hledger scored on the same seven agent-workflow criteria — installation, authentication, read/write scope, local versus cloud data, preview and validation, structured output, and repeated-import behavior — with dated official sources checked 2026-09-10. Beancount.io is the only tool there with an observed end-to-end run behind it; the page says so, names its publisher, and labels what it did not test.

## Where to go from here

- [Install page](/for-ai-agents) — the two commands, the first task, and the challenge downloads in one place.
- [CLI quick start](/docs/Basics/bea-cli) — installation plus the 987.50 USD worked example.
- [Agent guide](/docs/Solutions/accounting-with-ai-agents) — two recipes: CSV import with preview-first review, and balance questions from query output.
- [Recorded run](/bean-labs/research-logs/2026/09/10/can-your-agent-balance-these-books) — the full proof story with methodology, failures, and limits.
- [Five-tool comparison](/compare/best-accounting-tools-for-ai-agents) — which tool fits which agent workflow.
