api-contracts-and-validation
Define and validate API contracts using Zod
Best use case
api-contracts-and-validation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Define and validate API contracts using Zod
Teams using api-contracts-and-validation should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/api-contracts-and-validation/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How api-contracts-and-validation Compares
| Feature / Agent | api-contracts-and-validation | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Define and validate API contracts using Zod
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# API Contracts & Validation Skill
## Overview
Define Zod schemas as the source of truth for API contracts and validation.
## Usage
```
/api-contracts-and-validation
```
## Documentation Reference
- Use Ref tools to confirm Zod API details and best practices when needed.
## Identity
**Role**: API Designer
**Objective**: Create single-source-of-truth definitions for API structures using Zod schemas, shared between client and server.
## Standards
### 1. Zod First
Define the schema **before** the Typescript type.
```typescript
import { z } from 'zod';
// 1. Schema
export const UserSchema = z.object({
id: z.string().uuid(),
email: z.string().email(),
role: z.enum(['ADMIN', 'USER']),
meta: z.record(z.string()).optional()
});
// 2. Inference
export type User = z.infer<typeof UserSchema>;
```
### 2. Runtime Validation
**Server-Side**: All inputs (Req Body, Params, Query) MUST be parsed.
```typescript
app.post('/user', (req, res) => {
const result = UserSchema.safeParse(req.body);
if (!result.success) return res.status(400).json(result.error);
// ...
});
```
### 3. Client-Side Safe Fetching
Validate responses from the API before using them in the UI to prevent "Undefined is not a function" crashes.
## Workflow
### Contract Creation
**Command**: `/make-contract <name>`
1. **Define**: Create `src/contracts/<domain>.contract.ts`.
2. **Schema**: Write Zod schema for Request, Response, and Errors.
3. **Export**: Export inferred types.
### Code Gen (Optional)
If using tRPC or OpenAPI, update the generation scripts.
## Error Handling
- **Parse Errors**: Zod returns detailed error maps. Convert these to user-friendly messages for the frontend.
- **Strict Mode**: Schemas should use `.strict()` by default to strip unknown fields.
## Outputs
- Zod schemas and derived types for shared API contracts.
## Related Skills
- `/ts-strict-guardian` - Enforce strict TypeScript safetyRelated Skills
bio-alignment-validation
Validate alignment quality with insert size distribution, proper pairing rates, GC bias, strand balance, and other post-alignment metrics. Use when verifying alignment data quality before variant calling or quantification.
date-validation
Use when editing Planning Hubs, timelines, calendars, or any file with day-name + date combinations (Wed Nov 12), relative dates (tomorrow), or countdowns (18 days until) - validates day-of-week accuracy, relative date calculations, and countdown math with two-source ground truth verification before allowing edits
spring-validation
Bean Validation (Jakarta Validation) with Spring Boot. Custom validators, validation groups, cross-field validation, and internationalized error messages.
Smart Contracts
Smart contracts are self-executing programs on blockchain. This guide covers Solidity basics, contract deployment, interaction, and frontend integration for building decentralized applications with au
fullstack-validation
Comprehensive validation methodology for multi-component applications including backend, frontend, database, and infrastructure
Data Contracts
A Data Contract is a formal agreement between a data producer (e.g., a microservice) and a data consumer (e.g., a data platform) that defines the structure, semantics, and quality of data being shared
api-validation
Apply when validating API request inputs: body, query params, path params, and headers. This skill covers Zod v4 patterns.
api-request-validation
A skill for implementing robust API request validation in Python web frameworks like FastAPI using Pydantic. Covers Pydantic models, custom validators (email, password), field-level and cross-field validation, query/file validation, and structured error responses. Use when you need to validate incoming API requests.
API Contracts Generator
Génère des contrats API cohérents entre Frontend (Next.js) et Backend (NestJS) avec types synchronisés, validation standardisée et error handling uniforme. À utiliser lors de la création d'APIs, DTOs, types frontend/backend, ou quand l'utilisateur mentionne "API", "DTO", "types", "contract", "validation", "frontend-backend", "synchronisation".
api-contracts-and-zod-validation
Generate Zod schemas and TypeScript types for forms, API routes, and Server Actions with runtime validation. Use this skill when creating API contracts, validating request/response payloads, generating form schemas, adding input validation to Server Actions or route handlers, or ensuring type safety across client-server boundaries. Trigger terms include zod, schema, validation, API contract, form validation, type inference, runtime validation, parse, safeParse, input validation, request validation, Server Action validation.
api-contract-validation
Detect breaking changes in API contracts (OpenAPI/Swagger specs)
android-playstore-api-validation
Create and run validation script to test Play Store API connection