Agent skill
typebox
TypeBox and TypeMap patterns for runtime schema validation and JSON Schema generation. Use when the user mentions TypeBox, TypeMap, Standard Schema, or when working with runtime type validation, JSON Schema, or schema-based validation.
Install this agent skill to your Project
npx add-skill https://github.com/EpicenterHQ/epicenter/tree/main/.agents/skills/typebox
Metadata
Additional technical details for this skill
- author
- epicenter
- version
- 1.0
SKILL.md
TypeBox and TypeMap
Package Names
Use typebox, not @sinclair/typebox. The @sinclair/typebox package is deprecated.
// Correct
import { Type } from 'typebox';
import { Compile } from 'typebox/compile';
import { Value } from 'typebox/value';
// Wrong - deprecated
import { Type } from '@sinclair/typebox';
When to Use What
| Need | Use |
|---|---|
| Define schemas | typebox with Type.* |
| Standard Schema support | @sinclair/typemap |
| Translate between libraries | @sinclair/typemap |
| High-performance validation | Compile() from either |
| One-off validation | Value.Check() from typebox |
TypeMap for Standard Schema
TypeBox doesn't implement Standard Schema natively. Use TypeMap:
import { Compile } from '@sinclair/typemap';
import { Type } from 'typebox';
// From TypeBox schema
const validator = Compile(
Type.Object({
name: Type.String(),
age: Type.Number(),
}),
);
// Standard Schema interface
const result = validator['~standard'].validate({ name: 'Alice', age: 30 });
TypeMap Accepts Everything
Compile() from TypeMap accepts:
import { Compile } from '@sinclair/typemap';
// TypeScript syntax strings
const v1 = Compile(`{ name: string, age: number }`);
// TypeBox schemas
const v2 = Compile(Type.Object({ x: Type.Number() }));
// Zod schemas
const v3 = Compile(z.object({ x: z.number() }));
// Valibot schemas
const v4 = Compile(v.object({ x: v.number() }));
All return validators with ['~standard'].validate().
TypeBox Compile vs TypeMap Compile
// TypeBox Compile - returns Validator with Check/Parse
import { Compile } from 'typebox/compile';
const validator = Compile(schema);
validator.Check(value); // boolean
validator.Parse(value); // throws or returns typed value
// TypeMap Compile - returns Standard Schema validator
import { Compile } from '@sinclair/typemap';
const validator = Compile(schema);
validator['~standard'].validate(value); // { value } or { issues }
Use TypeMap when you need Standard Schema compatibility. Use TypeBox directly when you don't.
Translation Functions
TypeMap translates between libraries:
import { Syntax, TypeBox, Zod, Valibot } from '@sinclair/typemap';
const syntax = `{ name: string }`;
const tbSchema = TypeBox(syntax);
const zodSchema = Zod(syntax);
const valibotSchema = Valibot(syntax);
const backToSyntax = Syntax(zodSchema);
Performance
TypeMap's compiled validators are ~100x faster than native Zod:
| Library | 10M iterations |
|---|---|
| Zod native | ~4,669ms |
| TypeMap | ~47ms |
References
- TypeMap is the Real Deal
- TypeBox is a Beast
- Why TypeBox Won't Implement Standard Schema
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
svelte
Svelte 5 patterns including runes ($state, $derived, $props), TanStack Query, SvelteMap reactive state, shadcn-svelte components, and component composition. Use when the user mentions .svelte files, Svelte components, or when using TanStack Query, fromTable/fromKv, or shadcn-svelte UI.
autumn
Integrate Autumn billing—define features/plans in autumn.config.ts, use autumn-js SDK for credit checks/tracking, manage the atmn CLI for push/pull. Use when working on billing, pricing, credits, plan gating, or metered usage.
handoff-prompt
Draft a self-contained implementation prompt that an agent can execute with zero prior context. Use when the user says "draft a prompt", "write a handoff", "make a prompt I can copy-paste", "create a delegation brief", or wants to hand off a task to another agent, tool, or conversation.
factory-function-composition
Apply factory function patterns to compose clients and services with proper separation of concerns. Use when creating functions that depend on external clients, wrapping resources with domain-specific methods, or refactoring code that mixes client/service/method options together.
progress-summary
This skill should be used when the user asks questions like "can you summarize", "what happened", "what did we do", "what's the situation", "where are we at", "explain what's going on", "give me an overview", "what's been done", "tell me about this", "walk me through what happened", or any question asking to understand the current state of work or changes. Provides conversational, PR-style summaries with visual diagrams.
query-layer
Query layer patterns for consuming services with TanStack Query, error transformation, and runtime dependency injection. Use when the user mentions createQuery, createMutation, TanStack Query, or when implementing queries/mutations, transforming errors for UI, or adding reactive data management.
Didn't find tool you were looking for?