API Design Patterns

Design scalable APIs across REST, GraphQL, and tRPC.

2|1|Updated Jul 22, 2024
One-click install
npx skills add https://github.com/mcgilly17/nix-configs --skill api-design-patterns-mcgilly17
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: API Design Patterns
Source: https://github.com/mcgilly17/nix-configs/tree/main/users/michael/common/ai-tools/claude-code/skills/api-design
Command: npx skills add https://github.com/mcgilly17/nix-configs --skill api-design-patterns-mcgilly17

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Designing APIs that are scalable, consistent, and easy to evolve across REST, GraphQL, and tRPC often leads to fragmentation and governance gaps. This Skill provides structured guidance to unify patterns, naming, versions, and schemas.

Core Features & Use Cases

  • REST API design: establish clear resource names, standard HTTP methods, consistent status codes, versioning, pagination, and filtering.
  • GraphQL design: craft clear schemas, type definitions, and resolver patterns to optimize data fetching and evolution.
  • tRPC patterns: define type-safe routers, procedures, and client usage for end-to-end type contracts.
  • Use Case: design a public API for a product, build internal microservices with uniform contracts, or expose SDKs with stable interfaces.

Quick Start

Define a basic API design for a sample User service by outlining REST endpoints (GET /api/users, GET /api/users/:id), a GraphQL User type and a tRPC router skeleton, and document the expected responses.

Frequently Asked Questions about API Design Patterns

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

FAQPage Schema
What are the best practices for REST API resource naming, status codes, and pagination?

Designing scalable REST APIs requires establishing clear resource names, standard HTTP methods, consistent status codes, and structured pagination. Applying these patterns ensures uniform contracts across public services and internal microservices.

How do I design a GraphQL schema with type definitions and resolver patterns?

Designing a GraphQL schema involves crafting clear type definitions and resolver patterns to optimize data fetching. This approach allows APIs to evolve smoothly while maintaining strict governance and efficient data retrieval.

How do I structure a tRPC router for type-safe procedures?

Structuring a tRPC router involves defining type-safe procedures and client usage patterns. This establishes end-to-end type contracts, ensuring robust type safety across your internal microservices and SDKs without requiring manual type synchronization.

How do I unify API design patterns across REST, GraphQL, and tRPC?

Unifying API design patterns across REST, GraphQL, and tRPC requires structured guidance to standardize naming, versions, and schemas. This prevents fragmentation and governance gaps when building scalable public APIs or internal microservices.

Does this API pattern guidance work for building internal microservices and SDKs?

Yes, this API pattern guidance applies to teams building internal microservices and exposing SDKs. It provides the structured rules needed to enforce consistent API contracts, stable interfaces, and uniform resource versioning across different services.