
hledger-flow
CLIhledger 的自动记账流程工具:把银行、信用卡导出的 CSV 对账单按固定目录归档,套用分类规则一键生成账本,改规则后可重新生成,适合会计批量整理流水。需先安装 hledger,再从 Releases 页面下载程序(仅 macOS、Linux);账目结论需会计复核。
hledger-flow
What is it?
Keep every statement. Rebuild your journals from them.
hledger-flow is a command-line workflow for hledger, the plain-text accounting tool. hledger keeps your accounts in journals: human-readable text files you can open in any editor, in a format that hledger reads and that Ledger and other plain-text accounting tools largely share.
hledger-flow is opinionated about where files live. You save each statement,
exactly as your bank issued it, in a folder for its owner, institution,
account and year. hledger-flow import converts each one with your hledger
rules, or a script for formats rules can't read, and links the journals
through all-years.journal. The statements stay as permanent input, so
every journal can be rebuilt from its source and every entry traced to the
statement it came from.
It grew out of scripts I wrote while using adept's Full-fledged Hledger.
Who should use this?
There are many ways to keep your finances with hledger, and hledger's workflows page describes them. Three of them handle bank statements in quite different ways:
hledger import. Your journal is the primary record. You classify, split and annotate entries by editing the journal, and a better rule changes future imports only. Overlapping downloads are fine: hledger skips entries it has already imported, as long as their dates and same-day order stay stable. How hledger import works- Read the CSV directly. The CSV files are the record and nothing is
generated. You classify by editing the rules, and a better rule applies the
next time hledger reads the file. Suits a few files you name yourself, as in
hledger -f checking.csv bal. The hledger 1.99 previews can alsoincludea CSV in a journal. Reading CSV with hledger - hledger-flow. The original statements are the primary record, and journals are rebuilt from them. You classify by editing rules files, and a better rule rebuilds every journal that uses it, in every year. A fixed folder for each owner, institution, account and year keeps years of statements maintainable. An account's statements must not overlap, or a purchase appears twice.
Choose hledger import if your journal is your primary record and you want
to edit it by hand. Choose hledger-flow if you want to generate your journals
from statements exactly as they came from the source, classify by editing
rules, and keep years of files in a structure that stays maintainable and
auditable.
Full-fledged hledger teaches this last approach with build scripts you can adapt. hledger-flow packages the folder conventions, import and standard reports as CLI commands. Full-fledged hledger’s principles and practices
Overview of the Basic Workflow
- Save each statement under its account and year.
- Add an hledger rules file for the account or bank. For most bank CSVs, rules are all you need.
- Run
hledger-flow importfrom the base directory. Use the generatedall-years.journalas yourLEDGER_FILE. - Commit the statements, rules, manual journals and generated journals to version control so you can review the effect of later rule changes.
Example: reclassify purchases across three years
Suppose your 2023–2025 statements are already imported and committed.
Purchases from City Rail currently appear under expenses:misc. You also
recorded a one-off cash fare by hand in
import/john/_manual_/2024/post-import.journal. Keep handwritten adjustments
in a manual journal, since each
full import rewrites the statement journals in 3-journal/.
Add this rule to import/mybank.rules, the rules file used by those statements:
if %description City Rail
account2 expenses:transport
From the base directory, rebuild all three years and review the changes:
hledger-flow import
git diff -- import/
hledger -f all-years.journal print expenses:transport
The diff should show the rule and the matching purchases moving from
expenses:misc to expenses:transport in each affected statement journal.
The cash fare stays in the manual journal. If you booked it to
expenses:transport, the last command shows it alongside the rebuilt entries.
How do I install it?
Install with Homebrew on Linux or macOS:
brew install ferntrail/tap/hledger-flow
Or download a release for Linux, macOS, or Windows, or build from source. The quick start covers each option, how to verify a download, and your first import.
Documentation
The full documentation is at https://hledger-flow.github.io/:
Project Goals
My hledger files started to collect a bunch of supporting code that
weren't really specific to my financial situation.
I want to extract and share as much as possible of that supporting code.
Adept's goals also resonated with me:
- Tracking expenses should take as little time, effort and manual work as possible
- Eventual consistency should be achievable: even if I can't record something precisely right now, maybe I would be able to do it later, so I should be able to leave things half-done and pick them up later
- Ability to refactor is a must. I want to be able to go back and change the way I am doing things, with as little effort as possible and without fear of irrevocably breaking things.
Support
hledger-flow is supported by FernTrail B.V.
Contributing to hledger-flow
Have a look at the contribution guidelines.
相關資源

Beancount
CLI用文本文件记录复式记账交易的记账语言与工具集:bean-check 校验账本、bean-format 统一格式,配合 Fava、beanquery 出报表与查询;账本是纯文本,便于 agent 生成和版本管理。
beancount/beancount6.2k
Ledger
CLI经典的纯文本复式记账命令行工具:账目写在文本文件里,直接生成余额、明细、预算等报表,没有数据库和隐藏状态,方便 agent 读写账本、对账和出报表。
ledger/ledger6.1k
hledger
CLI纯文本复式记账工具:记录收支、投资与工时,一条命令生成资产负债表、利润表与预算报表,支持 CSV 导入和 JSON 输出,便于 agent 对账出报表;可与 Beancount 账本互转。
hledgerorg/hledger4.8k
rustledger
CLIBeancount 纯文本复式记账的 Rust 实现,命令是 rledger:校验账本、跑 BQL 查询、出资产负债表与收支表,能导入银行 CSV/OFX 对账单、对比预算、计算投资收益和资本利得;另有 MCP 服务,GitHub 发行包还附带输出 JSON 的 ag-rledger,便于 agent 调用。账本需是 Beancount 格式,报表与涉税数字需会计复核。
rustledger/rustledger441
beanquery
CLIBeancount 官方账本查询工具 bean-query,用类 SQL 语句查询纯文本复式账本,出余额、收支分类汇总和账户明细,适合会计让 agent 核对账目、整理报表。需 uv 或 Python 3.8+ 和 Beancount 格式账本;报表结论需会计复核。
beancount/beanquery67
HLedger MCP Server
MCP让 agent 读取本地 hledger 纯文本复式账本,生成资产负债表、损益表、现金流量表和收支统计,也能写入或修改分录(可先试运行预览,写入前默认备份)。需先安装 hledger 与 Node.js,建议先用只读模式;报表结论需会计人员复核。
iiAtlas/hledger-mcp65