json-schema-author
Installation
SKILL.md
JSON Schema Author
Overview
Keywords: JSON Schema, Draft 2020-12, Draft-07, $schema, $ref, $defs, validation, config schema, API schema, OpenAPI, additionalProperties, oneOf, anyOf, allOf, if/then/else, format, pattern, const, enum, error messages, ajv, jsonschema.
This skill helps you design correct, strict, and maintainable JSON Schemas for two dominant use cases: configuration files (validate user/operator input, fail fast with helpful messages) and APIs (contract for request/response bodies, often embedded in OpenAPI). It covers the type system, every important constraint keyword, schema composition, reuse via $ref/$defs, conditional validation, and turning raw validator output into actionable error messages.
Use the bundled material:
references/keywords.md— complete keyword reference (types, constraints, composition, applicators, annotations, draft differences) with copy-paste snippets.references/error-messages.md— patterns for clear, user-facing validation errors and how to map validator output to them.templates/config-schema.json— a strict, annotated starting point for a config-file schema.templates/api-schema.json— request/response schema pattern suitable for OpenAPIcomponents.schemas.scripts/validate.py— stdlib-only structural linter that flags the most common schema authoring mistakes; falls back tojsonschemaif installed for real validation.examples/config-walkthrough.md— sample config JSON turned into a finished schema with passing and failing instances.
Workflow
- Pick the draft. Default to Draft 2020-12 for new schemas (
$schema: "https://json-schema.org/draft/2020-12/schema"). Use Draft-07 when targeting tooling that lags (olderajvconfigs, many OpenAPI 3.0 toolchains). OpenAPI 3.1 aligns with 2020-12. Note the differences: 2020-12 uses$defsandprefixItems/items; Draft-07 usesdefinitionsanditems(array)/additionalItems. Seereferences/keywords.md.