andrewyng/context-hub/document-workflows
Claude Code and agent skill by andrewyng/context-hub
- community
Checking that the SKILL.md file is still in the repository.
Use this skill for building end-to-end document processing workflows and pipelines using LandingAI ADE. Trigger when users need to: (1) Process batches of documents in parallel or async, (2) Build classify-then-extract pipelines for mixed document types, (3) Prepare parsed documents for RAG systems with chunking and vector DB ingestion, (4) Load extraction results into databases like Snowflake or export to CSV/DataFrames, (5) Visualize extraction results: draw bounding box overlays on pages, cr…
Install
npx vskill@latest install andrewyng/context-hub/document-workflowsSKILL.md
The same SKILL.md was published earlier as andrewyng/context-hub/document-workflows.
Document Workflows — ADE Pipeline Patterns
Overview
This skill provides reusable building blocks for composing LandingAI ADE primitives (parse, extract, split) into production-ready document processing pipelines. It complements the document-extraction skill:
| Concern | document-extraction | document-workflows | |
|---|---|---|---|
| Scope | ADE SDK API: parse, extract, split, grounding | End-to-end pipelines: batch, RAG, DB, classify-route | |
| When | Need to call a single ADE operation | Need to compose operations into a workflow | |
| Code | SDK method calls with parameters | Complete functions with error handling, parallelism | |
| Deps | landingai-ade only | + workflow-specific libs (pandas, chromadb, etc.) |
Philosophy: Organize by workflow pattern (batch, RAG, DB insertion), not by document type. The same pattern applies whether documents are invoices, utility bills, or medical forms.
Step 0 (mandatory) — Pre-Flight Document Exploration {#pre-flight}
Run this before writing any pipeline code whenever working with documents whose internal structure has not already been inspected in this session.
**Rule: never write section-detection, heading-matching, or text-search codewithout first running Tool 2 (diagnostic parse) on the sample document.Heading format is document-specific and cannot be inferred from the taskdescription or document type alone — the only reliable way to know it is tolook at the actual ADE output.**Common surprises: a paper's "Introduction" heading may appear as1. Introduction(plain text, no#),## Introduction,INTRODUCTION(all-caps), or embedded inside a text chunk with body copy. Getting thiswrong means a silent failure (zero chunks matched) that requires a fullre-parse to debug.
Run Tool 1 (visual render) and Tool 2 (diagnostic parse) on 1–3 representative sample documents before writing any code. This takes under a minute and prevents debugging iterations that a pre-flight would have avoided.
Tool 1 — Visual page render
Render 1–2 pages as PNG and read them as visual context. No ADE credits used, but each PNG consumes context tokens. Use when layout is ambiguous or document origin is unknown (handwriting? scan? form?).
Then read the saved PNGs. Immediately answers:
- Are headings bold text (→ ADE may output plain-text heading, not
# Heading) - Is the document handwritten or scanned? → Tesseract OCR needed, not PyMuPDF
- Single-column or two-column layout?
- Any noise: running headers, page numbers, watermarks, stamps?
Tool 2 — ADE diagnostic parse
Parses 1 sample and prints markdown structure + chunk inventory. Uses ADE credits — keep to 1–3 samples only, never the full corpus.
Cost note: Save the parse result withpr.model_dump()to a JSON fileafter the first run. Load it for later development instead of callingclient.parse()again. Only re-parse when the document set changes.
What to look for
| Observation | Implication | |
|---|---|---|
Heading is 1. Introduction (plain text, no #) | ADE markdown won't use ATX header → use ADE extract, not regex | |
Heading format varies across docs (# INTRO in one, 1. Intro in another) | Regex will break on some docs → use ADE extract for robustness | |
Every ch.markdown starts with <a id='...'></a> | Strip anchor before string matching or display | |
Two-column: chunks on same page with l=0.07 vs l=0.50 | Text order is left column then right; sections may span both | |
| Chunk text cut mid-word at page break | Section spans pages; collect chunks from multiple pages | |
marginalia chunks at t<0.08 or t>0.90 | Running headers / page numbers → exclude from content extraction | |
| Scanned / handwritten content visible in page image | PyMuPDF text extraction won't work → use Tesseract OCR |
Tool 3 — Post-Crop Visual Verification (mandatory for bounding-box workflows) {#post-crop-verification}
After producing any bounding-box crop or overlay (figure extraction, chunk cropping, table cell extraction, word-level grounding), read back at least one output PNG as an image and describe what you see. Compare your description against the user's request. This catches:
- Wrong-page bugs — ADE page numbers are 0-indexed; an off-by-one error
lands the crop on an adjacent page with completely different content
- Wrong-region bugs — coordinate system mismatches that crop blank space
or an unrelated section
**Rule: never declare a crop workflow complete without visually reading atleast one output PNG and confirming its content matches the user's request.**
Verification steps
- Save the first crop as PNG (the workflow already does this)
- Read the PNG file as an image (use the
read_filetool on the PNG path) - Describe what you see: what content, table, figure, or text appears?
- Compare against the user's request:
- User asked for "the Events table" → does the crop show an Events table?
- User asked for "Figure 3" → does the crop show a chart/diagram?
- User asked for "Introduction section" → does the crop show intro text?
- If the description doesn't match → investigate page indexing and
bounding-box coordinates before continuing
- Only proceed with remaining crops after the first one is verified
Why LLM vision, not heuristics
A blank-check heuristic (e.g. "mean brightness > 250 → blank") catches only the most obvious failures. The agent's own vision capability can semantically verify: "this crop shows a bar chart" vs "the user asked for a data table." This catches wrong-page errors even when the crop contains valid content from the wrong section.
Quick Reference — Building Blocks
| # | Block | Pattern | Reference | |
|---|---|---|---|---|
| 0 | Pre-flight (mandatory) | Render pages + diagnostic parse before building | Above | |
| 1 | Parse + Save | Single doc → JSON + markdown | Below | |
| 2 | Parse + Extract + Save | Single doc → structured data | Below | |
| 3 | Batch (sync) | ThreadPoolExecutor + tqdm | batch-processing.md | |
| 4 | Batch (async) | AsyncLandingAIADE + aiolimiter | batch-processing.md | |
| 5 | Large files | Parse Jobs API (async polling) | batch-processing.md | |
| 6 | Classify → Extract | Enum classification + schema routing | Below | |
| 7 | Results → DataFrame | Flatten nested extraction to tables | database-integration.md | |
| 8 | Results → CSV | Summary + per-document export | database-integration.md | |
| 9 | Results → Snowflake | 4 normalized tables + COPY upload | database-integration.md | |
| 10 | Chunks → RAG CSV | 19-column chunk dataset | rag-pipelines.md | |
| 11 | Chunks → ChromaDB | OpenAI embeddings + persistent store | rag-pipelines.md | |
| 12 | Chunks → FAISS | LangChain Documents + FAISS index | rag-pipelines.md | |
| 13 | RAG query | RetrievalQA chain with sources | rag-pipelines.md | |
| 14 | Chunk images | Crop chunks from pages as PNGs | visualization.md | |
| 15 | Grounding overlay | Color-coded bounding boxes on pages | visualization.md | |
| 16 | Word-level grounding | OCR + fuzzy match highlighting | visualization.md | |
| 17 | Section extraction | Named section from markdown (regex or ADE extract) | Below | |
| 18 | Embedding computation | Local (FastEmbed) or API (OpenAI) with best practices | rag-pipelines.md | |
| 19 | Hierarchical chunking | Group ADE chunks into semantic units for embedding | rag-pipelines.md | |
| 20 | Multi-granularity RAG | Chunk vs hierarchical vs document-level strategy | rag-pipelines.md | |
| 21 | Table stitching | Parse-only or parse+extract merge of multi-page tables | table-stitching.md | |
| — | Schema catalog | Ready-to-use Pydantic models | schema-catalog.md |
Core Workflow: Parse + Extract + Save
The fundamental two-step ADE pattern. Every other workflow builds on this.
`save_to` parameter: Available onparse(),extract(), andsplit().Creates the folder if needed and writes{input_filename}_{method}_output.json.This is a client-side convenience — the full response is saved locally after the API call.
Parse-Only (no extraction)
Schemas: See schema-catalog.md forready-to-use Pydantic models (invoice, utility bill, bank statement,pay stub, food label, CME certificate, document classifier).See thedocument-extractionskill for schema design rules.
Classify-then-Extract
Process mixed document types by first classifying, then applying the appropriate schema. Two approaches:
Approach 1: Classification Extraction (any document mix)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcontent/landingai/skills/ade/document-workflows/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/andrewyng/context-hub/document-workflows)