← All craftbooks

Invoice Generator

Documents and decksevalv1.0.0released 2026-06-05workflow: build-loop

Generate a clean, professional, print-ready invoice from billing details — sender/recipient, line items with quantity and rate, subtotal, tax, total, invoice number, dates, and payment instructions. Scopes the required fields and the tax/total math FIRST (a wrong total is the one unforgivable invoice bug), then builds a polished single-file HTML invoice with an itemized table and correctly computed totals. Use for freelancer/contractor billing, one-off invoices, and invoice templates.

Steps

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

  1. Scope the invoiceplannerentry

    required fields, line items, and the tax/total math rules

    Show working prompt
    Nail down the data and the math before formatting. Step 1: list the required fields — sender (name, address, contact), recipient (bill-to), invoice number, issue date, due date, and payment terms. Step 2: enumerate the line items, each with description, quantity, unit rate, and line amount (quantity x rate). Step 3: define the money math EXACTLY: subtotal = sum of line amounts; tax = subtotal x tax rate (or none); discount if any; total = subtotal - discount + tax. State the currency and rounding (2 decimals). Step 4: capture payment instructions (bank/transfer/links) and any notes. Step 5: write an acceptance-criteria checklist ('all required header fields present', 'every line item has qty, rate, and qty x rate amount', 'subtotal equals the sum of line amounts', 'tax computed from the stated rate', 'total = subtotal - discount + tax and is arithmetically correct', 'currency + dates + invoice number shown', 'payment instructions present'). Write the field list + math rules + checklist via write_task_note AND to notes/scope.md. No HTML yet.
  2. Build the invoicedeveloper

    render invoice.html with an itemized table and correct totals

    Show working prompt
    Build the invoice as a single self-contained invoice.html (inline CSS with print @page rules). Step 1: render a header with the sender block, a bill-to block, and an invoice-meta block (invoice number, issue date, due date, terms). Step 2: render the line items as a bordered table with columns Description | Qty | Rate | Amount, computing each Amount as qty x rate. Step 3: render a totals block beneath the table: Subtotal (sum of amounts), Discount (if any), Tax (subtotal x rate, with the rate shown), and a visually emphasized Total = subtotal - discount + tax. COMPUTE the arithmetic correctly and format all money to 2 decimals in the stated currency. Step 4: add a payment-instructions section and any notes, plus a clean, professional visual style that prints to one page. Step 5: double-check the totals add up before finishing. On a loop-back, fix ONLY the named gaps (most commonly an arithmetic error). Write the path + the computed total via write_task_note.
  3. Evaluatereviewer

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

    Show working prompt
    QA the invoice against the locked criteria — and RE-DO THE MATH yourself. Step 1: open/render invoice.html. Step 2: independently recompute each line Amount (qty x rate), the Subtotal (sum of amounts), the Tax (subtotal x stated rate), and the Total (subtotal - discount + tax); compare to what the invoice shows — any mismatch is an automatic FAIL. Step 3: check EACH remaining criterion: all header fields present (sender, bill-to, invoice number, issue + due dates, terms), itemized table with qty/rate/amount columns, currency and 2-decimal formatting, payment instructions present, prints cleanly to one page. Step 4: write PASS/FAIL per criterion; on any arithmetic mismatch, state the correct figure and loop back to fix.
    
    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: "build" })` 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.
  4. 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