AI Agent Hub
Back to skills
API and Interface Design icon

API and Interface Design

Development Updated 2026.08.29

Paste the following prompt into your AI chat to install this skill:

Please install @user_e40a4360/api-and-interface-design according to https://skillhub.cn/install/skillhub.md.

About this skill

Problem it addresses

Once an interface is exposed, response shapes, error semantics, and undocumented behavior become de facto contracts. Common team-level failures include REST endpoints returning different structures under different conditions, unclear contracts for GraphQL, module boundaries, or component props, inconsistent choices between PATCH and PUT, and third-party responses entering business logic without validation. This skill turns those failure modes into a practical design framework.

How the skill works

It organizes interface design around the rule that the right behavior should be easy and the wrong behavior should be hard:
- Contract first: define inputs, outputs, types, and error formats before implementation.
- Consistent error semantics: avoid mixing throw, null, and { error } across endpoints.
- Boundary validation: validate API handlers, form submissions, environment variables, and third-party responses; avoid repeated validation inside trusted internal code.
- Backward-compatible extension: prefer optional additive fields, discriminated unions, branded IDs, and PATCH-friendly updates over breaking changes.
- Predictable naming and REST conventions: use GET /api/tasks, camelCase query parameters, isComplete booleans, and UPPER_SNAKE enum values.
It closes with a checklist covering typed schemas, consistent errors, pagination, PATCH support, and naming consistency.

Where it applies and cautions

This is useful for new API endpoints, cross-team contracts, component props, and database schemas that shape API behavior. It does not replace security scanning, authorization models, or distributed-system design. Treat Hyrum's Law as a design constraint: observable behavior is a commitment, so plan deprecation early.

Use Cases

  • Design new REST endpoints by defining inputs, outputs, errors, and pagination before implementation.
  • Create stable module or component prop contracts across teams instead of assuming field semantics.
  • Refactor public APIs by adding optional fields or extended types while keeping existing consumers compatible.
  • Validate third-party service responses at system boundaries before using untrusted data in business logic.

Best For

  • Backend engineers designing APIs: want consistent errors, pagination, and naming conventions.
  • Frontend engineers building components: want stable prop inputs and outputs with less misuse.
  • Architects defining cross-service contracts: want to avoid version forks and breaking changes.
  • Developers integrating third-party APIs: want to treat external responses as untrusted data to validate.