api-and-interface-design

Designs contract-first Kotlin APIs, DTOs, and domain models for Android applications.

Updated Jun 13, 2026
One-click install
npx skills add https://github.com/22Teikk/22Teikk-Agent-Skills-Hub --skill api-and-interface-design-22teikk
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/22Teikk/22Teikk-Agent-Skills-Hub/tree/main/core/skills/api-and-interface-design
Command: npx skills add https://github.com/22Teikk/22Teikk-Agent-Skills-Hub --skill api-and-interface-design-22teikk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Android codebases often leak Retrofit and Room annotations into domain logic, pass raw strings as identifiers, and break backward compatibility when APIs evolve. This Skill guides the design of type-safe, contract-first interfaces and data models that are hard to misuse and safe to extend. ## Core Features & Use Cases - Contract-First API Design: Define Retrofit interfaces before implementation, with consistent HTTP error semantics mapped to structured error classes. - Type-Safe Modeling: Use sealed interfaces for state variants, value classes for IDs like TaskId and UserId, and separate DTOs from domain models. - Boundary Validation: Validate user input in ViewModels and API responses in repositories before mapping to domain entities. - Use Case: When adding a new tasks feature, define the Retrofit TaskApi contract first, create TaskDto and Task domain models separately, and model TaskStatus as a sealed interface so the compiler enforces exhaustive state handling. ## Quick Start Ask the agent to design the Retrofit interface, DTOs, and domain models for a new tasks feature following the api-and-interface-design skill.

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 Retrofit API interface in Kotlin?▼

Define the Retrofit interface before implementing it, declaring suspend functions with annotations like @POST, @GET, and @PATCH for each endpoint. Use structured request bodies and typed response models rather than raw JSON strings.

How to separate DTOs from domain models in Android?▼

Keep DTOs with serialization annotations like @Serializable and @SerialName in the data layer, and map them to plain domain models used by UI and business logic. This prevents Retrofit or Room annotations from leaking into domain packages.

Should I use sealed classes or enums for UI state in Kotlin?▼

Use sealed interfaces when states carry different associated data, such as InProgress with an assignee or Completed with a timestamp. Sealed types give compile-time exhaustive when checks and smart casting, unlike enums or boolean flags.

How do I keep API changes backward compatible in Kotlin?▼

Prefer addition over modification by adding new fields as optional parameters with default values in data classes. Existing parsers and callers continue to work while new consumers can use the added fields.

Why use value classes for IDs instead of String in Kotlin?▼

Value classes like @JvmInline value class TaskId prevent accidentally passing a UserId where a TaskId is expected, catching mix-ups at compile time. They add type safety with no runtime allocation overhead.

When should input validation happen in an Android app?▼

Validate user input at system boundaries, such as in the ViewModel before calling repositories, and validate API responses inside the repository before mapping to domain models. Internal code can then assume data is already safe.