api-and-interface-design

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly designed APIs and module boundaries create breaking changes, inconsistent error handling, and duplicate side effects that erode consumer trust. This Skill guides the design of stable, hard-to-misuse interfaces 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. - Consistent Error Semantics: Enforce a single error response shape with machine-readable codes and correct HTTP status mapping across all endpoints. - Idempotency Implementation: Honour Idempotency-Key headers with atomic key claiming via unique constraints, payload hashing, and deliberate in-flight duplicate handling. - Use Case: When designing a new payments endpoint, use this Skill to define the REST resource shape, pagination, validation-at-boundary rules, and an idempotency strategy that survives retry storms and dead-letter queue replays. ## Quick Start Ask the agent to design a REST API for a new resource, including typed contracts, 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 consumers?

Define the contract first with typed input and output schemas, then extend interfaces only by adding optional fields. 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 POST endpoints?

Accept an Idempotency-Key header derived from the client's intent, then claim it atomically using a database unique constraint rather than a check-then-insert. Guard the payload with a request hash so a reused key with a different body fails loudly, and set key retention to outlive the longest retry path.

Where should input validation happen in an API?

Validation belongs at system boundaries: API route handlers, form submissions, external service responses, and environment variable loading. Internal functions that share type contracts should trust already-validated data rather than re-validating.

Should I use PUT or PATCH for updating resources?

Use PATCH for partial updates where only provided fields change, which matches what clients actually need. PUT requires sending the full object every time and increases the risk of accidentally overwriting fields.

What HTTP status codes should API errors return?

Use 400 for invalid client data, 401 for missing authentication, 403 for authorization failures, 404 for missing resources, 409 for conflicts, 422 for semantic validation failures, and 500 for server errors without exposing internal details. Pair every status with one consistent error body shape.

Why do duplicate charges happen even with idempotency keys?

Duplicates occur when the key is regenerated per attempt, claimed with a racy check-then-insert, or expired before the longest retry path completes. Timeouts also create an unknown third outcome, so record intent before calling external services.