api-and-interface-design

Designs stable REST APIs, TypeScript contracts, and idempotent interfaces with consistent error semantics.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Public interfaces become accidental commitments: undocumented behaviors get depended on (Hyrum's Law), breaking changes slip in, error formats diverge across endpoints, and retry storms cause duplicate charges when idempotency keys are accepted but not honored. This Skill provides concrete design rules and code patterns to prevent those failures before an API ships. ## Core Features & Use Cases - Contract-First Design: Define typed input/output schemas, discriminated unions, and branded ID types before implementation. - Consistent Error Semantics: One structured error shape mapped to HTTP status codes, with validation only at system boundaries. - Idempotency Implementation: Atomic key claiming via unique constraints, payload-hash guarding, in-flight duplicate strategies, and retention sizing. - Use Case: When adding a payment endpoint to a FastAPI or Express backend, apply the idempotency checklist so client retries during a dependency outage never produce duplicate charges. ## Quick Start Ask the AI to review your new REST endpoint design against the API and interface design principles, including error format, pagination, and 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 won't break existing clients?▼

Define the contract first with typed input and output schemas, then evolve it by adding optional fields only. Never change existing field types or remove fields, and follow consistent naming conventions like plural nouns for endpoints and camelCase for fields.

How to implement idempotency keys for payment or order APIs?▼

Accept a client-generated Idempotency-Key header and claim it atomically with a database unique constraint, not a check-then-insert. Reject the same key with a different payload, decide how in-flight duplicates are handled (409, wait, or 202), and retain keys longer than any retry path.

Should I use PATCH or PUT for updating resources?▼

Use PATCH for partial updates where only provided fields change, which is what clients actually want. PUT requires sending the full object every time, making it fragile for large resources and prone to overwriting concurrent changes.

Where should input validation happen in a web application?▼

Validate only at system boundaries: API route handlers, form submissions, environment variable loading, and third-party API responses. Internal functions that share type contracts should trust already-validated data rather than re-validating at every layer.

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

Hyrum's Law states that all observable behaviors of a system will be depended on by somebody, regardless of the documented contract. It means every public behavior is a commitment, so avoid leaking implementation details and plan deprecation strategies at design time.