structured-output
Skill59 starsChanged 2 months agoMITView on GitHub
Get parseable, trustworthy structured results out of a model — schema design, the enforcement mechanism the provider actually offers, validation at the boundary, bounded retry that feeds the error back, and recognising where a schema stops buying correctness. Use when a model's output feeds code rather than a human, when parsing keeps failing or fields come back plausible-but-wrong, or when designing an extraction, classification or grading step. Not for designing the tools an agent calls (tool-design), and not for free-form prose quality.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- InterfazeAI/interfaze-skillstheir own version, first seen Sep 10, 2026
- LingXi-Org/LingxiSkillstheir own version, first seen Aug 17, 2026
- nimadorostkar/Claude-Skills-collectiontheir own version, first seen Jul 14, 2026
- Archive228/loopkittheir own version, first seen Jun 29, 2026
- mykaarma/kaarma-skillstheir own version, first seen Apr 28, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- Archive228/loopkit★ 756same name
- nimadorostkar/Claude-Skills-collection★ 28same name
- InterfazeAI/interfaze-skills★ 4same name
- mykaarma/kaarma-skills★ 4same name
- LingXi-Org/LingxiSkills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository79 other files it gives its agents.
- agent-dispatcherSkill
- agent-designSkill
- agent-evalsSkill
- context-engineeringSkill
- llm-observabilitySkill
- mcp-designSkill
- memory-designSkill
- model-routingSkill
- prompt-engineeringSkill
- prompt-injection-defenseSkill
- retrieval-ragSkill
- tool-designSkill
- api-contract-verificationSkill
- api-designSkill
- authenticationSkill
- authorizationSkill
- background-jobsSkill
- cachingSkill
- idempotency-and-retriesSkill
- webhooksSkill
- database-migration-verificationSkill
- data-integritySkill
- data-pipelinesSkill
- data-qualitySkill
- migrationsSkill
- postgresSkill
- query-optimizationSkill
- schema-designSkill
- accessibilitySkill
- accessibility-verificationSkill
- design-systemsSkill
- design-to-codeSkill
- frontend-designSkill
- motion-designSkill
- responsive-designSkill
- ui-auditSkill
- ux-writingSkill
- ci-cdSkill
- deploymentSkill
- dockerSkill
- github-actionsSkill
- incident-responseSkill
- observabilitySkill
- release-verificationSkill
- rollbackSkill
- component-architectureSkill
- frontend-performanceSkill
- shadcn-uiSkill
- stack-detectionSkill
- tailwindSkill
- visual-verificationSkill
- competitive-analysisSkill
- copywritingSkill
- data-analysisSkill
- deep-researchSkill
- documentation-verificationSkill
- positioningSkill
- seoSkill
- source-evaluationSkill
- technical-writingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Decide what the code truly needs: Every field is something the model must get right and you must validate.
- Very specific: line 37
Give uncertainty somewhere to go: Add an explicit unknown or not_stated enum member and a nullable field where absence is genuine.
- Distinctive: line 98
Keep the verbs apart — *parses*, *validates* and *is correct* are three different results, and only the third needs labelled data to claim.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Structured output
A schema constrains shape, never truth. It buys you parse() succeeding; it does not buy you a
correct value in the field. Most structured-output work is deciding which of those two problems you
actually have.
When this fires
Any model output that code consumes: extraction, classification, routing, scoring, grading, filling a record. Also when parsing fails intermittently, when required fields arrive empty or invented, or when a downstream system trips over a value that validated fine. It does not fire for output a human reads.
Procedure
- Decide what the code truly needs. Every field is something the model must get right and you must validate. A schema with three well-defined fields outperforms one with twelve where four are guesses. Drop anything no caller reads.
- Use the strongest enforcement the provider gives you, and know which one it is. Ranked: constrained decoding against the schema, where the provider guarantees conformance; a tool or function call carrying the schema; a prompt asking for JSON, parsed defensively. The third is not a guarantee. Check the provider's current documentation for which mode applies and which JSON Schema keywords it supports — unsupported keywords are commonly ignored rather than rejected, and an ignored constraint fails later as a mysterious bad value.
- Make illegal values unrepresentable. Closed enums instead of free strings for anything with a known set. Numbers as numbers, with bounds. Dates in one stated format. No field that means two things depending on another field. Flat beats deeply nested: nesting and recursion cost accuracy and are the first thing a strict mode refuses.
- Name fields so the schema teaches the task.
refund_reason_codewith an enum and a one-line description does work no prompt sentence has to repeat. Put the per-field instruction in the schema description, not scattered in the prompt. - Give uncertainty somewhere to go. Add an explicit
unknownornot_statedenum member and a nullable field where absence is genuine. Without it, a required field forces a fabrication — the schema converts "I don't know" into a confident wrong answer. A refusal or safety stop also needs a representable path; do not model it as a parse error. - Order the fields so reasoning precedes conclusion. Where a decision needs thinking, put a short rationale field before the verdict, or take the reasoning outside the object entirely. A verdict emitted first and justified afterwards is a rationalization, not a reason.
- Validate at the boundary, every time. Parse with the real validator — the schema library the project already uses — and then check what the schema cannot: does the id exist, is the date in range, do the extracted spans appear in the source, does the total match the line items. Never let unvalidated model output into a database, a query, a shell command or a URL.
- Retry narrowly, bounded, with the error fed back. On a validation failure, return the validator's message and the offending output, and ask for a correction. One or two attempts, then fail loudly. An unbounded repair loop hides a broken schema and bills for it. Escalating to a larger model or splitting the task beats a third retry.
- Know when to stop adding schema. A schema cannot make a field accurate, cannot resolve a genuinely ambiguous source, cannot enforce a relationship between fields, and cannot stop confident invention. When failures are wrong values rather than wrong shapes, the fix is upstream: better retrieval, a smaller task, an example or two, a split into separate calls — not another constraint. Say this plainly instead of tightening a schema that is already conforming.
- Measure on a fixed set before trusting it. Twenty to fifty labelled cases including the ugly ones — missing data, ambiguity, adversarial text, empty input. Record parse rate and field accuracy separately; they fail for different reasons and a high parse rate hides a low accuracy. Re-run it when the schema, prompt or model changes.
- Stop at the boundary. Producing validated output is extracted. Writing it into a system of record, sending it onward, or acting on it is a separate, outward-facing step — and where the output drives a destructive action, it stops and asks first.
Checklist
- Every field is read by a caller; the rest are gone
- Enforcement mechanism named, and confirmed against current provider documentation
- Enums closed, numbers bounded, one date format, no overloaded fields
- Nesting kept shallow and supported by the mode in use
- Per-field meaning lives in the schema description
unknown/ null paths exist so the model need not fabricate; refusal is representable- Rationale precedes verdict where a judgement is made
- Output validated with a real validator, plus the semantic checks the schema cannot make
- Retry bounded, error message fed back, hard failure after the bound
- Fixed evaluation set run; parse rate and field accuracy reported separately
Failure handling
- Parse fails intermittently — prose around the JSON, a truncated response hitting the token limit, or a mode that was never actually enforcing. Check the finish reason before blaming the prompt.
- It validates but the values are wrong — a schema problem no longer. Go to step 9.
- A required field is always filled and sometimes invented — you removed the model's escape
hatch. Add
unknown. - The schema is rejected by the provider — an unsupported keyword or too much nesting. Simplify the schema rather than dropping to unenforced prompting.
- Retries succeed often enough to look fine — that is a defect rate you are paying to hide. Report the pre-retry rate.
- No labelled cases exist — say the accuracy is unmeasured. "Parses reliably" is not "is correct", and the two must never be reported as one claim.
Evidence to report
The schema as shipped. The enforcement mode, named, with what it does and does not guarantee. Validation code and the semantic checks beyond the schema. Results on the fixed set: parse rate before retries, parse rate after, field-level accuracy, and the failure cases with their inputs. Keep the verbs apart — parses, validates and is correct are three different results, and only the third needs labelled data to claim.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

