Schema Validation Gate
Validate generated artifacts with a real checker before downstream use.
These examples and illustrative results are independently authored teaching materials, not measured model results.
Use case
A publishing script is about to consume review.json with an enumerated status and nonempty checks array. A teaching candidate uses status OK: it looks plausible but violates the supplied JSON Schema.
Mechanism
Establish the actual schema version and validator contract, then save the candidate. Run a real validator on that file, recording digest, command/version, exit status and diagnostics. Repair named violations and revalidate, allowing at most two repairs here; failures do not reach the consumer. Confirm the consumed bytes still match validated bytes and revalidate after changes. Check required semantics separately.
Bad example
Look at review.json and say schema passed because it resembles JSON, then give it to the publishing script.
Good example
Validate review.json with the supplied schema and checker. If OK is invalid, change it to an evidence-supported allowed state rather than arbitrarily PASS. Record the file digest and result. Allow at most two repairs, then stop delivery if invalid. Downstream consumption uses the verified bytes.
Why the change matters
Running a checker turns format assurance into reviewable diagnostics. Binding file identity prevents checking A while using B. Repair must not alter facts merely to satisfy a schema.
Observable expectation
Teaching status OK fails enumeration validation. UNKNOWN with the remaining required fields can pass structure checks. A subsequent file edit requires revalidation. A structurally valid but false PASS illustrates that schema success can coexist with semantic failure.
Limits
Exit 0 depends on the checker; verify its failure contract. Structure establishes neither truth, appearance nor all behavior, and the target application may enforce extra constraints. Frozen document/package validators illustrate the mechanism, not a tool for this JSON task.
Sources and evidence
- anthropics/skills · File QA (required)
File at this version8a1541c4a3ff - ComposioHQ/awesome-claude-skills · Validation before ZIP
File at this versionbe2a406907db - ComposioHQ/awesome-claude-skills · validate_skill
File at this versionbe2a406907db