# Kjuhwa Skills Hub Type Safe Enum Generation Per Language

> Type Safe Enum Generation Per Language

- Skill: `tomevault-io/kjuhwa-skills-hub-type-safe-enum-generation-per-language` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/kjuhwa-skills-hub-type-safe-enum-generation-per-language`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/kjuhwa-skills-hub-type-safe-enum-generation-per-language/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/kjuhwa-skills-hub-type-safe-enum-generation-per-language

---


# Type Safe Enum Generation Per Language

**Trigger:** You support 300+ string-keyed types and want compile-time validation in every language without hand-maintaining four enum lists.

## Steps

- Parse content_types_kb.min.json once; produce a deterministically sorted list of labels.
- Generate per language: Rust pub enum (with non_exhaustive), Python StrEnum, TS string literal union, Go const iota with String().
- Apply consistent name normalization (3gp → _3gp in Rust due to no leading-digit identifiers).
- Generate from_string / to_string + a SIZE/COUNT constant.
- At codegen time, validate every label is present in the target model — fail the build on drift.
- Add a 'DO NOT EDIT' header to every generated file and check generated files into git.

## Counter / Caveats

- Label normalization rules differ per language; keep them in one place.
- Rust enums with 300+ variants slow compile time noticeably; non_exhaustive helps downstream evolution.
- Index stability matters if downstream uses int indices for array lookups; renumbering breaks model output mappings.
- Tooling (rust-analyzer, pyright) needs the generated files to exist before it can resolve symbols — generate before checkout-time tasks.

## Source

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

Files of interest:
- `rust/gen/src/main.rs:40-100`
- `python/src/magika/types/content_type_label.py:19-50`
- `js/src/content-type-label.ts`

---
> Source: [kjuhwa/skills-hub](https://github.com/kjuhwa/skills-hub) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->

