with one click
yaml
YAML & JSON Schema Conventions
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
YAML & JSON Schema Conventions
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | yaml |
| description | YAML & JSON Schema Conventions |
Generic skill — This skill is project-agnostic. Do not add project-specific references, paths, or terminology here.
Consult this when reading, writing, or modifying any YAML or JSON files in a project.
Never use raw yaml.safe_load() / yaml.dump() directly in application code. Instead:
BaseModel that matches the YAML structuremodel.model_validate(yaml.safe_load(path)) — gives type-safe attribute access and catches schema violations immediatelyyaml.dump(model.model_dump(exclude_none=True), ...) — produces clean YAML without None clutterWrap these in load_* / save_* helper functions so callers never touch raw dicts.
When saving YAML, prepend a schema tag so VS Code (with the YAML extension) provides autocompletion and validation:
# yaml-language-server: $schema=../../schemas/my_format.json
Use a relative path from the YAML file to the JSON Schema file. Save helpers should add this automatically.
Another approach is to publish schemas as GitHub Release artifacts and reference via absolute URL. (TODO: add details for ibek projects)
Generate JSON Schema files from Pydantic models using model.model_json_schema():
import json
schema = MyModel.model_json_schema()
Path("schemas/my_format.json").write_text(json.dumps(schema, indent=2) + "\n")
Commit generated schemas to the repo so VS Code picks them up without running code. Add a test that compares committed schemas against model_json_schema() output to catch staleness.
Literal["a", "b"] for enum-like string fields — catches typos at validation timemodel_config = ConfigDict(extra="allow") only for formats with user-defined fields; keep all others strictexclude_none=True when dumping so optional fields don't clutter YAML with null entriesbool | None flags, use None as the default (not False) so absent flags are omitted from output@dataclass for structures that are serialized to/from YAMLload_* / save_* helpers (with schema tag injection)model_json_schema()