# api and interface design

> Design stable, predictable APIs and module boundaries using contract-first principles and robust idempotency patterns.

api and interface design is a free AI agent skill on Agensi by 郭睿桓（Richard）, in APIs & Backend. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [郭睿桓（Richard）](https://www.agensi.io/creators/richard-3)
- Category: [APIs & Backend](https://www.agensi.io/skills/apis-backend)
- Uses: 2
- Version: 1.0
- Last updated: 2026-10-18
- Security: scan passed (2026-10-18); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/api-and-interface-design
- Tags: api, typescript, rest-api, graphql, backend-development

## About this skill

Interfaces are the most expensive things to change once they are live. This skill helps you design stable, predictable APIs and module boundaries that resist breaking changes and prevent misuse. It provides concrete patterns for REST, GraphQL, and TypeScript interfaces, grounded in principles like Hyrum's Law and the One-Version Rule.

### What it does
- **Enforces contract-first design** by requiring interface definitions before implementation to prevent tight coupling.
- **Standardizes error semantics** using structured machine-readable codes and consistent HTTP status mapping.
- **Secures system boundaries** by implementing validation at the edges (API routes, forms, and third-party responses) while trusting internal types.
- **Hardens state-changing operations** with rigorous idempotency patterns, including atomic key claims and payload guarding to prevent race conditions.
- **Optimizes resource design** through specific conventions for RESTful naming, pagination, and partial updates using PATCH.

### How it works
1. **Define the contract** by drafting TypeScript interfaces or API schemas for inputs and outputs.
2. **Apply design principles** such as Hyrum's Law to ensure implementation details do not leak into the public surface.
3. **Audit against red flags** like verbs in URLs, inconsistent error shapes, or non-atomic idempotency checks.

### Frameworks & tools
TypeScript, REST, GraphQL, and Zod-style schema validation. Applicable to any backend or frontend stack where code modules interact.

### Why this beats prompting it yourself
Generic prompts often ignore the nuance of Hyrum's Law or provide flawed idempotency logic that fails under race conditions. This skill provides production-grade patterns that specifically solve the diamond dependency problem and correlated retry storms.

### Use cases
- Drafting a new microservice API that needs to support multiple frontend consumers.
- Refactoring a legacy module boundary to improve type safety and developer experience.
- Implementing safe payment or transaction processing using robust idempotency keys.
- Designing a public-facing SDK where backward compatibility is a hard requirement.

### Known limitations
Does not provide implementation code for specific database drivers or web frameworks. Focuses on the interface layer and logic patterns rather than infrastructure setup.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the api and interface design skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How does this skill differ from simply asking an AI to 'design an API'?

This skill focuses on the architectural 'contract' layer, providing production-grade patterns for idempotency, error handling, and resource naming that prevent breaking changes and race conditions. Unlike generic prompts, it applies specific principles like Hyrum’s Law to ensure your interfaces remain stable even as your implementation evolves.

### Is this skill limited to TypeScript projects, or can I use it for other languages?

While the skill uses TypeScript and Zod-style schemas as its primary design language, the architectural principles are language-agnostic. You can apply the resulting interface designs and idempotency logic to any backend stack, including Node.js, Go, Python, or Java.

### Does this skill help with implementing safe distributed transactions or payments?

The skill provides robust, atomic idempotency patterns designed to handle concurrent requests and retry storms safely. It guides you through implementing payload guarding and unique key claims to ensure that state-changing operations, like payments, are never executed twice.

### What exactly is included in the purchase of this skill?

You receive a specialized set of design protocols, schema templates for REST and GraphQL, and an auditing framework to check for common interface 'red flags.' It includes specific strategies for versioning and backward compatibility to help you avoid the 'diamond dependency' problem.

### Will this skill generate the full implementation code for my database and server?

This skill is a design and architecture tool rather than a code generator for infrastructure. It provides the logic, structure, and validation patterns for your API, but you will still need to connect these designs to your specific database drivers or web framework of choice.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
