0xelitesystem/claude-skills-collection/json-schema-from-sample
Claude Code and agent skill by 0xelitesystem/claude-skills-collection
- community
Checking that the SKILL.md file is still in the repository.
Use when the user wants to generate a JSON Schema from one or more sample JSON documents. Triggers on "create a schema for this", "generate JSON Schema", "validate this shape", "infer types from this JSON", or when the user pastes JSON and asks how to validate similar documents.
Install
npx vskill@latest install 0xelitesystem/claude-skills-collection/json-schema-from-sampleSKILL.md
The same SKILL.md was published earlier as 0xelitesystem/claude-skills-collection/json-schema-from-sample.
JSON Schema from Sample
Generate a JSON Schema (Draft 2020-12 by default) from sample documents.
Process
- Get samples. Ideally multiple. One sample produces a schema that's too tight (every field is required, every enum has one value). Ask for 2-5 samples that represent the variation you expect to see.
- Confirm schema draft version. Default to Draft 2020-12. Common alternatives:
- Draft 7: still widely used, supported by older tooling
- Draft 4: legacy, only if explicitly required
- Walk the samples to infer:
- Types per field. If a field is sometimes a string and sometimes null, type is
["string", "null"]. If sometimes string sometimes number, that's worth flagging to the user as likely a bug. - Required fields. Only fields present in ALL samples are required. Mention which fields varied so the user can decide if the variation is real or coincidental.
- Enums. If a field has a small set (≤10) of distinct string values across all samples, suggest making it an enum. Ask before committing, the samples may not have exhausted the values.
- Patterns. If string values match a clear pattern (UUID, email, ISO date, semver), use the standard
formatkeyword (uuid,email,date-time) or apatternregex. Don't over-fit. - Number ranges. Use
minimum/maximumonly if the samples suggest a meaningful bound (e.g. age 0-120). Don't add bounds based on coincidental sample values. - Array item type. If an array always contains the same shape, use that as
items. If items are mixed, useprefixItemsoroneOf. - Nested objects. Recurse with the same logic.
- Output the schema with comments explaining choices. Use
descriptionfields liberally. JSON Schema doesn't allow//comments, so put rationale indescription.
- Below the schema, write a short audit:
What NOT to do
- MUST NOT add
"additionalProperties": falseby default. It locks down the schema and breaks forward compatibility. Add it only if the user asks. - MUST NOT infer regex patterns from a single sample value. Patterns need at least 3 examples.
- MUST NOT use
"format": "X"for non-standard formats. Only the spec-defined formats:date-time,date,time,email,uuid,uri,ipv4,ipv6,hostname. For others, usepattern. - MUST NOT silently drop fields that appear in only one sample. Make them optional and report which ones.
Common pitfalls to call out to the user
- "All samples have a positive
count. I mademinimum: 0. Iscountever negative?" - "Samples never have
nullvalues. Should null be allowed for any field?" - "Field
idis integer in some samples, string in others. This is usually a bug. Which is correct?"
Output destinations
If samples are large or the schema is going into a project, ask whether to write to a file (schema.json) or just paste inline. Default to inline for ≤100 lines, file for larger.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/json-schema-from-sample/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/0xelitesystem/claude-skills-collection/json-schema-from-sample)