Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Structured Json Extractor

    10

    Use to turn free-form LLM output into validated JSON via Pydantic models. Covers typed response models, retry on validation failure, nested schemas, and batch p

    Free

    9 uses5.0 (1 review)
    Structured Json Extractor

    Structured Json Extractor

    Example session with this skill installed

    Generate a Pydantic model for a medical prescription and a retry loop that handles validation errors for the dosage field.

    • Read your context and instructions
    • Compiled the structured json extractor
    class Prescription(BaseModel):
        drug: str
        dosage_mg: int = Field(gt=0)
    
    # Implementation includes a while-loop catching ValidationError, 
    # appending e.errors() to messages, and retrying up to 3 times 
    # before logging to failed.txt.
    

    Connects securely to your tools. The creator never sees your data.

    About this skill

    The problem

    LLMs frequently hallucinate JSON structures, skip required fields, or return invalid data types that break downstream applications. Manual regex parsing and basic string cleaning fail at scale when dealing with complex nested data or high-volume batch processing.

    What it does

    • Defines strict schema constraints using Pydantic models to enforce data integrity.
    • Implements a feedback loop that catches validation errors and re-prompts the LLM with specific error locations.
    • Handles complex nested schemas and cross-field validation for sophisticated data structures.
    • Provides a concurrent batch processing pattern for high-throughput extraction tasks.
    • Ensures reliability with a fallback logging system for inputs that fail all retry attempts.

    Frameworks & tools

    Python, Pydantic, and any LLM SDK (OpenAI, Anthropic) supporting structured outputs or JSON mode.

    Why this beats prompting it yourself

    Simply asking an LLM for JSON is not a production strategy. This skill provides the infrastructure for error handling, field-level constraints, and self-correction loops that raw prompting lacks. It transforms unreliable text generation into a hardened data pipeline.

    Use cases

    • Extracting structured line items and totals from unstructured receipt photos.
    • Converting messy customer support transcripts into classified tickets with priority levels.
    • Automating document ingestion from diverse PDF layouts into a normalized database.
    • Batch processing thousands of product reviews into sentiment and feature-score matrices.

    Known limitations

    Not suitable for creative writing or open-ended chat where strict schemas limit quality. Extremely long documents require pre-chunking before extraction.

    Requires Python and Pydantic. Does not handle document chunking for files exceeding model context limits. Needs an LLM capable of basic JSON formatting.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    5.0
    1 review
    5
    1
    4
    0
    3
    0
    2
    0
    1
    0

    This skill has been used 9 times.

    Trust & safety

    Security scan

    Security scan passed 3 months ago

    • Free with an Agensi account

    Permissions

    Terminal / Shell
    Listed3 months ago

    What's inside

    Frequently Asked Questions

    This skill uses Pydantic validation and an automated feedback loop to catch formatting errors. If an LLM returns invalid JSON, the skill identifies the specific field failure and re-prompts the model to correct its mistakes automatically.

    The skill is framework-agnostic and works with any LLM provider that supports JSON mode or structured outputs, including OpenAI (GPT-4o/o1), Anthropic Claude, and local models via LangChain or direct SDKs.

    You will receive a complete Python implementation including the Pydantic schema templates, the retry logic wrapper, and a batch processing script, along with documentation for integrating it into your existing data pipeline.

    While the skill is designed for high-accuracy extraction, extremely long documents should be chunked into smaller segments first to ensure the LLM stays within its context window and maintains field precision.

    Yes, the skill is designed to handle complex, deeply nested JSON objects and cross-field validation, making it ideal for converting messy data like transcripts or receipts into highly organized database entries.