Zod 4 schema validation patterns. An agent skill from Gentleman-Programming/Gentleman-Skills.

Apache-2.0Auto-check passedFrontend & Design

Install Zod 4

skills CLI
$ npx skills add Gentleman-Programming/Gentleman-Skills --skill zod-4 -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Gentleman-Programming/Gentleman-Skills zod-4 --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Gentleman-Programming/Gentleman-Skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/curated/zod-4 .claude/skills/zod-4 && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
zod-4
GitHub stars
657
Token cost
~1.2k tokens
SKILL.md length
34 words
Files
1
Skills in repo
23
Repo updated
First seen
Licence
Apache-2.0

At a glance

Zod 4 schema validation patterns. An agent skill from Gentleman-Programming/Gentleman-Skills.

  • Tasks that involve Forms and validation
  • SKILL.md covers Breaking Changes from Zod 3, Basic Schemas, Object Schemas and Arrays and Records, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Zod 4 is an agent skill from Gentleman-Programming/Gentleman-Skills. Zod 4 schema validation patterns. Trigger: When using Zod for validation - breaking changes from v3.

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Frontend & Design, covering Forms and validation. It works with Zod. The repository describes itself as: Community-driven AI agent skills for Claude Code, OpenCode, and other AI assistants. Curated patterns and community contributions. The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Forms and validation

Example prompts

  • “/zod-4”

What it can do on your machine

Read from SKILL.md and the folder at commit c8036a3. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Zod 4 loads about 1.2k tokens when it runs. Until then it costs about 27 tokens; SKILL.md has 34 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~27
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Gentleman-Programming/Gentleman-Skills at commit c8036a3, republished under its Apache-2.0 licence (© Gentleman-Programming). 34 words, ~1,211 tokens.

Download SKILL.mdSave it as .claude/skills/zod-4/SKILL.md (or your agent's skills folder).
name
zod-4
description
Zod 4 schema validation patterns. Trigger: When using Zod for validation - breaking changes from v3.
license
Apache-2.0
metadata.author
gentleman-programming
metadata.version
1.0

Breaking Changes from Zod 3

typescript
// ❌ Zod 3 (OLD)
z.string().email()
z.string().uuid()
z.string().url()
z.string().nonempty()
z.object({ name: z.string() }).required_error("Required")

// ✅ Zod 4 (NEW)
z.email()
z.uuid()
z.url()
z.string().min(1)
z.object({ name: z.string() }, { error: "Required" })

Basic Schemas

typescript
import { z } from "zod";

// Primitives
const stringSchema = z.string();
const numberSchema = z.number();
const booleanSchema = z.boolean();
const dateSchema = z.date();

// Top-level validators (Zod 4)
const emailSchema = z.email();
const uuidSchema = z.uuid();
const urlSchema = z.url();

// With constraints
const nameSchema = z.string().min(1).max(100);
const ageSchema = z.number().int().positive().max(150);
const priceSchema = z.number().min(0).multipleOf(0.01);

Object Schemas

typescript
const userSchema = z.object({
  id: z.uuid(),
  email: z.email({ error: "Invalid email address" }),
  name: z.string().min(1, { error: "Name is required" }),
  age: z.number().int().positive().optional(),
  role: z.enum(["admin", "user", "guest"]),
  metadata: z.record(z.string(), z.unknown()).optional(),
});

type User = z.infer<typeof userSchema>;

// Parsing
const user = userSchema.parse(data);  // Throws on error
const result = userSchema.safeParse(data);  // Returns { success, data/error }

if (result.success) {
  console.log(result.data);
} else {
  console.log(result.error.issues);
}

Arrays and Records

typescript
// Arrays
const tagsSchema = z.array(z.string()).min(1).max(10);
const numbersSchema = z.array(z.number()).nonempty();

// Records (objects with dynamic keys)
const scoresSchema = z.record(z.string(), z.number());
// { [key: string]: number }

// Tuples
const coordinatesSchema = z.tuple([z.number(), z.number()]);
// [number, number]

Unions and Discriminated Unions

typescript
// Simple union
const stringOrNumber = z.union([z.string(), z.number()]);

// Discriminated union (more efficient)
const resultSchema = z.discriminatedUnion("status", [
  z.object({ status: z.literal("success"), data: z.unknown() }),
  z.object({ status: z.literal("error"), error: z.string() }),
]);

Transformations

typescript
// Transform during parsing
const lowercaseEmail = z.email().transform(email => email.toLowerCase());

// Coercion (convert types)
const numberFromString = z.coerce.number();  // "42" → 42
const dateFromString = z.coerce.date();      // "2024-01-01" → Date

// Preprocessing
const trimmedString = z.preprocess(
  val => typeof val === "string" ? val.trim() : val,
  z.string()
);

Refinements

typescript
const passwordSchema = z.string()
  .min(8)
  .refine(val => /[A-Z]/.test(val), {
    message: "Must contain uppercase letter",
  })
  .refine(val => /[0-9]/.test(val), {
    message: "Must contain number",
  });

// With superRefine for multiple errors
const formSchema = z.object({
  password: z.string(),
  confirmPassword: z.string(),
}).superRefine((data, ctx) => {
  if (data.password !== data.confirmPassword) {
    ctx.addIssue({
      code: z.ZodIssueCode.custom,
      message: "Passwords don't match",
      path: ["confirmPassword"],
    });
  }
});

Optional and Nullable

typescript
// Optional (T | undefined)
z.string().optional()

// Nullable (T | null)
z.string().nullable()

// Both (T | null | undefined)
z.string().nullish()

// Default values
z.string().default("unknown")
z.number().default(() => Math.random())

Error Handling

typescript
// Zod 4: Use 'error' param instead of 'message'
const schema = z.object({
  name: z.string({ error: "Name must be a string" }),
  email: z.email({ error: "Invalid email format" }),
  age: z.number().min(18, { error: "Must be 18 or older" }),
});

// Custom error map
const customSchema = z.string({
  error: (issue) => {
    if (issue.code === "too_small") {
      return "String is too short";
    }
    return "Invalid string";
  },
});

React Hook Form Integration

typescript
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";

const schema = z.object({
  email: z.email(),
  password: z.string().min(8),
});

type FormData = z.infer<typeof schema>;

function Form() {
  const { register, handleSubmit, formState: { errors } } = useForm<FormData>({
    resolver: zodResolver(schema),
  });

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input {...register("email")} />
      {errors.email && <span>{errors.email.message}</span>}
    </form>
  );
}

Keywords

zod, validation, schema, typescript, forms, parsing

© Gentleman-Programming, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in curated/zod-4 of Gentleman-Programming/Gentleman-Skills.

Open the folder on GitHubat commit c8036a3

Compare with similar skills

Zod 4 next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Zod 4 compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Zod 4 this skillGentleman-Programming/Gentleman-Skills657—~1.2kAutomated safety check: PassApache-2.0
World Book Skillecho-xianyu/worldbook-skill211—~1.8kAutomated safety check: PassCustom licence
Reglevictorgarciaesgi/regle506—~840Automated safety check: PassMIT
Buzzformbuildnbuzz/buzzform101—~1.5kAutomated safety check: PassMIT
Regle Migrate Vuelidatevictorgarciaesgi/regle506—~752Automated safety check: PassMIT
Shared SchemasInsForge/InsForge13k—~628Automated safety check: PassApache-2.0

Similar skills

  • World Book Skill

    echo-xianyu/worldbook-skill

    Create and manage SillyTavern Character Cards (角色卡) and World Books (世界书).

    211 GitHub stars~1.8k tokensUpdated 4 mo ago
    Frontend & DesignAuto-check passed
  • Regle

    victorgarciaesgi/regle

    Core Regle form validation in Vue 3 — setup with useRegle, the reactive r$ object, validation properties, displaying errors, and modifiers.

    506 GitHub stars~840 tokensUpdated 10 days ago
    Frontend & DesignAuto-check passed
  • Buzzform

    buildnbuzz/buzzform

    A skill your agent uses when working with BuzzForm schema-driven forms, @buildnbuzz/form-core, @buildnbuzz/form-react, or any related APIs like defineSchema, InferType, FormProvider, useDataField…

    101 GitHub stars~1.5k tokensUpdated 4 mo ago
    Frontend & DesignAuto-check passed
  • Regle Migrate Vuelidate

    victorgarciaesgi/regle

    Migrate Vuelidate form validation to Regle. An agent skill from victorgarciaesgi/regle.

    506 GitHub stars~752 tokensUpdated 10 days ago
    Frontend & DesignAuto-check passed
  • Shared Schemas

    InsForge/InsForge

    A skill your agent uses when contributing to InsForge's shared schema package.

    13k GitHub stars~628 tokensUpdated 2 days ago
    Frontend & DesignAuto-check passed
  • Sets the conventions for the Opik React frontend: TanStack Query for data, Zustand for shared state, one-way layer imports and a fix for Google Translate crashes.

    22k GitHub stars~1.1k tokensUpdated yesterday
    Frontend & DesignAuto-check passed

More from Gentleman-Programming/Gentleman-Skills

All 23 skills in this repo
  • Elixir Antipatterns

    Gentleman-Programming/Gentleman-Skills

    Core catalog of 8 critical Elixir/Phoenix anti-patterns covering error handling, separation of concerns, Ecto queries, and testing.

    657 GitHub stars~2.1k tokensUpdated 6 mo ago
    Auto-check passed
  • Skill Creator

    Gentleman-Programming/Gentleman-Skills

    Creates new AI agent skills following the Agent Skills spec.

    657 GitHub stars~1.1k tokensUpdated 6 mo ago
    Auto-check: notes
  • Angular Architecture

    Gentleman-Programming/Gentleman-Skills

    Angular architecture: Scope Rule, project structure, file naming, style guide.

    657 GitHub stars~823 tokensUpdated 6 mo ago
    Auto-check passed
  • Angular Core

    Gentleman-Programming/Gentleman-Skills

    Angular core patterns: standalone components, signals, inject, control flow, zoneless.

    657 GitHub stars~1.1k tokensUpdated 6 mo ago
    Auto-check passed
  • Angular Forms

    Gentleman-Programming/Gentleman-Skills

    Angular forms: Signal Forms (experimental) and Reactive Forms.

    657 GitHub stars~687 tokensUpdated 6 mo ago
    Auto-check passed
  • Angular Performance

    Gentleman-Programming/Gentleman-Skills

    Angular performance: NgOptimizedImage, @defer, lazy loading, SSR.

    657 GitHub stars~703 tokensUpdated 6 mo ago
    Auto-check passed

Works with

Questions about Zod 4

What does Zod 4 do?

Zod 4 schema validation patterns. An agent skill from Gentleman-Programming/Gentleman-Skills. Zod 4 is an agent skill from Gentleman-Programming/Gentleman-Skills. Zod 4 schema validation patterns.

When should I use Zod 4?

Zod 4 fits situations like: tasks that involve Forms and validation.

How do I install Zod 4 in Claude Code?

Run `npx skills add Gentleman-Programming/Gentleman-Skills --skill zod-4 -a claude-code`. Or copy the skill folder (curated/zod-4 in Gentleman-Programming/Gentleman-Skills) into .claude/skills/zod-4 in your project. Claude Code loads it when a task matches its description.

How do I install Zod 4 in Codex?

Run `npx skills add Gentleman-Programming/Gentleman-Skills --skill zod-4 -a codex`. Or copy the skill folder (curated/zod-4 in Gentleman-Programming/Gentleman-Skills) into .agents/skills/zod-4 in your project. Codex loads it when a task matches its description.

Can I use Zod 4 in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Gentleman-Programming/Gentleman-Skills --skill zod-4 -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/zod-4, .gemini/skills/zod-4, .github/skills/zod-4 and .opencode/skills/zod-4 in your project.

What does Zod 4 need to run?

SKILL.md names no scripts, command-line tools or credentials: Zod 4 is instructions for the agent only.

Does Zod 4 access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Zod 4 safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Zod 4 use?

Zod 4 is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Zod 4 use?

About 1.2k tokens (SKILL.md is roughly 4.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Zod 4?

Skills that share tags, products or a category with Zod 4: World Book Skill (echo-xianyu/worldbook-skill, 211 stars), Regle (victorgarciaesgi/regle, 506 stars), Buzzform (buildnbuzz/buzzform, 101 stars) and Regle Migrate Vuelidate (victorgarciaesgi/regle, 506 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Zod 4?

Gentleman-Programming (a GitHub organization) maintains it in Gentleman-Programming/Gentleman-Skills, which has 657 GitHub stars. The repository holds 23 skills in this directory. The repository was last updated on March 28, 2026.

Source: Gentleman-Programming/Gentleman-Skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.