agentleFS
HenryQWHenryQW/skills/beanquery/SKILL.md

beanquery

Skill1 starsChanged 4 months agoApache-2.0View on GitHub

Query existing Beancount ledgers with bean-query and Beancount Query Language (BQL). Use when an agent needs quick read-only ledger lookups, balances, journals, transaction searches, or CSV results.

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 3 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use bean-query for fast, read-only queries against an existing Beancount ledger.

    line 8
  2. Distinctive:

    Read this file first. Load one reference only when task needs deeper detail:

    line 13
  3. Very specific:

    Do not load all references for routine query.

    line 19
  4. Distinctive:

    Check command and ledger:

    line 25
  5. Distinctive:

    Run one-shot query. Quote query as one shell argument:

    line 39
  6. Very specific:

    Use --format=csv for agent parsing.

    line 46
  7. Very specific:

    Use --numberify when spreadsheet-like numeric currency columns are needed.

    line 47
  8. Very specific:

    Default queries scan postings.

    line 73
  9. Very specific:

    Use FROM entries for directive-level rows.

    line 82
  10. Very specific:

    Use BALANCES for account totals, JOURNAL for account registers, and PRINT for Beancount-formatted directives.

    line 91
  11. Very specific:

    Use explicit GROUP BY for every non-aggregate target.

    line 93
  12. Very specific:

    Check optional values with IS NULL or IS NOT NULL.

    line 98
  13. Very specific:

    Use .help targets, .help from, and .help where for complete type-aware columns and functions.

    line 112

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

beanquery

Use bean-query for fast, read-only queries against an existing Beancount ledger. Do not edit ledger files or use BQL CREATE/INSERT.

Progressive loading

Read this file first. Load one reference only when task needs deeper detail:

  • Exact tables, columns, types, or structured fields: schema
  • Ready-made reports and search patterns: query cookbook
  • BQL grammar, semantics, operators, and edge cases: BQL

Do not load all references for routine query. Re-check live .describe output when ledger schema or installed beanquery version may differ.

Procedure

  1. Resolve ledger path. Never guess it; ask user when unknown.
  2. Check command and ledger:

    test -f "$LEDGER"
    command -v bean-query || python3 -m beanquery --help
  3. Inspect schema when query shape is unclear:

    bean-query "$LEDGER" ".tables"
    bean-query "$LEDGER" ".describe postings"
  4. Run one-shot query. Quote query as one shell argument:

    bean-query "$LEDGER" --format=csv \
      "SELECT date, account, position WHERE account ~ '^Expenses:' ORDER BY date;"
  5. Use --format=csv for agent parsing. Use text for quick human inspection. Use --numberify when spreadsheet-like numeric currency columns are needed.
  6. Load once without --no-errors when ledger health matters. Report Beancount validation errors; --no-errors only hides their output.

For long BQL, pipe stdin instead of fighting shell quoting:

cat <<'BQL' | bean-query "$LEDGER" --format=csv
SELECT date, account, number, currency
WHERE account ~ '^Expenses:'
ORDER BY date, account;
BQL

Ledger model

Ledger source exposes:

postings       default table; one row per transaction posting
entries        every Beancount directive
transactions   transaction directives
accounts       account open/close dates
commodities, prices, balances, notes, events, documents

Default queries scan postings. Common posting columns:

date, year, month, day, flag, payee, narration, description
account, other_accounts, accounts, position, number, currency
cost_number, cost_currency, cost_date, price, weight, balance
posting_flag, meta, entry, filename, lineno, location, id, type, tags, links

Use FROM entries for directive-level rows. Use FROM # for one constant row; without it, SELECT 1 repeats once per posting.

Core query rules

  • SELECT queries default postings; each row is one posting.
  • WHERE account ~ 'REGEX' filters posting rows. Use directive fields in FROM (date, year, narration, flag) when complete transactions must remain for balancing context.
  • Use BALANCES for account totals, JOURNAL for account registers, and PRINT for Beancount-formatted directives.
  • Use explicit GROUP BY for every non-aggregate target. sum(position) returns inventory; sum(cost(position)) returns cost-basis inventory.
  • OPEN ON, CLOSE ON, and CLEAR perform accounting transformations, not simple date predicates.
  • ~ and !~ are case-insensitive regex operators. Dates use YYYY-MM-DD. Check optional values with IS NULL or IS NOT NULL.

Load query cookbook for task recipes. Load BQL reference for grammar, operators, functions, or edge cases.

Discovery and troubleshooting

bean-query "$LEDGER" ".tables"
bean-query "$LEDGER" ".describe postings"
bean-query "$LEDGER" ".describe entries"

Use .help targets, .help from, and .help where for complete type-aware columns and functions. If result is empty, verify default table, column name, regex, date range, and whether filter belongs in FROM or WHERE. Use .errors to inspect load errors.

Interactive shell commands include .tables, .describe, .errors, .reload, .parse, .explain, .set pager false, .format csv, .output FILE, and .run NAME for Beancount query directives.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.