An accountant gets a stack of invoices, delivery notes and receipts, and retypes them into a spreadsheet. Hours of work where nobody uses their experience.

This setup replaces the retyping. You point it at a folder of scans and phone photos. You get back one Excel register, files renamed and sorted by month, and a "to check" list for the unreadable ones. The data entry is automated. The checking stays with a person.

What you build

Three free pieces working together:

  • A field schema. An LLM turns "what do we need from these documents" into a JSON schema.
  • DocStrange. An open Python library that turns PDFs, scans, phone photos, Word and Excel files into clean text and tables, and can pull only the fields in your schema.
  • Two Claude skills. invoice-organizer renames and sorts files. xlsx builds the Excel file with formulas.

You need Claude Code (a paid Claude plan), Python, and 10 to 20 sample documents. Copies, not originals.

DocStrange has two modes:

  • Cloud. Free up to 10,000 documents a month after docstrange login (Google sign-in) or with a free API key. Documents go to the server of Nanonets, the developer.
  • Local. Everything stays on your machine. Fastest on a CUDA graphics card. The library also has a CPU mode.

Step 1: define the fields

What to extract is a decision for you and whoever owns the documents. Ask any strong LLM to write it down in a machine-readable form. Fix the bracketed parts:

I am setting up an agent that reads invoices and delivery notes of a client [accounting firm / logistics company] and moves the data into a table. I need: 1. A list of fields to extract: document number, date, supplier, supplier tax ID, amount without VAT, VAT, total amount, currency, purpose. Add [my own fields]. 2. A JSON schema where every field has a type: "string" or "number", for example {"invoice_number": "string", "total_amount": "number"}. Give document line items as a list of objects. 3. Rules for disputed cases: mark an unreadable value as "[check]", never guess an amount, and move duplicates and documents outside the reporting period to a separate list. 4. A short list of questions I need to clarify with the client. 

Save the JSON as schema.json. Show the field list to the document owner. It also tells you what matters to them.

Step 2: install

Make a folder such as scan-test, open Claude Code in it and paste:

Prepare the environment for working with documents. 1. Install the Python package docstrange (pip install docstrange). 2. Download the invoice-organizer skill (https://aiskills.team/en/claude-skills/invoice-organizer) and put its folder into ~/.claude/skills/invoice-organizer. 3. Take the official `xlsx` skill from Anthropic's `anthropics/skills` repository and put its folder into ~/.claude/skills/xlsx. Before each step say what you are about to do. If a skill asks to install extra programs, ask me. Do not change or delete anything outside these folders. After installation read the SKILL.md of each skill and briefly retell what it can do, and check that the docstrange command runs. 

You should get a short report on three items. The Excel skill recalculates formulas with LibreOffice, so Claude Code may ask to install it. Allow it.

For cloud mode, sign in once:

docstrange login 

A browser opens, you sign in with Google. Or use a free API key from your DocStrange account. Treat the key like a password and never paste it into a chat.

Step 3: run it on a stack

Put the 10 to 20 document copies into an incoming folder, then give Claude Code this:

In the incoming folder there are invoices and delivery notes: PDFs, scans and photos. Work step by step. 1. For each file, extract the fields from the schema in schema.json through docstrange (cloud mode) and save the result in the data folder. Mark unreadable values "[check]" and do not guess amounts. 2. With the invoice-organizer skill, show a plan: how you will rename the files by the template "YYYY-MM-DD Supplier - Invoice - Description" and sort the copies into folders by month. Do not touch the originals. Wait for my "yes". 3. After "yes", carry out the plan and with the xlsx skill build the file reestr.xlsx: a "Register" sheet with all rows, a "Totals by month" sheet with formulas, and a "To check" sheet with problem documents. At the end write how many files were processed and how many went to "To check". 

First you see the renaming plan. After "yes" you get month folders and reestr.xlsx. Then open the table and compare 10 documents with the originals by hand: amount, date, supplier. Do this every time.

For a stack of receipts there is a separate expense-report skill that flags missing receipts, limit overruns and duplicates. It needs the company's expense policy as input.

When there are thousands of documents

Dozens of files fit the flow above. For thousands, look at Unstract. You describe fields in plain words (a tool called Prompt Studio), send a document through an API, and get JSON back. It has a pipeline that picks files from a folder or cloud storage.

According to its README you need Linux or macOS, Docker, 8 GB of memory, and a key for an AI model or a local Ollama. It starts with one command:

./run-platform.sh 

The default login is unstract/unstract. Change the password immediately. The licence is AGPL-3.0, so read its terms before you modify the code and offer it as a service.

Where it breaks

  • docstrange not found. Close and reopen the terminal, or ask Claude Code where pip put the package.
  • Scans read badly. Check the photo quality, repeat in local mode and compare.
  • Cloud limit or refusal. Run docstrange login again.
  • Formula errors in the table. Ask Claude Code to recalculate the file and list the cells with errors.

Limits you should respect

  • The agent enters data. The accountant stays responsible for the numbers. The expense skill does not judge tax deductions.
  • Cloud mode sends documents to a third-party server. Contracts, passport data and anything marked confidential go through local mode, or need consent.
  • What Claude Code reads goes to the Claude model. Tell the owner of the documents before a test run.
  • Never publish real documents in chats or portfolios. Never paste keys into chats.

Result

A folder of mixed scans becomes reestr.xlsx with a register, monthly totals with formulas, and a "To check" sheet. Files are renamed YYYY-MM-DD Supplier - Invoice - Description and sit in month folders.

The full walkthrough with all three prompts is on our blog: Agent that turns documents into a table

Your turn

Scan or photograph 10 of your own old receipts or invoices, drop them in incoming, and run step 3. Then count how many landed in "To check" and which field failed most often. That tells you what to fix in schema.json.

This article was written with the help of AI and fact-checked by the AI SKILLS team.