Skip to main content
skill CX Codex

llm-document-extraction — Claude Code skill

The llm-document-extraction skill parses unstructured PDFs—RFIs, submittals, contracts, specifications—into structured JSON and Excel. Uses LLMs to analyze text, classify document types, and extract fields automatically.

MIT 125 installs ★ 434 updated 2026-10-19

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill llm-document-extraction -a claude-code
Open on GitHub

What llm-document-extraction does

Construction documents hold critical data buried in inconsistent formats. The skill deploys LLM to pull out key information: RFI numbers, approval dates, contract parties, material specs, cost impacts. Under the hood: Python functions for PDF parsing via pdfplumber, GPT-4o prompts with JSON schemas, batch workflows in n8n, and RAG pipelines through Qdrant for handling large documents. You'll need your OpenAI API key in the OPENAI_API_KEY environment variable, plus QDRANT_URL if indexing larger files. Python 3 must be in your system path. Comes with ready-made schemas for RFIs, submittals, and contracts.

What it helps with

  • Pull RFI numbers, dates, and approval statuses from PDFs
  • Turn a messy contract PDF into structured JSON with amounts and payment terms
  • Batch-process a folder of construction documents and save results to a database
  • Read room dimensions and areas from floor plan images

Example prompts for the agent

  • Extract contract amount, start date, completion date, and retention percentage from this PDF
  • Process all RFIs in this folder and write number, date, question, response to a spreadsheet
  • Analyze this floor plan image and list rooms with their square footage

How to install llm-document-extraction

1Skills CLI (Vercel)

npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill llm-document-extraction -a claude-code

2Manually: put the files in place

~/.claude/skills/llm-document-extraction/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/llm-document-extraction/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about llm-document-extraction

How do I install llm-document-extraction?

Run npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill llm-document-extraction -a claude-code, then open ~/.claude/skills/llm-document-extraction/SKILL.md.

What does llm-document-extraction do?

It extracts structured data from construction PDFs—RFIs, submittals, contracts, specifications—and converts them to JSON or writes them to a database.

What environment variables do I need?

OPENAI_API_KEY is required to call the LLM. If you use RAG and vector indexing for large documents, also set QDRANT_URL to point to your vector database.

Source text

SKILL.md · MIT
---
name: "llm-document-extraction"
description: "Extract structured data from construction documents using LLMs. Process RFIs, submittals, contracts, specifications. Convert unstructured PDFs to structured JSON/Excel."
homepage: "https://datadrivenconstruction.io"
metadata: {"openclaw": {"emoji": "🤖", "os": ["darwin", "linux", "win32"], "homepage": "https://datadrivenconstruction.io", "requires": {"bins": ["python3"], "env": ["OPENAI_API_KEY", "QDRANT_URL"]}, "primaryEnv": "OPENAI_API_KEY"}}
---
# LLM Document Extraction

## Overview

Construction documents (RFIs, submittals, specs, contracts) contain critical data trapped in unstructured formats. This skill uses LLMs to extract structured data automatically.

> "The construction industry is drowning in a flood of new data: the volume of information has grown from 15 zettabytes in 2015 to 181 zettabytes in 2025, and 90% of all existing data has been created in just the last few years." — Artem Boiko

## Use Cases

| Document Type | Extract |
|---------------|---------|
| RFI | Question, response, dates, parties |
| Submittal | Product specs, approval status, materials |
| Contract | Parties, amounts, dates, scope, clauses |
| Specification | Materials, standards, requirements |
| Daily Report | Weather, labor, equipment, progress |

## Quick Start

```python
from openai import OpenAI
import pdfplumber
import json

client = OpenAI()

def extract_from_pdf(pdf_path: str, extraction_schema: dict) -> dict:
    """Extract structured data from PDF using LLM"""

    # Extract text from PDF
    with pdfplumber.open(pdf_path) as pdf:
        text = "\n".join(page.extract_text() for page in pdf.pages)

    # Build extraction prompt
    prompt = f"""
    Extract the following information from this construction document.
    Return ONLY valid JSON matching the schema.

    Schema:
    {json.dumps(extraction_schema, indent=2)}

    Document:
    {text[:8000]}  # Truncate for context limits

    JSON Output:
    """

    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[
            {"role": "system", "content": "You are a construction document analyst. Extract data accurately."},
            {"role": "user", "content": prompt}
        ],
        response_format={"type": "json_object"}
    )

    return json.loads(response.choices[0].message.content)
```

## Extraction Schemas

### RFI Schema

```python
rfi_schema = {
    "rfi_number": "string",
    "date_submitted": "YYYY-MM-DD",
    "date_required": "YYYY-MM-DD",
    "from_company": "string",
    "to_company": "string",
    "subject": "string",
    "question": "string",
    "response": "string or null",
    "status": "open|closed|pending",
    "cost_impact": "boolean",
    "schedule_impact": "boolean",
    "attachments": ["list of attachment names"]
}

# Extract
rfi_data = extract_from_pdf("RFI-0042.pdf", rfi_schema)
```

### Submittal Schema

```python
submittal_schema = {
    "submittal_number": "string",
    "spec_section": "string",
    "description": "string",
    "manufacturer": "string",
    "product_name": "string",
    "model_number": "string",
    "submitted_by": "string",
    "date_submitted": "YYYY-MM-DD",
    "status": "approved|approved_as_noted|revise_resubmit|rejected",
    "reviewer_comments": "string or null",
    "materials": [
        {
            "name": "string",
            "specification": "string",
            "quantity": "string"
        }
    ]
}
```

### Contract Schema

```python
contract_schema = {
    "contract_number": "string",
    "project_name": "string",
    "owner": {
        "name": "string",
        "address": "string"
    },
    "contractor": {
        "name": "string",
        "address": "string"
    },
    "contract_amount": "number",
    "start_date": "YYYY-MM-DD",
    "completion_date": "YYYY-MM-DD",
    "liquidated_damages": "number per day",
    "retention_percentage": "number",
    "key_clauses": [
        {
            "clause_number": "string",
            "title": "string",
            "summary": "string"
        }
    ]
}
```

## Batch Processing with n8n

```json
{
  "workflow": "Document Extraction Pipeline",
  "trigger": "Watch folder for new PDFs",
  "nodes": [
    {
      "name": "Read PDF",
      "type": "Read Binary Files"
    },
    {
      "name": "Classify Document",
      "type": "AI Agent",
      "prompt": "Classify this document: RFI, Submittal, Contract, Spec, or Other"
    },
    {
      "name": "Route by Type",
      "type": "Switch",
      "rules": ["RFI", "Submittal", "Contract", "Spec"]
    },
    {
      "name": "Extract RFI",
      "type": "OpenAI",
      "schema": "rfi_schema"
    },
    {
      "name": "Extract Submittal",
      "type": "OpenAI",
      "schema": "submittal_schema"
    },
    {
      "name": "Save to Database",
      "type": "PostgreSQL",
      "operation": "insert"
    },
    {
      "name": "Update Dashboard",
      "type": "HTTP Request",
      "method": "POST"
    }
  ]
}
```

## Vision Model for Drawings

```python
import base64

def extract_from_drawing(image_path: str, query: str) -> str:
    """Extract information from drawings using vision model"""

    with open(image_path, "rb") as f:
        image_data = base64.standard_b64encode(f.read()).decode()

    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": query},
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": f"data:image/png;base64,{image_data}"
                        }
                    }
                ]
            }
        ]
    )

    return response.choices[0].message.content

# Example: Extract room areas from floor plan
areas = extract_from_drawing(
    "floor_plan.png",
    "List all rooms with their areas in square meters. Return as JSON."
)
```

## RAG for Large Documents

```python
from langchain_community.document_loaders import PyPDFLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_openai import OpenAIEmbeddings
from langchain_community.vectorstores import Qdrant

def create_document_index(pdf_path: str):
    """Create searchable index for large documents"""

    # Load and split
    loader = PyPDFLoader(pdf_path)
    docs = loader.load()

    splitter = RecursiveCharacterTextSplitter(
        chunk_size=1000,
        chunk_overlap=200
    )
    chunks = splitter.split_documents(docs)

    # Create vector store
    embeddings = OpenAIEmbeddings()
    vectorstore = Qdrant.from_documents(
        chunks,
        embeddings,
        collection_name="contract_docs"
    )

    return vectorstore

def query_document(vectorstore, question: str) -> str:
    """Query document with RAG"""

    retriever = vectorstore.as_retriever(search_kwargs={"k": 5})
    docs = retriever.invoke(question)

    context = "\n".join(doc.page_content for doc in docs)

    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[
            {"role": "system", "content": "Answer based on the contract excerpts provided."},
            {"role": "user", "content": f"Context:\n{context}\n\nQuestion: {question}"}
        ]
    )

    return response.choices[0].message.content

# Usage
index = create_document_index("contract_100pages.pdf")
answer = query_document(index, "What are the liquidated damages terms?")
```

## Requirements

```bash
pip install openai pdfplumber langchain langchain-openai qdrant-client
```

## Resources

- OpenAI Vision: https://platform.openai.com/docs/guides/vision
- LangChain RAG: https://python.langchain.com/docs/tutorials/rag/

© datadrivenconstruction · MIT · datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction

Similar skills

All skills for AI and ML →

From the same set156

The whole set →
meeting-minutes-generator The meeting-minutes-generator skill generates structured meeting minutes for construction projects, tracking decisions and action items. Requires Python 3. CX Codex +1 126installs bim-visual-programming-automation bim-visual-programming-automation automates BIM tasks with Dynamo Python nodes and Revit API routines. Extracts element quantities, calculates take-offs, and batch updates parameters. CX Codex +1 126installs pdf-construction pdf-construction extracts data from RFI forms, splits drawing sets by sheet, parses CSI specifications, and builds submittal packages from construction PDFs. CX Codex +1 126installs punch-list-manager punch-list-manager is a Claude Code skill that tracks construction deficiencies from site walks through final acceptance, including assignments, deadlines, photos, and verification. CX Codex +1 125installs quality-control-workflow The quality-control-workflow skill structures construction quality control from inspection planning to defect resolution, with records for findings, NCRs, and specification checks. CX Codex +1 125installs 4d-simulation 4d-simulation links building models to project schedules and visualizes construction sequences day by day. Detects scheduling conflicts and analyzes work phases. CX Codex +1 125installs image-to-data The image-to-data skill analyzes construction site photos, scanned documents, and drawings, extracting text, tables, and detected objects using computer vision and OCR. CX Codex +1 125installs xml-reader xml-reader — a skill for Claude Code, Cursor, Codex and other platforms that reads XML from P6, IFC, COBie and buildingSMART Data Dictionary. Converts elements to pandas DataFrames. CX Codex +1 125installs

Project sponsors

Companies that keep this analytics open