This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
The project uses pnpm workspaces. Key commands:
pnpm build- Build all packages (runs recursive build command)pnpm test- Run all tests with Vitestpnpm test:watch- Run tests in watch modepnpm dev- Execute code with tsx under source conditionspnpm dev <file>- Execute<file>with tsx & proper resolution conditions. Usually use forplay.ts.pnpm lint- Run biome linter with auto-fixpnpm format- Format code with biomepnpm fix- Run both format and lint
- Tests use Vitest with workspace-based configuration
- Test files are located in
src/*/tests/directories - Run specific tests:
pnpm test <pattern>orpnpm test --filter <workspace> <pattern> - Tests include type checking via
typecheck.enabled = true
In the packages/zod/ workspace:
pnpm build- Uses zshy build tool with tsconfig.build.jsonpnpm clean- Clean build artifacts (preserving node_modules)
Zod is a TypeScript-first schema validation library organized as a monorepo with multiple versions and variants:
- Root: Monorepo configuration with pnpm workspaces
- packages/zod/: Main Zod package with multiple version exports
- packages/docs/: Documentation website (Next.js)
- packages/bench/: Performance benchmarks
- packages/resolution/: Module resolution testing
- packages/treeshake/: Bundle size analysis
- packages/tsc/: TypeScript compilation benchmarks
The main zod package exports multiple versions:
- v4 (default): Current version, exports from
v4/classic/external.js - v4/core: Core v4 implementation without legacy compatibility
- v4/mini: Lightweight v4 variant
- v3: Legacy version for backward compatibility
- mini: General minimal build
src/v4/core/: Core validation logic, schemas, parsing, and error handlingsrc/v4/classic/: v4 with legacy compatibility layersrc/v4/mini/: Minimal v4 implementationsrc/v3/: Legacy v3 implementationsrc/locales/: Internationalization support
The package uses conditional exports with:
@zod/source: Development condition pointing to TypeScript source- Standard ESM/CJS exports for distribution
- Multiple entry points for different versions and variants
- Uses Biome for both linting and formatting
- Line width: 120 characters
- Trailing commas: ES5 style for JavaScript, none for JSON
- Notable lint rule relaxations:
noExplicitAny: "off"-anyis allowednoParameterAssign: "off"- Required for performance optimizationsnoNonNullAssertion: "off"- Non-null assertions are allowed
- Strict mode enabled with exact optional property types
- Node.js module resolution (NodeNext)
- Target: ES2020
- Custom conditions support for
@zod/source
- Use
play.tsfor initial experimentation withpnpm dev play.ts - Write tests in appropriate
tests/directories - Build with
pnpm buildbefore testing changes - Run linting/formatting with
pnpm fix - All changes must pass tests and type checking
- Uses
zshybuild tool for the main package - Generates both ES modules and CommonJS outputs
- Supports source maps and declaration files
- Post-build formatting with Biome
- Performance is critical - parameter reassignment is allowed for optimization
- Benchmarks available in
packages/bench/ - Bundle size monitoring in
packages/treeshake/ - TypeScript compilation performance tracked in
packages/tsc/