agentsclimarketplace

Generated enum and config code from json schema

Skill kjuhwa/skills-hub/skills/codegen/generated-enum-and-config-code-from-json-schema

Build-time code generator that reads a JSON content-type knowledge base and emits per-language type-safe enums + const TypeInfo structs (MIME type, group, extensions, is_text).From its SKILL.md

Install
npx -y skills add kjuhwa/skills-hub --skill generated-enum-and-config-code-from-json-schema

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.1 KB, 345 tokens by cl100k_base, as published. Nobody here has run it

Generated Enum And Config Code From Json Schema

Trigger: You have a large dynamic schema (300+ entries) and need per-language type safety without hand-writing or hand-maintaining enums.

Steps

  • Create a generator binary (Rust here) that reads content_types_kb.min.json and config.min.json.
  • Parse with serde; for each content type emit a const struct with label, mime_type, group, description, extensions, is_text.
  • Generate enum variants per type; map labels to valid identifiers (CamelCase / snake_case, leading-digit prefix).
  • Write generated code under a clearly-marked path (rust/lib/src/content.rs, python types/content_type_label.py) with a 'DO NOT EDIT' header.
  • Use a deterministic ordering (BTreeMap) so regeneration is reproducible.
  • Wire generation into the build pipeline (build.rs, setup.py hook, or dedicated generate.sh) and check generated files into git.

Counter / Caveats

  • Generator output must be deterministic; non-deterministic ordering breaks reproducible builds and noisy diffs.
  • Schema drift (new fields, type changes) causes generator failures; version the schema and validate before generating.
  • Large enums (300+ variants) slow Rust compile times; consider non_exhaustive and feature gates.
  • IDE autocomplete fails until generation runs; document a clone-time setup script.

Source

Extracted from magika (https://github.com/google/magika.git @ main).

Files of interest:

  • rust/gen/src/main.rs:23-100
  • python/src/magika/types/content_type_label.py:19-30
  • rust/lib/src/content.rs (generated)

What ships with it: 1 file

1.0 KB alongside SKILL.md

Keep looking

Skills are one crate of 326,871. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.