api-contracts-and-zod-validation
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.
What this skill does
# API Contracts and Zod Validation Generate 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. ## Core Capabilities ### 1. Generate Zod Schemas from TypeScript Types When creating API contracts or form validations: - Analyze existing TypeScript interfaces or types - Generate equivalent Zod schemas with proper validation rules - Ensure bidirectional type compatibility (Zod -> TypeScript) - Use `z.infer<typeof schema>` for automatic type inference ### 2. Form Validation Schemas To create form validation with Zod: - Generate schemas for React Hook Form, Formik, or native forms - Include field-level validation rules (min/max length, regex, custom validators) - Support nested objects, arrays, and complex data structures - Provide helpful error messages for validation failures - Use `references/zod_patterns.md` for common validation patterns ### 3. API Route and Server Action Validation To add validation to API endpoints or Server Actions: - Wrap handler logic with schema validation using `.parse()` or `.safeParse()` - Return typed errors for validation failures - Generate request/response schemas for API contracts - Validate query parameters, body payloads, and route parameters - Ensure type safety between client and server code ### 4. Schema Generation Script Use `scripts/generate_zod_schema.py` to automate schema generation: ```bash python scripts/generate_zod_schema.py --input types/entities.ts --output schemas/entities.ts ``` The script: - Parses TypeScript interfaces/types - Generates Zod schemas with appropriate validators - Preserves JSDoc comments as descriptions - Handles common patterns (optional fields, unions, enums) ## Resource Files ### scripts/generate_zod_schema.py Automated TypeScript-to-Zod schema generator. Parses TypeScript AST and generates equivalent Zod schemas. ### references/zod_patterns.md Common Zod validation patterns including: - String validation (email, URL, UUID, custom regex) - Number constraints (min, max, positive, integer) - Date validation and transformation - Array and tuple validation - Object shape validation - Union and discriminated unions - Optional and nullable fields - Custom refinements and transforms - Error message customization ### assets/schema_templates/ Pre-built Zod schema templates: - `form_schema_template.ts` - Basic form validation - `api_route_schema_template.ts` - API route request/response - `server_action_schema_template.ts` - Server Action input/output - `entity_schema_template.ts` - Database entity validation ## Usage Workflow ### For New API Routes 1. Define request/response TypeScript types 2. Generate Zod schemas using `scripts/generate_zod_schema.py` or templates 3. Add validation middleware to route handler 4. Return typed validation errors on failure ### For Server Actions 1. Define input parameters as TypeScript types 2. Create Zod schema for validation 3. Use `.safeParse()` at the beginning of the action 4. Return validation errors in action result 5. Handle errors on the client side ### For Forms 1. Define form fields as TypeScript interface 2. Generate Zod schema with field validators 3. Integrate with form library (React Hook Form recommended) 4. Display validation errors inline ## Best Practices - Always use `.safeParse()` instead of `.parse()` to avoid throwing exceptions - Provide clear, user-friendly error messages - Validate early (at API boundary or Server Action entry) - Keep schemas colocated with routes/actions for maintainability - Use `z.infer<typeof schema>` for automatic TypeScript types - Document validation rules in schema comments - Test edge cases (empty values, invalid formats, boundary conditions) ## Integration with Worldbuilding App Common use cases for worldbuilding applications: - **Entity creation forms**: Validate character, location, faction data - **Relationship APIs**: Ensure valid entity IDs and relationship types - **Timeline events**: Validate dates, ordering, and event data - **Search/filter endpoints**: Validate query parameters and filters - **Bulk operations**: Validate arrays of entities or updates - **Import/export**: Validate file formats and data structure Consult `references/zod_patterns.md` for specific validation patterns applicable to worldbuilding entities.
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.