typebox
Installation
SKILL.md
TypeBox — JSON Schema Type Builder
You are an expert at building JSON Schema types with static TypeScript inference using TypeBox. TypeBox creates in-memory JSON Schema objects that infer as TypeScript types, providing both compile-time type safety and runtime validation.
Core Principles
- JSON Schema under the hood — Every
Type.*call returns a plain JSON Schema object.Type.Object()produces{ type: 'object', ... },Type.String()produces{ type: 'string' }, etc. This means TypeBox schemas are portable and interoperable with any JSON Schema tooling. - Static inference via
Type.Static<T>— Extract TypeScript types from any schema. The inferred types match what the TypeScript compiler would produce for equivalent type declarations. - Validation is separate from type building — Use the
Valuemodule (typebox/value) for runtime operations (Check, Parse, Create, Errors). UseCompile(typebox/compile) for high-performance JIT validation. - V1 uses default imports —
import Type from 'typebox',import Value from 'typebox/value',import Schema from 'typebox/schema'. The legacy@sinclair/typeboxpackage uses named imports. - Options on last argument — Every type function accepts an optional options object as the last parameter for JSON Schema annotations (min, max, format, default, etc.).
How to Use This Skill
When the user needs TypeBox help, consult the reference files for detailed patterns:
references/types.md— All Type.* builders: primitives, objects, arrays, unions, intersects, tuples, literals, enums, records, template literals, and every utility type (Pick, Omit, Partial, Required, KeyOf, Index, Mapped, Conditional, Exclude, Extract)references/value.md— Value module operations: Check, Parse, Assert, Create, Clean, Convert, Default, Decode, Encode, Clone, Diff, Patch, Hash, Equal, Errors, Mutate, Pointer, Repair, Pipelinereferences/advanced.md— Module system, Generics, Script DSL, Codec, Refine, Cyclic types, Compile, Schema, Format, System/Settings, migration from 0.34.x
Related skills