/tooling:zod-conventionsfrom tooling
Conventions for Zod schemas: FooSchema naming, packages/shared location, schema composition (extend/pick/omit/merge), z.coerce for HTTP values, NestJS ZodValidationPipe integration, and error formatting.
Ships in tooling. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
FooSchema for schema, Foo for inferred type:
import { z } from 'zod';
export const CreateReceiptSchema = z.object({
leaseId: z.string().uuid(),
period: z.object({
year: z.number().int().min(2020),
month: z.number().int().min(1).max(12),
}),
});
export type CreateReceiptDto = z.infer<typeof CreateReceiptSchema>;
All schemas live in packages/shared so both apps/api and apps/web can import them:
packages/shared/src/
├── dto/
│ ├── receipt.dto.ts # CreateReceiptSchema, UpdateReceiptSchema
│ ├── tenant.dto.ts # CreateTenantSchema, LoginSchema
│ └── index.ts # Re-exports
├── enums/
│ └── status.ts # as const enums
└── index.ts # Barrel export
// Usage in apps/api or apps/web
import { CreateReceiptSchema, type CreateReceiptDto } from '@app/shared';
const BaseTenantSchema = z.object({
email: z.string().email(),
firstName: z.string().min(1),
lastName: z.string().min(1),
});
// Extend
const CreateTenantSchema = BaseTenantSchema.extend({
password: z.string().min(8),
});
// Pick
const LoginSchema = BaseTenantSchema.pick({ email: true }).extend({
password: z.string(),
});
// Omit
const PublicTenantSchema = BaseTenantSchema.omit({ email: true });
const WithTimestamps = z.object({
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
});
const TenantResponseSchema = BaseTenantSchema.merge(WithTimestamps);
Use z.coerce.* for values from HTTP (query strings, form data) that arrive as strings:
// ❌ AVOID - Fails on "123" from query string
const schema = z.object({
page: z.number(), // Rejects "123" (string)
});
// ✅ CORRECT - Coerces string to number
const schema = z.object({
page: z.coerce.number().int().min(1).default(1),
date: z.coerce.date(),
active: z.coerce.boolean(),
});
// src/infrastructure/http/pipes/zod-validation.pipe.ts
import { PipeTransform, BadRequestException } from '@nestjs/common';
import { ZodSchema } from 'zod';
export class ZodValidationPipe implements PipeTransform {
constructor(private readonly schema: ZodSchema) {}
transform(value: unknown) {
const result = this.schema.safeParse(value);
if (!result.success) {
throw new BadRequestException(result.error.flatten());
}
return result.data;
}
}
@Post()
async create(
@Body(new ZodValidationPipe(CreateReceiptSchema)) dto: CreateReceiptDto,
) {
return this.receiptService.generate(dto);
}
@Get()
async list(
@Query(new ZodValidationPipe(PaginationSchema)) query: PaginationDto,
) {
return this.receiptService.findAll(query);
}
safeParse + flatten() produces a clean error structure:
const result = schema.safeParse(input);
if (!result.success) {
const errors = result.error.flatten();
// {
// formErrors: [],
// fieldErrors: {
// email: ['Invalid email'],
// period: ['Required'],
// }
// }
}
| Rule | Convention |
|---|---|
| Naming | FooSchema + z.infer<typeof FooSchema> |
| Location | packages/shared/src/dto/ |
| Composition | .extend(), .pick(), .omit(), .merge() |
| HTTP values | z.coerce.* for strings from query/form |
| NestJS | ZodValidationPipe in @Body() / @Query() |
| Errors | safeParse + flatten() |
| Exports | Barrel file in packages/shared |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub fabiensalles/claude-marketplace --plugin tooling5 skills in this plugin
/docker-integrationACTIVATE when integrating a new Docker image, writing docker-compose.yml services, or adding external tools to a Docker stack. ACTIVATE for 'docker-compose', 'Docker image', 'container setup', 'service integration'. Covers: mandatory RTFM checklist before writing any docker-compose line (volumes, ports, env vars, healthchecks, internal architecture), image inspection commands, common anti-patterns that cause silent failures. DO NOT use for: Dockerfile writing, CI/CD pipeline configuration (see tooling:github-actions-conventions), Kubernetes./drizzle-conventionsACTIVATE when defining database schemas, writing queries, creating migrations, or implementing repositories with Drizzle ORM. ACTIVATE for 'Drizzle', 'pgTable', 'drizzle-kit', 'db.query', 'db.select', '$inferSelect', 'migration'. Covers: schema definition with pgTable, relations, type inference ($inferSelect/$inferInsert), Query API vs Select API vs raw SQL decision tree, repository pattern with toDomain/toPersistence, migration workflow (always drizzle-kit generate first, never manual journal). DO NOT use for: Doctrine/PHP queries (see php-sql-conventions), general SQL formatting./github-actions-conventionsACTIVATE when writing, reviewing or debugging a GitHub Actions workflow: jobs, timeouts, concurrency, a scheduled canary, path filters, caching, a red or stuck run. ACTIVATE for '.github/workflows', 'timeout-minutes', 'cancel-in-progress', 'on: schedule', 'nightly CI job', 'required check Pending', 'not acquired by Runner'. Covers: one entry step and one size per job, PR-only cancellation, pinned gate vs floating canary, allowlist guards, macOS legs. DO NOT use for: test sizes and where each check runs (see craft:test-suite-design), a canary release to users (see product:delivery), node --test flags (see node-test:node-test-conventions), bash 3.2 script fixes (see mac:mac-platform)./pnpm-workspaceACTIVATE when configuring monorepo structure, cross-package imports, workspace scripts, or pnpm workspace protocol. ACTIVATE for 'pnpm workspace', 'workspace:*', 'monorepo', 'pnpm --filter', 'packages/shared'. Covers: workspace structure (packages/shared + apps/api + apps/web), workspace:* protocol, build order (shared first), filtering commands, shared vs per-package dependencies. DO NOT use for: individual package configuration, npm/yarn workspaces.