zod-extract

Moves inline Zod schemas into a centralized validations directory in TypeScript projects.

Updated Sep 12, 2021
One-click install
npx skills add https://github.com/cerico/macfair --skill zod-extract
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zod-extract
Source: https://github.com/cerico/macfair/tree/main/files/claude/skills/zod-extract
Command: npx skills add https://github.com/cerico/macfair --skill zod-extract

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Find inline Zod schemas defined outside validations/ and centralize them.

Core Features & Use Cases

  • Detects inline Zod schemas across a TypeScript project.
  • Creates or updates validations/[entity].ts files and exports types.
  • Updates imports and barrel exports in validations/index.ts to point to centralized schemas.

Quick Start

Run zod-extract on your TypeScript codebase to move all inline Zod schemas into the validations directory and update references accordingly.

Frequently Asked Questions about zod-extract

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I centralize inline Zod schemas in a TypeScript project?

Centralizing inline Zod schemas involves detecting them across your TypeScript codebase and moving them into a validations directory. This updates all imports and barrel exports so files continue referencing the correct validation logic.

Why should I move Zod schemas out of my UI and API layers?

Moving Zod schemas out of UI and API layers centralizes validation logic into a dedicated validations directory. This prevents scattered schemas and ensures consistent type exports and imports across separate application layers.

Can I automatically update imports when refactoring Zod validations?

Yes, refactoring Zod validations can automatically update imports and index exports. When schemas are moved to a validations directory, the process updates all references to point to the newly centralized schema files.

Does zod-extract work with TypeScript projects using Zod across multiple layers?

Yes, zod-extract targets TypeScript projects using Zod across UI, API, and domain layers. It detects inline schemas in these layers and centralizes them into dedicated validations files with updated exports.

What is the best way to export TypeScript types from centralized Zod schemas?

The best way to export TypeScript types from centralized Zod schemas is to place them in a validations directory. This creates entity-specific files, exports the inferred types, and updates the barrel index for imports.