JP Sámano

← All work

Legal document pipelines

Organized and extracted metadata from two confidential legal archives with Claude vision and the Batch API: 13,288 documents for a telecom operator and 903 notarial records for a security-services group.

Role
Engineer, LegalShelf
Period
Jun – Jul 2026
Status
Delivered

An archive becomes a verifiable delivery

Original archive

Reconcile the index, plan the folders, copy the files. Leave originals untouched.

Choose how to read each page

Legible text

Read the text layer

Scanned page

Render → Claude vision

Extract structured fields

Batch processing; work can stop and resume.

Verify before delivery

Compare file hashes and reconcile the folder tree, plan and workbook.

Organized files + linked workbook

Two delivered archives: 13,288 documents and 903 notarial records.

  1. Reconcile
  2. Plan
  3. Copy
  4. Read
  5. Extract
  6. Verify
  7. Deliver
System diagram. Copy-only processing, two reading paths, one verified output.
documents processed
14,191
files hash-verified
903/903
fields per document
10
first archive, build and run
3 days

Historical figures as of 11 September 2026.

Problem

A telecom operator's legal department had more than 13,000 scanned contracts, corporate instruments and regulatory filings, indexed by a spreadsheet nobody trusted. A second client kept its notarial deeds and corporate-book entries on a USB drive, with duplicates and no structure.

Constraints

  • Confidential client documents: nothing may be moved or modified, only copied.
  • Most pages are scans with no text layer.
  • The client's own index was unreliable but still useful as a hint.
  • A fixed budget per document, and a pipeline that can stop and resume at any point.

Decisions

  1. A hybrid reader instead of a separate OCR step

    Pages with legible text are read as text; scans are rendered and sent to Claude vision. It removed a whole OCR stage and its error modes.

  2. The Batch API, and the client's index as a prior

    Batching halved the cost, and passing the client's existing index as a hint let the model verify and correct it instead of starting blind.

  3. Copy-only, with a hash gate before anything is touched

    The organizer only ever copies, and a verification gate compares every file by hash. For the notarial archive it passed 903 of 903 with zero mismatches.

Outcome

The telecom archive was organized into 12 legal areas with 10 fields extracted per document, delivered with a reconciled master workbook. The notarial archive was classified into notarized, corporate and spare documents with five fields each and delivered through a linked workbook. When the first client flagged annex handling, I traced the cause and designed a second phase that reconciles every annex one to one.

Evidence

  • 13,288 documents extracted; a QA audit found zero mismatches between folder tree, plan and workbook.
  • 903 of 903 notarial files verified by hash before delivery.
  • Client names and documents are confidential; the pipeline design is available to walk through.

Stack

Python · Claude API · Batch API · PyMuPDF · openpyxl · Google Apps Script