agentleFS
FirzusFirzus/agent-skills/skills/web/zod/SKILL.md

zod

Skill4 starsChanged 21 days agoMITView on GitHub

Zod schema validation. Use when writing or reviewing Zod schemas, parsing untrusted data, handling coercion, refinements, transforms or validation errors, integrating forms or APIs, exporting JSON Schema, or migrating Zod versions.

23 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use tailwind-css-patterns, typescript-advanced-types and 3 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • midudevSkill

    tailwind-css-patterns

    Provides comprehensive Tailwind CSS utility-first styling patterns including responsive design, layout utilities, flexbox, grid, spacing, typography, colors, and modern CSS best practices. Use when styling React/Vue/Svelte components, building responsive layouts, implementing design systems, or optimizing CSS workflow.

    Also in 3 projects that use this

  • xfstudioSkill

    typescript-advanced-types

    Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.

    Also in 5 projects that use this

  • VercelSkill

    turborepo

    Turborepo monorepo build system guidance. Triggers on: turbo.json, task pipelines, dependsOn, caching, remote cache, the "turbo" CLI, --filter, --affected, CI optimization, environment variables, internal packages, monorepo structure/best practices, and boundaries.

    Also in 4 projects that use this

  • VercelSkill

    ai-sdk

    Answer questions about the AI SDK and help build AI-powered features. Use when developers: (1) Ask about AI SDK functions like generateText, streamText, ToolLoopAgent, embed, or tools, (2) Want to build AI agents, chatbots, RAG systems, or text generation features, (3) Have questions about AI providers (OpenAI, Anthropic, Google, etc.), streaming, tool calling, structured output, or embeddings, (4) Use React hooks like useChat or useCompletion. Triggers on: "AI SDK", "Vercel AI SDK", "generateText", "streamText", "add AI to my app", "build an agent", "tool calling", "structured output", "useChat".

    Also in 3 projects that use this

  • BlockSkill

    frontend-design

    Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 23 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the consuming package's resolved Zod version, imports, TypeScript settings, existing schemas, adapters, and nearest tests.

    line 13
  2. Distinctive:

    Use strict TypeScript checking.

    line 16
  3. Very specific:

    Treat external data as unknown until the boundary succeeds.

    line 64
  4. Distinctive:

    Keep authorization, database uniqueness, and transaction guarantees in their existing enforcement layers.

    line 98
  5. Distinctive:

    Run the project's existing typecheck and focused tests.

    line 107

“Common” is measured: kept by at least 6 in 10 of the 23 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Zod

1. Establish the version and boundary

Read the consuming package's resolved Zod version, imports, TypeScript settings, existing schemas, adapters, and nearest tests. Account for multiple installed versions. Match the project's import style and preserve its validation layer. Use strict TypeScript checking; investigate incompatible adapters before changing their schema types. This skill targets Zod 4 Classic, with 4.6.5 as its documentation baseline; not every 4.x API is interchangeable.

Task branchRead before implementing
Zod 3 maintenance, major upgrade, or changing 4.x behaviormigration.md
Forms, query strings, environment variables, defaults, custom checks, errorsboundaries.md
Codecs, JSON Schema, metadata, Mini, library adapters, performanceinterop.md
Unclear API availability or disputed behaviorInstalled types and the official documentation for the resolved version

Identify the raw representation, accepted values, parsed output, failure consumer, and synchronous or asynchronous execution. Finish with those five decisions explicit for each changed boundary.

2. Encode the contract

Reuse existing domain schemas where their accepted values and unknown-key policy match. Infer application-owned types from schemas; for externally owned contracts, check compatibility without erasing the concrete schema's inferred type.

Contract decisionZod 4 choice
Input versus parsed dataz.input<typeof Schema> versus z.output<typeof Schema>; z.infer is output
Absent, null, or either.optional(), .nullable(), .nullish() respectively
Extra object keysz.object strips; z.strictObject rejects; z.looseObject retains; .catchall(schema) validates extras
Tagged alternativesz.discriminatedUnion with a shared discriminant
Untagged alternativesz.union; test overlapping branches and their resulting output
All enum keys requiredz.record(KeyEnum, ValueSchema)
Some enum keys allowedz.partialRecord(KeyEnum, ValueSchema)

Derive create, update, and public-response schemas deliberately. .partial() is shallow; a PATCH contract must define absent versus explicit null and which fields are writable. A database row schema is not automatically a safe write or response schema. Select allowed fields before persistence or serialization.

Compose plain object shapes with .extend() or explicit shape spread. Check overwritten keys and choose the resulting unknown-key policy. For refined objects on 4.1+, use .safeExtend(): spreading .shape preserves fields, not object-level checks. Its assignability check does not prove preservation of every runtime restriction. Prefer object composition over an intersection when downstream code needs object methods.

Finish when requiredness, variants, extra keys, and input/output differences are intentional rather than side effects of schema composition.

3. Parse and consume the result

Treat external data as unknown until the boundary succeeds. Choose safeParse for an expected validation-failure branch, or parse where throwing a ZodError matches the existing caller. Consume parsed data, including normalization, transforms, defaults, and stripped keys; a successful check does not rewrite input.

import * as z from "zod";

const RenameProject = z.strictObject({
  name: z.string().trim().min(1).max(120),
});

type RenameProjectInput = z.input<typeof RenameProject>;
type RenameProjectData = z.output<typeof RenameProject>;

export function validateRename(input: unknown) {
  const result = RenameProject.safeParse(input);
  if (!result.success) {
    return { ok: false as const, issues: result.error.issues };
  }
  return { ok: true as const, data: result.data };
}

Any asynchronous refinement or transform requires awaited parseAsync or safeParseAsync throughout its callers. Safe parsing handles validation failures, not arbitrary exceptions from user callbacks or unavailable services. Keep those failures distinct from invalid input.

For Zod 4.6+, .validate() answers only whether input is acceptable. Use it only when neither parsed output nor issues are needed; it narrows the input type, not the output type. See interop.md for measured hot paths.

Validate at the server trust boundary even when the client uses the same schema. Keep authorization, database uniqueness, and transaction guarantees in their existing enforcement layers. Format validation is not authentication, sanitization, or permission to fetch a URL. Bound request size and nesting before costly parsing.

Finish when downstream effects receive the parsed contract and each failure has an explicit owner.

4. Verify the changed boundary

Run the project's existing typecheck and focused tests. Select relevant cases:

  • Valid input yields the exact expected output, not merely success: true.
  • Wrong types, absent keys, explicit undefined, null, empty and whitespace-only strings take the intended paths.
  • Extra keys and privileged fields cannot cross the write or response boundary.
  • Union overlap, nested paths, numeric limits, and enum-record omissions behave as specified.
  • Coercion, defaults, transform order, and async rejection preserve the contract.
  • Composition retains cross-field checks; adapters receive the right input/output types and error shape.
  • Version changes preserve recorded fixtures or document intentional differences.

Report the resolved version, changed contracts, executed checks, and any untested integration.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.