---
name: "fastify-schema-validation-typebox"
description: "Achieve maximum JSON serialization and validation throughput using Fastify and TypeBox."
metadata:
  author: "Fastify"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "fastify typebox schema"
  - "fast-json-stringify fastify"
  - "fastify swagger documentation"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Fastify High-Throughput JSON Schema Validation with TypeBox

Configures Fastify 4+: defining request and response schemas using @sinclair/typebox (Type.Object), high-speed serialization with fast-json-stringify, route options, and automatic Swagger/OpenAPI generation.

## When to Invoke
Invoke this skill whenever you need to:
- fastify typebox schema
- fast-json-stringify fastify
- fastify swagger documentation

## Execution SOP & Rules
1. Define schema with TypeBox: const UserSchema = Type.Object({ name: Type.String(), age: Type.Integer() }).
2. Register route with schema: fastify.post('/users', { schema: { body: UserSchema, response: { 200: UserSchema } } }, handler).
3. Extract static TypeScript types using Static<typeof UserSchema>.
4. Register @fastify/swagger and @fastify/swagger-ui plugins for automated API documentation.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
