AgentSkillsCN

Global Validation

利用Zod架构对内容集合、API输入、表单数据,以及环境变量进行运行时验证与类型安全检查。在验证用户输入、API请求、内容架构,或确保数据完整性时使用此技能。在处理src/content/config.ts中的内容集合架构定义、使用Zod进行API路由输入验证、进行表单验证(服务器端与客户端)、验证环境变量、在运行时进行组件Props验证、验证URL与查询参数、对请求体与表单数据进行净化、进行TypeScript运行时类型验证,或实施自定义的Zod精炼与转换时使用此技能。

SKILL.md
--- frontmatter
name: Global Validation
description: Implement runtime validation and type safety using Zod schemas for Content Collections, API inputs, form data, and environment variables. Use this skill when validating user input, API requests, content schemas, or ensuring data integrity. When working on Content Collections schema definitions in src/content/config.ts, API route input validation with Zod, form validation (server-side and client-side), environment variable validation, component prop validation with runtime checks, URL and query parameter validation, request body and form data sanitization, TypeScript runtime type validation, or custom Zod refinements and transformations.

Global Validation

This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle global validation.

When to use this skill

  • When defining Content Collection Zod schemas in src/content/config.ts
  • When validating API route inputs (query params, request body, headers)
  • When implementing server-side form validation in API endpoints
  • When validating environment variables on application startup
  • When adding client-side HTML5 form validation attributes
  • When sanitizing user input to prevent XSS attacks
  • When validating URLs, emails, or other formatted data types
  • When implementing component prop validation for critical components
  • When using Zod safeParse for validation with detailed error messages
  • When creating custom Zod refinements for complex validation rules
  • When ensuring type safety at runtime, not just compile-time

Instructions

For details, refer to the information provided in this file: global validation