shared-api-types

Define shared Zod schemas and TypeScript types for API contracts.

1|Updated Jan 2, 2025
One-click install
npx skills add https://github.com/allenlin90/eridu-services --skill shared-api-types
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shared-api-types
Source: https://github.com/allenlin90/eridu-services/tree/main/.agent/skills/shared-api-types
Command: npx skills add https://github.com/allenlin90/eridu-services --skill shared-api-types

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Establishes a single source of truth for API contracts by standardizing how frontend and backend share types and schemas across services.

Core Features & Use Cases

  • Defines and exports runtime schemas and TypeScript types from the shared package.
  • Enforces domain-scoped imports (e.g., @eridu/api-types/users, @eridu/api-types/task-management).
  • Provides guidance for transforming Prisma outputs to DTOs and for validating inputs.

Quick Start

Import shared schemas and types from the api-types package in both frontend and backend projects to start validating inputs and coordinating DTOs.

Frequently Asked Questions about shared-api-types

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

FAQPage Schema
How do I share TypeScript types and Zod schemas between frontend and backend services?

You can share TypeScript types and Zod schemas by defining them in a single shared package and importing them in both frontend and backend projects to establish a single source of truth for API contracts.

What is the best way to transform Prisma outputs to DTOs while maintaining API contracts?

Transform Prisma outputs to DTOs by applying guidance from the shared package, using exported Zod schemas to validate inputs and ensure the frontend receives consistently structured data.

How do I enforce domain-scoped imports for API contracts across different services?

Domain-scoped imports are enforced by structuring the shared package to export types and schemas through specific domain paths, such as importing from @eridu/api-types/users for user-related contracts.

When do I need a single source of truth for API contracts in a TypeScript monorepo?

A single source of truth is needed when defining API contracts, validating inputs, or coordinating DTOs across frontend and backend services to prevent type mismatches and runtime validation failures.

Does defining API contracts with Zod schemas require external dependencies?

Defining API contracts with Zod schemas in this Skill requires no external dependencies, allowing you to infer TypeScript types directly from the schemas without installing additional validation libraries.