api-and-interface-design

Design stable REST APIs, TypeScript interfaces, and module contracts with consistent error semantics.

Updated Apr 28, 2026
One-click install
npx skills add https://github.com/visdomtech/skills --skill api-and-interface-design-visdomtech
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/visdomtech/skills/tree/main/api-and-interface-design
Command: npx skills add https://github.com/visdomtech/skills --skill api-and-interface-design-visdomtech

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly designed interfaces create breaking changes, inconsistent error handling, and hidden dependencies that break consumers. This Skill guides the design of stable, hard-to-misuse APIs and module boundaries before implementation begins. ## Core Features & Use Cases - Contract-First Design: Define typed input/output schemas, discriminated unions, and branded ID types before writing implementation code. - REST API Patterns: Apply conventions for resource naming, pagination, filtering, partial updates (PATCH), and consistent structured error responses. - Idempotency Implementation: Correctly honour Idempotency-Key headers with atomic claims via unique constraints, payload guards, and deliberate in-flight duplicate handling. - Use Case: When creating a new payments endpoint, use this Skill to define the contract first, design idempotent retry semantics, and ensure every error response follows one consistent shape. ## Quick Start Use the api-and-interface-design skill to review my new REST endpoint design for breaking changes and missing idempotency handling.

Frequently Asked Questions about api-and-interface-design

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

FAQPage Schema
How do I design a REST API that doesn't break existing consumers?▼

Design REST APIs for extension rather than modification: add only optional fields, never change existing field types or remove fields. Use plural nouns in URLs, paginate all list endpoints, and support PATCH for partial updates so clients send only what changes.

How to implement idempotency keys for payment APIs?▼

Implement idempotency by inserting the key with a unique constraint in one atomic operation, never a check-then-insert. Derive keys from immutable identifiers like order IDs, reject reused keys with different payloads, and set retention longer than the longest retry path including dead-letter replays.

Where should input validation happen in an API?▼

Validation belongs at system boundaries: API route handlers, form submissions, environment variable loading, and third-party API response parsing. Internal functions sharing type contracts should trust already-validated data rather than re-validating at every layer.

Should I use PUT or PATCH for API updates?▼

Use PATCH for updates because it accepts partial objects, changing only provided fields. PUT requires clients to send the full object every time, which creates race conditions and forces clients to track fields they do not intend to modify.

What is Hyrum's Law and why does it matter for API design?▼

Hyrum's Law states that all observable behaviors of an API will be depended on by somebody, including undocumented quirks and error message text. It means every public behavior is a de facto commitment, so design intentionally about what you expose and plan deprecation at design time.

When should I not trust third-party API responses?▼

Never trust third-party API responses; always validate their shape and content before use. A compromised or misbehaving external service can return unexpected types, malicious content, or instruction-like text that corrupts your logic or rendering.