Check the books as you edit¶
CI checks a change once it is pushed. Run the same check earlier: after every edit an agent makes, and on every save in your editor.
Applies if
- Legal form, VAT status, method, filing period: any. The check is
quints check; Diagnostics says which codes appear in which case. - Who edits the books: an AI coding agent (steps 1 to 3), a person in an editor (steps 4 and 5), or both.
- Where the books live: a git repository. Steps 1 to 3 compare with the last commit.
- Not covered: VS Code and aider (see below).
1. Run by hand what the agent runs¶
--reviewalso lists what is still to do:!flags, entries with no document, bank balances not asserted for a quarter.quints explain <code>prints what a code means and how to fix it, from the installed package: no network.--fixapplies the fixes that need no judgement, then checks again.
After an edit, report only what the edit brought:
--base-ref HEAD checks the books as committed and as they are now, and
reports the problems the commit doesn't have. --strict makes a new
warning exit 1 too. Books with fifty old problems still answer "you added
this one".
2. Claude Code: nothing to do¶
quints init writes .claude/settings.json. Claude Code then runs the
command of step 1 after each edit, and the new problems go back to the
model.1 For books scaffolded earlier, upgrade quints
(uv lock --upgrade-package quints: older releases lack the flags), then
add the file by hand:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "cd \"$CLAUDE_PROJECT_DIR\" && uv run quints check --review --strict --base-ref HEAD 1>&2 || exit 2",
"timeout": 60,
"statusMessage": "quints check"
}
]
}
]
}
}
Commit once the check is clean: the next edit is compared with that commit.
3. Other agents¶
AGENTS.md tells any agent that reads it to run the command of step 1
after each edit. Nothing else is needed.
OpenCode can also hand the model the problems from the language server of
step 4.2 In opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"lsp": {
"quints": {
"command": ["uv", "run", "quints", "lsp"],
"extensions": [".bean"]
}
}
}
The language server reports every problem, not only the new ones. On books that already have many, prefer the command of step 1.
4. Your editor: quints lsp¶
quints lsp is a language server.3 It shows each problem at its file
and line when the editor opens the books, and again on every save. The code
links to its entry in Diagnostics, and a
problem that has a fix offers it as a quick fix. What --review adds shows
as information, not as a warning.
It needs an extra, in the books' project:
Any other editor that starts a language server from a command works the
same: uv run quints lsp, in the directory that holds main.bean, for
beancount files.
5. Completion, formatting and the other files¶
quints lsp only reports problems. Three more servers run beside it:
- Beancount files:
beancount-language-servercompletes accounts and payees and formats entries. It runs beancount with the books'.venv, so afteruv syncit loadsquints.plugins.kmuand reports a missingkmu:code in the editor.6 quints.toml: its first line,#:schema …/schema/quints.schema.json, points Taplo (Even Better TOML) at the schema: an unknown key or a value of the wrong kind is underlined.7quints initwrites the line; add it to aquints.tomlwritten earlier.- Invoice YAML: each file under
invoicing/carries ayaml-language-servermodeline to its schema.
For an editor with no network, write the same schemas to
invoicing/schema/:
What quints doesn't do here¶
- VS Code. VS Code starts a language server only from an extension, and
quints has none. Use the terminal (
quints check), or the Claude Code hook of step 2. - aider. aider's
--lint-cmdpasses the edited files to the command, andquints checktakes none: it always checks the whole books. Wrap it in a script that ignores its arguments. - Unsaved changes. The check reads the books from disk. An edit shows up when you save it.
- Fixes that need judgement.
--fixand the quick fix book the hash of a filed invoice, and nothing else today. They never change an amount, an account or a tag.
-
Claude Code Docs, Hooks reference,
PostToolUseand "Exit code 2 behavior": https://code.claude.com/docs/en/hooks. ↩ -
OpenCode Docs, LSP Servers, "Custom LSP servers": https://opencode.ai/docs/lsp/. ↩
-
Microsoft, Language Server Protocol Specification 3.17, "Publish Diagnostics" and "Code Action": https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/. ↩
-
Helix Docs, Languages, "Configuring Language Servers for a language": https://docs.helix-editor.com/languages.html. ↩
-
Neovim Docs, LSP,
vim.lsp.config()andvim.lsp.enable(): https://neovim.io/doc/user/lsp/. ↩ -
polarmutex, beancount-language-server README, "Diagnostics": https://github.com/polarmutex/beancount-language-server. ↩
-
Taplo Docs, Directives, "The schema directive": https://taplo.tamasfe.dev/configuration/directives.html. ↩