AgentSkillsCN

schema-meta

验证 JSON 模式是否格式良好,并符合 JSON 模式规范。当用户要求检查模式是否有效、验证模式语法、验证模式结构,或检查 JSON 模式文件是否存在错误时,可使用此功能。

SKILL.md
--- frontmatter
name: schema-meta
description: Validate that a JSON Schema is well-formed and conforms to the JSON Schema specification. Use when the user asks to check if a schema is valid, verify schema syntax, validate schema structure, or check a JSON Schema file for errors.

Validate JSON Schema (Meta-Validation)

Validate that a JSON Schema document is itself a valid schema according to the JSON Schema specification.

Usage

bash
npx tsx scripts/meta-validate.ts <schema-file> [options]

Arguments

ArgumentRequiredDescription
schema-fileYesPath to the JSON Schema file to validate

Options

OptionDescription
--draft=VERSIONJSON Schema draft version (draft-04, draft-06, draft-07, 2019-09, 2020-12). Default: auto-detect
--strictEnable strict mode (additional validation rules)
--verboseShow detailed validation information

Output

Valid schema:

code
Valid JSON Schema (draft-2020-12)
  Keywords: 5
  Definitions: 2

Invalid schema:

code
Invalid JSON Schema
  Error: "type" must be a string or array
  Path: /properties/name/type

Script Execution

bash
npx tsx scripts/meta-validate.ts schema.json
npx tsx scripts/meta-validate.ts schema.json --draft=draft-07
npx tsx scripts/meta-validate.ts schema.json --strict --verbose

Run from the json-schema plugin directory: ~/.claude/plugins/cache/json-schema/

Draft Version Detection

The script auto-detects the JSON Schema draft version from:

  1. The $schema keyword in the document
  2. Falls back to draft-2020-12 if not specified

Supported drafts:

  • draft-04 - JSON Schema Draft 4
  • draft-06 - JSON Schema Draft 6
  • draft-07 - JSON Schema Draft 7
  • 2019-09 - JSON Schema Draft 2019-09
  • 2020-12 - JSON Schema Draft 2020-12 (default)

Strict Mode

When --strict is enabled, additional validations are performed:

  • Disallow unknown keywords
  • Require $schema declaration
  • Validate format assertions by default

Related Skills

  • Use schema-validate to validate JSON data against a schema
  • Use schema-check to validate a JSON file against its embedded $schema