api-and-interface-design

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

5|Updated Feb 12, 2026
One-click install
npx skills add https://github.com/PHenrique07/Sementis-IFSP-Pirituba --skill api-and-interface-design-phenrique07
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/PHenrique07/Sementis-IFSP-Pirituba/tree/main/.github/skills/api-and-interface-design
Command: npx skills add https://github.com/PHenrique07/Sementis-IFSP-Pirituba --skill api-and-interface-design-phenrique07

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly designed interfaces create breaking changes, inconsistent error handling, and hidden dependencies that frustrate consumers and multiply maintenance cost. 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. - Consistent Error Semantics: Apply a single structured error format with correct HTTP status code mapping across all endpoints. - Idempotency Key Handling: Implement atomic key claiming, payload guards, and retention policies for safe retries of state-changing operations. - Use Case: When adding a new payments endpoint to a Flask or Express backend, use this Skill to define the resource routes, pagination, validation-at-boundary rules, and idempotency behavior so clients can retry safely without duplicate charges. ## Quick Start Use the api-and-interface-design skill to review my new REST endpoint design for consistency, pagination, and idempotency before I implement it.

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?▼

Prefer addition over modification: add new fields as optional and never change or remove existing field types. Define the contract first with typed input and output schemas, and plan for deprecation at design time since consumers depend on all observable behavior.

How to implement idempotency keys for payment or POST endpoints?▼

Accept a client-generated Idempotency-Key header and claim it atomically using a database unique constraint, not a check-then-insert. Reject the same key reused with a different payload, and set key retention longer than the longest possible retry path including dead-letter replays.

What HTTP status codes should a REST API return for errors?▼

Use 400 for invalid client data, 401 for unauthenticated, 403 for unauthorized, 404 for missing resources, 409 for conflicts, 422 for semantic validation failures, and 500 for server errors. Pair every status with one consistent structured error body containing a machine-readable code and human-readable message.

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 throughout the codebase.

Should I use PUT or PATCH 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 and risks overwriting fields the client did not intend to modify.

When should I version my API instead of extending it?▼

Prefer the One-Version Rule: extend interfaces additively rather than forking versions, since multiple versions multiply maintenance cost and create diamond dependency problems. Version only when a truly breaking change is unavoidable.