Generate Zod schemas and TypeScript types for forms, API routes, and Server Actions with runtime validation. Use this skill when creating API contracts, validating request/response payloads, generating form schemas, adding input validation to Server Actions or route handlers, or ensuring type safety across client-server boundaries. Trigger terms include zod, schema, validation, API contract, form validation, type inference, runtime validation, parse, safeParse, input validation, request validation, Server Action validation.
Generate Zod schemas with TypeScript types for forms, API routes, and Server Actions. Use when creating API contracts, validating request/response payloads, adding runtime validation to route handlers, or ensuring type safety across client-server boundaries. Trigger terms: zod, schema, validation, API contract, form validation, type inference, parse, safeParse.
/plugin marketplace add hopeoverture/worldbuilding-app-skills/plugin install api-contracts-and-zod-validation@worldbuilding-app-skillsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/schema_templates/api_route_schema_template.tsassets/schema_templates/entity_schema_template.tsassets/schema_templates/form_schema_template.tsassets/schema_templates/server_action_schema_template.tsreferences/zod_patterns.mdscripts/generate_zod_schema.pyGenerate Zod schemas with TypeScript type inference for forms, API routes, and Server Actions. Validate inputs in Server Actions or route handlers with runtime type checking.
When creating API contracts or form validations:
z.infer<typeof schema> for automatic type inferenceTo create form validation with Zod:
references/zod_patterns.md for common validation patternsTo add validation to API endpoints or Server Actions:
.parse() or .safeParse()Use scripts/generate_zod_schema.py to automate schema generation:
python scripts/generate_zod_schema.py --input types/entities.ts --output schemas/entities.ts
The script:
Automated TypeScript-to-Zod schema generator. Parses TypeScript AST and generates equivalent Zod schemas.
Common Zod validation patterns including:
Pre-built Zod schema templates:
form_schema_template.ts - Basic form validationapi_route_schema_template.ts - API route request/responseserver_action_schema_template.ts - Server Action input/outputentity_schema_template.ts - Database entity validationscripts/generate_zod_schema.py or templates.safeParse() at the beginning of the action.safeParse() instead of .parse() to avoid throwing exceptionsz.infer<typeof schema> for automatic TypeScript typesCommon use cases for worldbuilding applications:
Consult references/zod_patterns.md for specific validation patterns applicable to worldbuilding entities.