← All craftbooks

Receipts to Expense Ledger

Personal and business workflowsevalv1.0.0released 2026-06-05workflow: build-loop

Turn a folder of receipt photos/PDFs into a clean expense ledger: OCR each receipt, extract vendor, date, line items, tax, and total, assign an expense category, and reconcile that each extracted total matches its line items. Locks the per-receipt field schema, the category set, and the math/reconciliation rules FIRST, then OCRs and extracts each receipt into rows, then verifies every receipt was processed, totals reconcile, currencies/dates are normalized, and low-confidence reads are flagged for review. Defining the schema and the total-equals-line-items check before extraction is what keeps an expense ledger trustworthy for reimbursement or tax.

Steps

Entry step: scope. Each step names the specialist role it wants; the full working prompt is expandable.

  1. Scope the ledgerplannerentry

    per-receipt schema, categories, reconciliation rules

    Show working prompt
    Define the ledger contract before reading receipts. Step 1: identify the receipts folder and the file types (jpg, png, pdf). Step 2: define the per-receipt schema (file, vendor, date, currency, line items[{desc, amount}], subtotal, tax, total, category, confidence, needs_review). Step 3: define the closed expense-category set (e.g. Meals, Travel, Supplies, Software, Other) — every receipt gets exactly one. Step 4: define the math/reconciliation rule — sum(line items) + tax should equal total within a small tolerance; a mismatch sets needs_review. Step 5: define normalization (dates → ISO, amounts numeric to two decimals, a single output currency or a currency column) and the confidence threshold below which a row is flagged. Step 6: write an acceptance-criteria checklist ('every receipt file produces a row', 'amounts numeric and dates ISO', 'total reconciles to line items + tax within tolerance else flagged', 'category is in-set', 'low-confidence reads flagged for review', 'a grand total across receipts is reported'). Call write_task_note with schema + categories + rules + checklist and write notes/scope.md. No OCR yet.
  2. OCR and extractdeveloper

    read each receipt, extract fields, categorize, reconcile

    Show working prompt
    Process every receipt into a ledger row to the locked schema. Step 1: list the folder and, for each receipt, use the available OCR/vision capability to read the text. Step 2: extract vendor, date, line items, subtotal, tax, and total; normalize dates to ISO and amounts to numbers. Step 3: assign exactly one in-set category from the vendor/items. Step 4: reconcile — check sum(line items)+tax ≈ total within tolerance; on mismatch or low OCR confidence, set needs_review with a note rather than silently trusting it. Step 5: write all rows to the output file (JSON), confirm it parses, and compute a grand total across receipts. Do not skip any receipt; if one is unreadable, still emit a row flagged needs_review. Call write_task_note with the output path, the receipt count, and how many are flagged.
  3. Verify the ledgerreviewer

    coverage, reconciliation, normalization, review flags

    Show working prompt
    Verify the ledger against scope. Step 1: confirm the file parses and there is one row per receipt file in the folder — none skipped. Step 2: confirm amounts are numeric to two decimals and dates are ISO. Step 3: confirm reconciliation ran — rows where line items + tax do not match the total within tolerance are flagged needs_review, and clean rows actually balance (re-check 3 by hand). Step 4: confirm categories are all in-set and low-confidence/unreadable receipts are flagged rather than silently accepted. Step 5: confirm the grand total equals the sum of the row totals. Write PASS/FAIL per criterion to notes/verify.md and task notes; on failure, name the receipts and loop back to extract.
  4. Evaluatereviewer

    Grade the deliverable against every acceptance criterion. All pass → finish; any fail → loop back and fix the gap.

    Show working prompt
    Open ledger.json and verify every criterion from notes/scope.md: one row per receipt file (none skipped, unreadable ones flagged), amounts numeric to two decimals and dates ISO, reconciliation flags rows where line items + tax do not match the total within tolerance while clean rows balance (re-check 3 by hand), categories all in-set, low-confidence reads flagged, and the grand total equals the sum of row totals. Write PASS/FAIL per criterion; on any failure, name the receipts and loop back to extract.
    
    Then route — this is the whole point of the loop:
    
    - **Every criterion PASSES →** call `advance_task_step({ ref, stepId: "evaluate", next: "finish" })`.
    - **Any criterion FAILS →** write the specific gaps to notes, then call `advance_task_step({ ref, stepId: "evaluate", next: "extract" })` to loop back. The builder fixes exactly those gaps.
    
    Never route to `finish` while any criterion is unmet. The build phase's completion gate already blocked a grossly-incomplete deliverable; your job is the judgment an automated check cannot make (does it actually work, read well, look right). After ~3 unproductive loops, stop and report DONE_WITH_CONCERNS so the user can step in.
  5. Finishdeveloper

    All acceptance criteria met. Stamp a short summary and report DONE.

    Show working prompt
    Every acceptance criterion passed. Write a one-paragraph DONE summary to task notes via `write_task_note`: what was built, the deliverable path(s), and a one-line confirmation that each criterion is met. Then report DONE.

Triggers

Phrases that suggest this craftbook to a crew.

Source

View this craftbook on GitHub · MIT license