ericrisco/rsc-harness / skills/structured-extraction
structured-extraction
VerifiedUse when text must become a typed, schema-conformant object you can trust — pulling fields into a fixed JSON shape, extracting line items as typed records, classifying into enums, and building the Pydantic or Zod model plus the validate-and-retry loop. Covers extractors that throw parse errors, leak markdown fences, or fabricate a value where the field is absent instead of returning null. NOT getting the text out of a PDF, scan or DOCX first (that is `document-processing`), NOT general prompt craft untied to a schema (that is `prompt-engineering`).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 14.1 KB |
| evals/README.md | markdown | 1.1 KB |
| evals/cases.yaml | config | 4.7 KB |
| references/providers.md | markdown | 6.6 KB |
| scripts/verify.shexecutable | script | 5.8 KB |
evals/cases.yaml
View on GitHubskill: structured-extraction
# Prompts that MUST load `structured-extraction`. The skill owns turning text
# into a typed, schema-conformant object: defining the schema, choosing the
# native decoding mechanism, and building the value-validation + bounded-reask
# loop. The deliverable is a typed object that conforms to a schema you defined
# — both its SHAPE (decoding) and its VALUES (validation).
should_trigger:
- prompt: "Extract name, email, and total amount from these invoices into a fixed JSON schema."
why: "Canonical text-in/typed-object-out: a defined schema plus extraction is exactly this skill."
- prompt: "My LLM keeps returning a markdown fence and a chatty intro, JSON.parse blows up — make extraction reliable."
why: "Non-obvious: the symptom reads like a parsing bug, but the real fix is native structured outputs, not regex fence-stripping."
- prompt: "When the document has no phone number the model invents one — I want null instead."
why: "The value-correctness half: null-vs-absent is solved with a nullable schema field plus a 'use null if not stated' instruction, not by re-prompting harder."
- prompt: "Build the Pydantic model and a validate-and-retry loop to pull line items from 5k receipts."
why: "Schema design + bounded reask loop for value validation — the rung-2/rung-3 core of this skill."
- prompt: "Convertir estos contratos en datos estructurados con un esquema fijo y validar los campos."
why: "Spanish/Catalan: turn contracts into structured data with a fixed schema and validate the fields — squarely this skill."
- prompt: "Classify each support ticket into one of these 6 enums and pull the order id as structured output."
why: "Closed-set enum classification plus field extraction, emitted as a schema-conformant object."
# NEAR-MISS prompts that must NOT load `structured-extraction`. The recurring
# trap: the real deliverable is raw document bytes/text, a generic prompt, a
# multi-node pipeline, an offline accuracy scorecard, or a retrieval index.
should_not_trigger:
- prompt: "Get the text and tables out of this scanned PDF."
route_to: "document-processing"
why: "Produces the unstructured text this skill consumes; bytes-out, not schema-out."
- prompt: "Help me write a better system prompt with few-shot examples for my chatbot."
route_to: "prompt-engineering"
why: "General prompt craft not bound to a target schema; schema design and constrained decoding live here, 'make this prompt better' lives there."
- prompt: "Orchestrate a 4-step chain that summarizes then routes then drafts, and batch 50k docs cheaply."
route_to: "llm-pipeline"
why: "Multi-node orchestration, batching, and cost/latency — not a single extraction node."
- prompt: "Score my extractor's precision and recall against a labeled golden set and gate regressions in CI."
route_to: "agent-eval"
why: "Offline measurement harness; this skill builds the extractor, agent-eval scores it."
- prompt: "Answer questions over my document corpus by retrieving the relevant chunks."
route_to: "rag"
why: "Retrieval over a corpus, not parsing one document into a fixed schema."
- prompt: "Dedupe and normalize the categories across this 200k-row CSV of customers."
route_to: "data-cleaning"
why: "Tabular cleanup across a whole dataset, not extracting typed fields out of free text."
# Capability: graded against the must_include rubric.
capability:
- scenario: >
Given a paragraph of free text describing a customer order — sometimes
missing the email or the discount percent, sometimes writing the amount
as "$1,200.00" — produce a reliable typed extraction (vendor, amount,
email, discount_pct, order_date). Outline the schema and the code you
would write.
must_include:
- "Uses a native structured-outputs mode (OpenAI strict:true json_schema OR Anthropic output_config.format), NOT prompt-and-json.loads."
- "Schema sets additionalProperties:false and lists every property in required."
- "Maybe-absent fields (email, discount_pct) are modeled as a nullable union with an instruction to use null when absent, so the model does not fabricate them."
- "Adds a post-decode value-validation step (Pydantic @field_validator / Zod .refine) for ranges, currency normalization ('$1,200' -> int), and date->ISO that the schema cannot enforce."
- "Any reask/retry on validation failure is BOUNDED (e.g. max_retries=2) and logged, never an unbounded loop."
- "Explicitly distinguishes 'valid JSON' (decoding) from 'correct values' (validation) and assigns each failure mode to the rung that catches it."
- "Uses current APIs, not the deprecated Anthropic output_format / structured-outputs-2025-11-13 header."
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |