Add a rules engine for transaction categories

pocket-ledger · Cursor · branch feat/rules · claude-opus-5 · cwd /home/user/code/pocket-ledger · id deea060d-b6b9-5111-dfe5-d62464723a9b · 2026-08-26 13:02 · 2 msgs · 7 tools · 1 min read · updated 12 days ago

Replaced a hardcoded keyword map with ordered user-defined rules.

tools: Read, Edit, Bash
← pocket-ledger Download .md
Tool calls
Bash Bash: 8 calls (53.3%) 8 Edit Edit: 5 calls (33.3%) 5 Read Read: 2 calls (13.3%) 2
Token usage18.8K total
Input15.8K
Cache creation0
Cache read0
Output2.9K
Cache hit ratio0%· cold cache

Replaced a hardcoded keyword map with ordered user-defined rules.

Conversation

Turn 1 — User

Category matching is a giant if-chain. I want to define my own rules.

Turn 2 — Assistant

Replaced it with an ordered rule list loaded from config: each rule has a matcher and a category, first match wins, and an explicit fallback catches the rest.

Ordering is the whole design — the previous behaviour depended on dictionary order, which was accidental.

Turn 3 — User

Can a rule match on amount as well as description?

Turn 4 — Assistant

Yes, and the two combine with an implicit and. There is a test for a rule matching only above a threshold, since that was the case the old code could not express at all.

Subjects

  • [[Python]]
  • [[Configuration]]

Keyboard shortcuts

⌘K / Ctrl+KOpen command palette
/Focus search
g hGo to home
g pGo to projects
g sGo to sessions
j / kNext / prev row (tables)
?Show this help
EscClose dialogs

Structured queries

Mix key:value filters with free text in the palette:

type:sessionOnly session pages
project:llm-wikiFilter by project name (substring)
model:claudeFilter by model name (substring)
date:>2026-03-01Sessions after a date
date:<2026-04-01Sessions before a date
tags:rustPages mentioning a tag/topic
sort:dateSort results by date (newest first)

Example: type:session project:llm-wiki date:>2026-04 sort:date