api-contracts-and-validation

Define and validate API contracts using Zod

16 stars

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

$curl -o ~/.claude/skills/api-contracts-and-validation/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/backend/api-contracts-and-validation/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/api-contracts-and-validation/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How api-contracts-and-validation Compares

Feature / Agentapi-contracts-and-validationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/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 safety

Related Skills

bio-alignment-validation

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

Bean Validation (Jakarta Validation) with Spring Boot. Custom validators, validation groups, cross-field validation, and internationalized error messages.

Smart Contracts

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

Comprehensive validation methodology for multi-component applications including backend, frontend, database, and infrastructure

Data Contracts

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

Apply when validating API request inputs: body, query params, path params, and headers. This skill covers Zod v4 patterns.

api-request-validation

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

Detect breaking changes in API contracts (OpenAPI/Swagger specs)

android-playstore-api-validation

16
from diegosouzapw/awesome-omni-skill

Create and run validation script to test Play Store API connection