Skip to main content
AIDiveForge AIDiveForge
🧩

Self-Correcting Schema Agent

Agents & Workflows · by AIDiveForge · Apr 20, 2026 · Advanced

An agent that retries JSON generation with schema violation feedback until the output validates — or a budget is exhausted.

🧠 Why it works

Most JSON validation failures are near-misses — a wrong enum value, a missing required field. One-shot prompting discards that information and starts over. Feeding the specific error back lets the next attempt fix the exact problem, which converges in 2-3 iterations for most schemas.

⚙️ How it works

  1. Call the model with the prompt + the JSON schema in the system message. 2. Parse the output; run schema validation. 3. On failure, extract the specific validation error (path, expected, actual) and append it as a user message: 'Your previous output violated <path>: expected <X>, got <Y>. Fix and resubmit the full output.' 4. Retry up to N times (default 5). 5. On final failure, emit the last attempt with a failure reason for human review. 6. Record attempt counts for cost analysis.

Description

Given a JSON schema and a prompt, runs an inner loop: generate, validate, on failure feed the specific validation error back into the next attempt. Designed for production workflows where schema-valid output is a hard requirement and a one-shot failure means a retry from scratch.

Install this skill

A Claude skill is a skill.md file with YAML frontmatter and a markdown body. Drop the file into your tool of choice — or pick a different format if you use Cursor, Windsurf, Copilot, or something else.

Download skill.md
mkdir -p ~/.claude/skills/self-correcting-schema-agent \
  && curl -L https://aidiveforge.com/skill/self-correcting-schema-agent.skill-md \
       -o ~/.claude/skills/self-correcting-schema-agent/skill.md

Save to ~/.claude/skills/self-correcting-schema-agent/skill.md

Recommended Use

Tools and workflow packs this skill pairs well with. Forge picks are auto-generated from category + capability signals; Community picks are added by people who've used the pairing.

No matches yet. Be the first to suggest a pairing, or the Forge will populate suggestions as signals align.