agentleFS
doculentdoculent/community/skills/doc-extract/SKILL.md

doc-extract

Skill1 starsChanged 9 months agoMITView on GitHub

Extract structured data from documents using built-in presets or custom schemas. Supports invoices, contracts, resumes, legal filings, and any user-defined schema. Outputs consistent JSON or CSV. Handles batch processing across multiple files.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. anthropics/healthcare★ 417same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository4 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use the same extraction approach as doc-parse:

    line 161
  2. Distinctive:

    If the user provided:

    line 170
  3. Distinctive:

    Read the document content and extract values matching each field in the schema.

    line 177
  4. Very specific:

    Null: If a field cannot be found in the document, set to null — never fabricate data

    line 184
  5. Distinctive:

    When processing multiple files:

    line 222
  6. Very specific:

    If a field can't be found, set to null and add a warning — never guess

    line 240
  7. Distinctive:

    If the document doesn't match the preset type (e.g., invoice preset on a resume), warn the user

    line 241
  8. Distinctive:

    If OCR quality is poor, flag low confidence and still attempt extraction

    line 242

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

doc-extract: Schema-Based Document Data Extraction

You are a data extraction specialist. Your job is to pull structured, consistent data from documents according to a defined schema — either a built-in preset or a user-provided field list.

Input

The user will provide:

  • Target files — file paths, glob patterns, or directories
  • Schema — one of:
    • A preset name: --preset invoice, --preset contract, --preset resume, --preset legal, --preset receipt
    • Custom fields: --fields "vendor, amount, due_date, line_items"
    • A JSON schema file: --schema schema.json
  • Output format — --format json (default), --format csv, or --format markdown
  • Output path — optional, defaults to ./extracted.<format>

Built-in Presets

invoice

{
  "vendor_name": "string",
  "vendor_address": "string",
  "invoice_number": "string",
  "invoice_date": "date",
  "due_date": "date",
  "currency": "string",
  "subtotal": "number",
  "tax": "number",
  "total": "number",
  "line_items": [
    {
      "description": "string",
      "quantity": "number",
      "unit_price": "number",
      "amount": "number"
    }
  ],
  "payment_terms": "string",
  "notes": "string"
}

contract

{
  "title": "string",
  "parties": ["string"],
  "effective_date": "date",
  "expiration_date": "date",
  "auto_renewal": "boolean",
  "renewal_terms": "string",
  "total_value": "number",
  "currency": "string",
  "payment_schedule": "string",
  "termination_clause": "string",
  "liability_cap": "string",
  "governing_law": "string",
  "key_obligations": ["string"],
  "confidentiality": "boolean",
  "non_compete": "boolean"
}

resume

{
  "name": "string",
  "email": "string",
  "phone": "string",
  "location": "string",
  "summary": "string",
  "experience": [
    {
      "company": "string",
      "title": "string",
      "start_date": "date",
      "end_date": "date|present",
      "highlights": ["string"]
    }
  ],
  "education": [
    {
      "institution": "string",
      "degree": "string",
      "field": "string",
      "graduation_date": "date"
    }
  ],
  "skills": ["string"],
  "certifications": ["string"]
}

legal

{
  "case_number": "string",
  "court": "string",
  "filing_date": "date",
  "document_type": "string",
  "parties": {
    "plaintiff": ["string"],
    "defendant": ["string"]
  },
  "judge": "string",
  "claims": ["string"],
  "relief_sought": "string",
  "ruling": "string",
  "key_dates": [
    {
      "event": "string",
      "date": "date"
    }
  ]
}

receipt

{
  "merchant": "string",
  "date": "date",
  "items": [
    {
      "name": "string",
      "quantity": "number",
      "price": "number"
    }
  ],
  "subtotal": "number",
  "tax": "number",
  "total": "number",
  "payment_method": "string"
}

Process

Step 1: Read the Document

Use the same extraction approach as doc-parse:

  • Text-based PDFs: pdftotext -layout
  • Scanned PDFs/images: pdftoppm + tesseract
  • Markdown/text files: read directly

For large documents, extract text first and then analyze.

Step 2: Determine Schema

If the user provided:

  • A preset name → use the matching schema above
  • Custom fields → build a flat JSON schema from the field names, inferring types from field names (e.g., date, amount, total suggest number/date types)
  • A schema file → read and parse it

Step 3: Extract Data

Read the document content and extract values matching each field in the schema.

Extraction rules:

  • Dates: Normalize to ISO 8601 (YYYY-MM-DD). Handle "January 5, 2026", "01/05/2026", "5 Jan 2026", etc.
  • Numbers: Strip currency symbols and commas. Store as plain numbers. Store currency separately.
  • Arrays: Extract all matching items (e.g., all line items, all parties)
  • Booleans: Infer from presence/absence of clauses (e.g., "confidentiality" section exists → true)
  • Null: If a field cannot be found in the document, set to null — never fabricate data

Step 4: Validate

After extraction, validate:

  • Required fields have values (warn if missing, don't fail)
  • Dates are valid ISO 8601
  • Numbers are parseable
  • Line items / arrays have consistent structure
  • Totals add up where applicable (e.g., subtotal + tax = total)

Flag any inconsistencies:

⚠ Line items sum to $4,231.00 but invoice total shows $4,331.00

Step 5: Write Output

JSON output (default):

{
  "source": "invoice-001.pdf",
  "extracted_at": "2026-03-31T14:30:00Z",
  "preset": "invoice",
  "confidence": "high",
  "data": { ... },
  "warnings": []
}

CSV output (for batch): Flatten nested objects. One row per document. Arrays become semicolon-delimited strings.

Markdown output: Render as a clean markdown table or key-value list.

Batch Mode

When processing multiple files:

  1. Extract each file against the same schema
  2. Report progress: Extracting 5/23: receipt-005.pdf...
  3. Aggregate results:
    • JSON: array of extraction objects
    • CSV: one row per document, header row from schema fields
  4. Report summary:
    ✓ Extracted 23/23 files
      Preset: invoice
      Format: csv
      Output: invoices.csv
      Warnings: 2 files had missing fields

Error Handling

  • If a field can't be found, set to null and add a warning — never guess
  • If the document doesn't match the preset type (e.g., invoice preset on a resume), warn the user
  • If OCR quality is poor, flag low confidence and still attempt extraction
  • Report which fields were found vs. missing for each document

Custom Schema Example

User says: /doc-extract --fields "tenant_name, unit_number, monthly_rent, lease_start, lease_end, security_deposit" ./leases/

Build schema:

{
  "tenant_name": "string",
  "unit_number": "string",
  "monthly_rent": "number",
  "lease_start": "date",
  "lease_end": "date",
  "security_deposit": "number"
}

Then extract each file against this schema.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.