← Back to Skills Marketplace
mr-muddle

Invoice Scan

by mr-muddle · GitHub ↗ · v2.2.0 · MIT-0
cross-platform ⚠ suspicious
512
Downloads
0
Stars
0
Active Installs
29
Versions
Install in OpenClaw
/install invoice-scan
Description
AI-powered invoice OCR, scanning, and data extraction. Use when: (1) user needs OCR or text extraction from invoice images, scanned documents, or PDFs, (2) s...
README (SKILL.md)

Invoice Scan

⚠️ Privacy Notice

CLI mode sends base64-encoded invoice images to Anthropic's API (api.anthropic.com). Invoice data (supplier/buyer names, addresses, IBANs, bank details, amounts) will be transmitted to a third-party service. Confirm this is acceptable under your privacy and compliance requirements before use. Consider dedicated API credentials with usage limits.

Agent-native mode does NOT send data externally — the agent uses its own built-in vision. Only formatOutput() is called locally for CSV/Excel export.

Setup

Install dependencies (required before first use):

cd {SKILL_DIR}/scripts && npm install --production

Dependencies: sharp (image processing), xlsx (Excel export). Review scripts/package.json before installing.

CLI mode requires: ANTHROPIC_API_KEY environment variable. Agent-native mode requires: nothing — uses agent's built-in vision capability.

Two Modes

Mode 1: Agent-Native (No API Key, No External Calls)

Use your built-in vision to look at the invoice image directly. Do NOT call scanInvoice() — that function requires an API key and sends data externally. Instead:

  1. Look at the image with your vision capability
  2. Extract all fields into a JSON object matching the canonical schema in references/canonical-schema.md
  3. Classify document type: invoice, credit-note, receipt, purchase-order, delivery-note, confirmation, statement, other-financial, not-financial
  4. Validate arithmetic and business rules per references/validation-rules.md
  5. Present results (see Output Format below)
  6. For CSV/Excel export, construct the canonical JSON object and pass it to formatOutput() only:
const { formatOutput } = require('{SKILL_DIR}/scripts');
// invoiceData = the JSON object YOU built from your vision extraction
// IMPORTANT: include ALL fields from canonical-schema.md, including charges[]
// e.g. invoiceData.charges = [{ type: 'shipping', label: 'P&P', amount: 5.99, vatRate: 20, vatAmount: 1.20 }]
const csv = formatOutput(invoiceData, 'csv');    // string — local only
const xlsx = formatOutput(invoiceData, 'excel');  // Buffer — local only

Key: formatOutput() is purely local — no network calls, no API key needed. It just formats your extracted data into CSV or Excel.

Mode 2: CLI Standalone (Needs API Key)

For automation or pipelines. Requires ANTHROPIC_API_KEY env var.

ANTHROPIC_API_KEY=\x3Ckey> node {SKILL_DIR}/scripts/cli.js scan \x3Cfile> [--format json|csv|excel] [--output result.json]

Options: --provider claude, --accept strict|relaxed|any, --no-preprocess, --model \x3Cmodel>

Agent-Native Extraction Checklist

Extract ALL of:

Header: invoiceNumber, invoiceDate (YYYY-MM-DD), dueDate, currency (ISO 4217), supplierName, supplierAddress, supplierVatNumber, buyerName, buyerAddress, buyerVatNumber, paymentTerms, paymentReference, bankDetails (iban, bic, accountNumber, sortCode)

Line items: description, quantity, unitOfMeasure, unitPrice, lineTotal, vatRate, sku, discount

References: PO, contract, GRN, timesheet, project, proforma, invoice (original invoice if this is a credit/debit memo), credit-note, debit-note refs. For credit/debit memos, ALWAYS include the original invoice reference.

Totals: netTotal, vatBreakdown (rate + amount + type per band — type is the tax regime label e.g. "CGST", "SGST", "USt", "НДС", "IVA"), vatTotal, grossTotal, amountPaid, amountDue, discount (invoice-level discount amount), discountRate (percentage)

Metadata: paidDate (YYYY-MM-DD — date from PAID stamp), vatInclusive (true if line totals include VAT, false if net, null if unknown)

Charges: Surcharges/fees outside line items — shipping, postage, P&P, delivery, freight, carriage, dispatch, handling, insurance, eco-levy, surcharges. Each: type (shipping|handling|insurance|surcharge|discount|other), label (original text from document), amount, vatRate, vatAmount. Do NOT duplicate items already captured as line items.

Document type: documentType (invoice, credit-note, debit-note, receipt, purchase-order, delivery-note, confirmation, statement, other-financial, not-financial)

Additional: handwritten notes, stamps/seals (type + text), remarks/comments, document language (ISO 639-1)

Arithmetic Validation

  1. qty × unitPrice = lineTotal (per line)
  2. Sum of lineTotals = netTotal
  3. netTotal + vatTotal = grossTotal (Tolerance: ±0.02 for rounding)

Locale Numbers

Parse regional formats automatically: US/UK (1,234.56), European (1.234,56), French (1 234,56), Indian (1,23,456.78). Use currency/country context when ambiguous.

Quality Score

Count present from: invoiceNumber, invoiceDate, currency, supplierName, buyerName, supplierVatNumber, netTotal, vatTotal, grossTotal. Score = present / 9. good ≥ 0.8, partial ≥ 0.5, poor \x3C 0.5.

Output Format

📄 Invoice #{number} | {date}
   Supplier: {name} → Buyer: {name}
   Net: {currency}{net} | VAT: {currency}{vat} | Gross: {currency}{gross}
   [if charges exist] 📦 Charges: {label} {currency}{amount} [per charge]
   [if amountDue is not null] Amount Due: {currency}{amountDue} [if amountPaid] (Paid: {currency}{amountPaid})
   Items: {count} | Arithmetic: ✅/❌ | Quality: {rating} ({score}/9)

List warnings/flags, then offer: "Want JSON, CSV, or Excel?"

File Delivery

  • Output directory: {WORKSPACE}/invoice-scan/output/ (create if needed)
  • Naming: {supplierName}_{invoiceNumber}_{invoiceDate}.{ext} (replace spaces/slashes with hyphens)
  • Always save JSON automatically, offer CSV/Excel on request
  • Send file as chat attachment + confirm path

References

  • Full schema: references/canonical-schema.md
  • Validation rules: references/validation-rules.md
Usage Guidance
This skill appears to do what it says, but review and consider the following before installing or using it: - Privacy: CLI mode sends base64-encoded invoice images (which include PII and financial details) to api.anthropic.com. Only use CLI mode if sending that data to a third party is acceptable; prefer agent-native mode for local-only extraction if you must avoid data exfiltration. - API keys: Use a limited/monitored ANTHROPIC_API_KEY for CLI automation; do not reuse high-privilege keys. The skill declares this key optional (agent-native), but CLI operations require it. - Local runtime: The SKILL.md instructs agents to call local formatOutput() via require('{SKILL_DIR}/scripts'). That requires Node and the installed scripts to be present; if your agent environment does not permit executing local Node modules, agent-native instructions may not be usable as-is. - Installation: The provided install step runs npm install --production in scripts/ and pulls packages like sharp (native image library) and xlsx. This is a standard npm install (no arbitrary archive downloads), but sharp can trigger native compilation — run it in a safe environment and inspect scripts/package.json before installing. - Code review: The repository is self-contained and readable; the network call to Anthropic is explicit in scripts/extraction/scanner.js and the SKILL.md documents the external endpoint. If you must comply with regulatory constraints (GDPR, PCI, internal data policies), confirm sending invoice images to Anthropic is allowed and consider redaction or using agent-native mode. - Operational behavior: Ensure you (or the agent) do not accidentally call scanInvoice() in agent-native mode (that function sends images externally). If you will only use local extraction and export, call formatOutput() on the canonical JSON as directed. If you want, I can: (a) highlight the exact lines where the network call is made, (b) list the packages from scripts/package.json that will be installed, or (c) suggest minimal package.json edits to avoid installing native modules.
Capability Analysis
Type: OpenClaw Skill Name: invoice-scan Version: 2.2.0 The invoice-scan skill is a well-engineered tool for AI-powered OCR and data extraction. It features a dual-mode architecture (agent-native vs. CLI) with clear privacy disclosures in SKILL.md regarding the transmission of PII to Anthropic's API. The codebase includes sophisticated normalization logic for international locales (base.js), image preprocessing via the sharp library (preprocess.js), and an extensive validation framework (arithmetic.js, document-rules.js) to ensure data integrity. No evidence of malicious intent, unauthorized data exfiltration, or prompt injection was found.
Capability Assessment
Purpose & Capability
Name/description match the files and behavior: this is an invoice OCR/extraction tool. Requested binary (node) and optional ANTHROPIC_API_KEY align with the two modes (CLI → Anthropic, agent-native → local). No unrelated credentials or binaries are requested.
Instruction Scope
SKILL.md explicitly separates two modes: 'agent-native' (use agent vision; do NOT call scanInvoice) and 'CLI standalone' (requires ANTHROPIC_API_KEY and sends base64 images to api.anthropic.com). That scope is reasonable, but the instructions ask the agent to require local JS (require('{SKILL_DIR}/scripts') and call formatOutput()). Calling local scripts requires a Node runtime and the installed scripts; ensure your agent environment supports executing local Node code. Also note the CLI mode transmits PII (supplier/buyer names, bank details, amounts) to Anthropic as base64 images — the SKILL.md warns about this.
Install Mechanism
Install is an npm install --production in scripts/, pulling standard packages (sharp, xlsx). This is a packaged-registry install (moderate risk vs. pure instruction-only). There are no downloads from arbitrary URLs or extract-from-unknown-host steps. Be aware 'sharp' may trigger native builds on install.
Credentials
Only ANTHROPIC_API_KEY is declared (optional), which matches needing an API key for the Anthropic/Claude provider. The code contains a small mapping for other providers (OPENAI/GEMINI env names) but they are not required by this skill. One small inconsistency: the SKILL.md treats ANTHROPIC_API_KEY as optional for agent-native mode, but the core scanInvoice() function (used by CLI) will throw if no apiKey is provided — this is expected for CLI but worth noting so the agent or a user doesn't accidentally call the CLI path without credentials.
Persistence & Privilege
Skill does not request always:true and does not modify other skills. It uses normal agent invocation. The bundle writes code to disk only if you run the npm install step; there is no automatic persistent system-wide privilege requested.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install invoice-scan
  3. After installation, invoke the skill by name or use /invoice-scan
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v2.2.0
Schema completeness checker — local validation catches missing fields at zero token cost; Retry pass for missing critical/important fields — sends focused re-extraction prompt with __NOT_ON_DOCUMENT__ sentinel; Merge + re-validate pipeline recovers fields the first pass missed; Completeness metadata in every output (score, populated, missing, retryRecovered); prepare.js agent-native mode also gets completeness warnings
v2.1.0
Programmatic documentType inference (weighted signal scoring, 12+ languages); Required field validation (amountDue, grossTotal, documentType warnings); Fixes null documentType from cron/isolated sessions
v2.0.1
Fix test for rounding threshold behaviour; 172 tests passing
v2.0.0
20 fixes from adhoc test review; Schema: paidDate, vatInclusive, discount, discountRate, vatBreakdown.type; Validation: 10 new rules; Arithmetic: rounding warnings; Excel: new fields
v1.9.0
Move charges into totals block in Excel/CSV exports (between net and gross); Add invoice/credit-note/debit-note reference support for credit and debit memos; Excel: Related Documents section with friendly labels (Original Invoice, Purchase Order); CSV: new originalInvoiceRef and referencedDocuments columns; Claude adapter: extract invoiceRef/creditNoteRef/debitNoteRef; SKILL.md: agent-native prompt updated for memo reference extraction; 7 new tests (170 total)
v1.8.1
Quiet test runner (--quiet flag); Fix: add charges[] to canonical-schema reference doc + SKILL.md output template — fixes agent-native not populating charges in exports
v1.8.0
Add charges[] array for shipping, postage, freight, handling, insurance, and surcharges; Schema: new charges field with type, label, amount, vatRate, vatAmount; Claude adapter: extract charges from documents with prompt guidance for all common names (P&P, freight, delivery, carriage, dispatch, S&H, etc.); Excel: charges appear in Header sheet; CSV: new chargesTotal and chargesDetail columns; Pre-export pipeline: auto-creates charges[] on bare objects; SKILL.md: charges in extraction checklist; 25 new tests (163 total)
v1.7.3
Add test gate to publish.sh — tests run first, publish aborts on failure; Update pipeline: tests → version bump → changelog → git push → ClawHub
v1.7.2
Add comprehensive test suite (138 tests across 11 sections); Fix prepare.js crash: ensure totals.vatBreakdown is array before validators run
v1.7.1
Fix debit-note not in accepted document types list (was triggering false 'not a standard invoice' warning); Add debit-note to due-date check alongside invoice
v1.7.0
Add pre-export pipeline — formatOutput() now auto-normalises metadata and runs validators; Agent-native and CLI mode produce identical output; New prepare.js handles: structural completeness, metadata defaults (provider, timestamp, language, documentType, confidence), bidirectional field sync (top-level ↔ metadata.*), auto-run arithmetic + document-rules validators if not already run
v1.6.0
Add stamps[] and remarks to canonical schema; Add amountDue/amountPaid validation rules (arithmetic.js + validation-rules.md); Add documentType to SKILL.md extraction checklist; Tighten Additional fields list (stamps type+text, remarks)
v1.5.2
Add documentType field to Excel and CSV output
v1.5.1
Removed unused parquet-wasm dependency; Declared ANTHROPIC_API_KEY in metadata as optional env var (CLI mode only); Fixed metadata consistency flagged by ClawHub scanner
v1.5.0
Add amountPaid & amountDue fields to totals; Fix formatters crashing on agent-native output (missing invoice.metadata fallback)
v1.4.4
Make ANTHROPIC_API_KEY optional — only needed for CLI mode, agent-native mode needs no key
v1.4.3
Fix registry metadata: add metadata.clawdbot block with required env vars (ANTHROPIC_API_KEY), install spec (npm install), and external endpoints declaration (api.anthropic.com + PII data types). This should resolve the suspicious flag.
v1.4.2
Fix suspicious flags + security review: added privacy notice (PII/data flow to Anthropic), clarified agent-native vs CLI modes, declared env var and install reqs, corrected package.json paths. Supersedes 1.2.1/1.2.2 which were misnumbered.
v1.2.2
Address security review: added privacy notice, clarified agent-native mode, declared env var and install reqs in description
v1.2.1
Fix suspicious flags: corrected package.json main/bin paths, clarified agent-native vs CLI modes with clear separation, added explicit npm install setup step, removed env var ambiguity (ANTHROPIC_API_KEY only needed for CLI mode)
Metadata
Slug invoice-scan
Version 2.2.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 29
Frequently Asked Questions

What is Invoice Scan?

AI-powered invoice OCR, scanning, and data extraction. Use when: (1) user needs OCR or text extraction from invoice images, scanned documents, or PDFs, (2) s... It is an AI Agent Skill for Claude Code / OpenClaw, with 512 downloads so far.

How do I install Invoice Scan?

Run "/install invoice-scan" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Invoice Scan free?

Yes, Invoice Scan is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Invoice Scan support?

Invoice Scan is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Invoice Scan?

It is built and maintained by mr-muddle (@mr-muddle); the current version is v2.2.0.

💬 Comments