Our tax assessments, health insurance letters, contracts, and certificates lived in binders and loose piles.
I now have a pipeline that turns a pile into searchable, tagged documents in Paperless-ngx, a self-hosted document archive. Two batches in, the archive holds 80 documents from 181 scanned pages.
The pipeline
- Scan. A shell script runs a scan loop. One key scans in grey, another in colour, and a third marks the start of a new document. It talks to the scanner over SANE on Linux and over eSCL (AirScan) on the Mac.
- OCR. Apple’s Vision framework reads each page, in German and English.
- Group. Claude reads the OCR text of the new pages and decides which pages belong together, who sent each document, what type it is, which tags fit, and the date the document itself carries.
- Assemble. A script builds one PDF per document.
- Upload. Another script sends the PDFs to Paperless. It is idempotent: it uploads only what is not there yet.
- Copy. A last script copies every PDF into a folder per person in iCloud Drive, so I can open them on a phone without logging in anywhere.
A file called manifest.json is the source of truth. Scripts rebuild both Paperless and the iCloud folders from it.
One entry looks like this. The values here are invented, but the fields are the real ones:
{
"pages": ["page_0156_gray.jpg", "page_0158_gray.jpg", "page_0159_gray.jpg"],
"pile_range": "0156,0158-0159",
"asn": 156,
"title": "Bescheid für 2024 über Einkommensteuer",
"correspondent": "Finanzamt Frankfurt am Main",
"document_type": "Steuerbescheid",
"created": "2025-06-12",
"tags": ["Steuer"],
"confidence": "high",
"notes": "Page 0157 is a second scan of 0156 and is left out.",
"pdf_path": "pdfs/0156-einkommensteuer-2024.pdf",
"paperless_document_id": 142
}
Keeping the taxonomy tidy
An LLM left alone will invent a new correspondent for every letter. “Finanzamt”, “Finanzamt Frankfurt”, and “Tax office” would all appear. So before each batch, the grouping prompt receives every correspondent, document type, and tag that already exists, and Claude matches new documents to them where it can.
Each document also records where it sat in the physical pile. Paperless’s archive serial number holds the first position, and a custom field holds the full range, such as 0156,0158-0161 for a document whose pages were not together. If I need the paper original, I know which pile and roughly where.
What went wrong
Duplicate scans. I sometimes scanned the same page twice. Comparing OCR text fails to catch it, because German agencies reuse almost identical legal boilerplate across different letters, years, and recipients. Comparing image hashes of the raw scans works much better. I still check by eye before excluding anything.
No scanner driver on the Mac. I scanned the first batch on an old Linux box. For the second batch there was no working SANE driver for my scanner on macOS. Claude wrote a direct HTTP client for eSCL, the protocol behind AirScan, so the Mac now scans without a driver.
Half-finished uploads. When the Paperless server ran out of memory mid-batch, a document could land on the server while the script recorded a timeout. The rerun then said “It is a duplicate of #N”. The fix is to record N in the manifest instead of uploading again.
Where it lives
Paperless runs on a server I host. Claude sessions in my other projects can search it through a read-only tool. When one of them needs a figure from a tax assessment, it looks the document up and cites its Paperless id instead of asking me.
The cost
The grouping step is a headless claude -p call, so it runs on my Claude subscription rather than per-token API billing. A batch costs about a dollar’s worth of usage.
The AI part
I fed the scanner. Claude wrote the scan loop, the eSCL client, the grouping prompt, the PDF assembly, the uploader, and the reconciliation steps. It also wrote the runbook I follow for the next batch.