typebox-model-schema

Define TypeBox model schemas as the single source of truth for validation, SQL contracts, and UI generation.

1|Updated Jun 25, 2026
One-click install
npx skills add https://github.com/IgorAIvanov/altera03 --skill typebox-model-schema-igoraivanov
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typebox-model-schema
Source: https://github.com/IgorAIvanov/altera03/tree/main/skills/src/typebox-model-schema
Command: npx skills add https://github.com/IgorAIvanov/altera03 --skill typebox-model-schema-igoraivanov

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @sinclair/typebox.

What problem does it solve? Maintaining separate TypeScript interfaces, backend validators, SQL contracts, and frontend form configurations for the same data model leads to drift and duplicated effort. This Skill establishes one TypeBox schema file per model that drives types, runtime validation, SQL function documentation, and generated forms, lists, and pickers. ## Core Features & Use Cases - Single-source schema definition: Create Item, Row, LookupRow, payload, and response schemas per model with derived TypeScript types via Static<>. - UI annotation system: Use standard JSON Schema annotations plus x-form, x-list, x-lookup, x-filter, x-ref, and x-transient to drive form fields, list columns, pickers, and generated SQL filters. - Database conventions: Enforce bigint identity primary keys starting at 100, string-typed ids in TypeScript, and reference handling for catalogs, documents, and multi-writer registers. - Use Case: When adding a new bank catalog model, define one bank.schema.ts file and get validated payloads, list/get/save/delete/lookup contracts, and a generated form and list view without writing separate interfaces. ## Quick Start Ask the AI to create a TypeBox model schema for a new catalog model with fields for code, name, and a reference to another model, including list and form annotations.

Frequently Asked Questions about typebox-model-schema

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define a model schema with TypeBox for both frontend and backend?

Create one <model>.schema.ts file exporting Item, Row, LookupRow, payload, and response schemas with Type.Object, and derive types via Static<typeof Schema>. The same file serves backend validation and frontend form generation, so it must not import server-only or client-only modules.

How do TypeBox JSON Schema annotations drive form and list generation?

Standard annotations like title, minLength, and format set labels and validation, while custom x-form, x-list, and x-lookup annotations declare which fields appear in forms, list columns, and pickers. Width values like sm, md, and lg control column sizing.

Why use Type.String for bigint ids in TypeScript?

JavaScript numbers lose precision above 2^53, so bigint database ids travel as strings in JSON. Annotate these fields with x-db-type: bigint to document the database type while keeping Type.String() in the schema.

When should I use UUID instead of bigint as a primary key?

Use UUID only when an entity genuinely needs non-sequential, globally unique identifiers, such as external integrations, distributed generation, or public-facing tokens. Ordinary catalog and document models should use bigint identity starting at 100.

Why does my reference column show empty in the generated list?

If a register row can be written by multiple document types, an x-ref naming one model joins only through that model's table, leaving other rows silently empty. Use x-ref with entity: document instead so the join goes through the shared document header.

What is the x-transient annotation used for in TypeBox schemas?

x-transient marks a field that exists in the form type but has no database column, such as the display object next to a reference field. The generator skips it when building SQL, preventing errors like column does not exist at publish time.