Agent skill
zod
Esposter Zod schema conventions — z namespace imports, no optional+default combos, generic schemas with create* functions, vjsf form schemas, and satisfies with ToData for class types. Apply when writing Zod schemas.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/zod-esposter-esposter
SKILL.md
Zod Conventions
Imports
Always use the z namespace export: z.ZodType, z.ZodError, etc. Never use named imports like import type { ZodType }.
Schema Rules
.default()— do not combine.optional().default(value);.default()already handlesundefinedinput, so.optional()is redundant.- Generic schemas — when an abstract class has a generic type parameter (e.g.
ADataSourceItem<TType, TConfig>), its schema must also be generic. Export acreate*Schemafunction that takes typed zod schemas as parameters and returns the composed schema. Never hardcode type-specific values in a base schema. UseTfor a single type parameter, descriptiveT*names (e.g.TType,TConfiguration) for multiple:typescriptFor the union schema used by parent models, create a separate// WRONG — hardcodes type, missing configuration export const aDataSourceItemSchema = z.object({ ...base.shape, type: dataSourceTypeSchema }); // CORRECT — generic function, concrete schemas passed by callers export const createDataSourceItemSchema = < TType extends z.ZodType<keyof DataSourceConfigurationTypeMap>, TConfiguration extends z.ZodType<object>, >( typeSchema: TType, configurationSchema: TConfiguration, ) => z.object({ ...aTableEditorItemEntitySchema.shape, configuration: configurationSchema, type: typeSchema }); // Caller: export const csvDataSourceItemSchema = createDataSourceItemSchema( z.literal(DataSourceType.Csv), csvDataSourceConfigurationSchema, ) satisfies z.ZodType<ToData<CsvDataSourceItem>>;*ItemSchema.tsfile usingz.discriminatedUnion:typescriptAdding a new type = add its schema to the discriminated union array.export const dataSourceItemSchema = z.discriminatedUnion("type", [csvDataSourceItemSchema]); - vjsf form schemas — never pass a full entity schema to
zodToJsonSchema()if it containsz.date()fields — vjsf will throw. Create a separate*FormSchemaco-located in the same file using.pick().extend()to add.meta()titles. The form schema picks only user-editable fields (no entity metadata likeid,createdAt,updatedAt). satisfies z.ZodType<T>with class types — when a schema output has plain objects but the interface uses class instances (withtoJSON), useExcept+ToDatain the satisfies to striptoJSONfrom nested classes:typescriptexport const dataSourceSchema = z.object({...}) satisfies z.ZodType<Except<DataSource, "columns"> & { columns: ToData<Column>[] }>;
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?