Design an API contract
Designs an API contract before implementation, with operations, schemas, errors, pagination, idempotency and evolution rules. Use when adding an API that other teams or clients will call.
An API contract is a promise that outlives its first implementation: once clients depend on it, every field name, error shape and default is expensive to change. Designing the contract first, from the consumers' point of view, catches the expensive mistakes while they are still cheap to fix.
Design the API contract for: Only if [CONSUMERS] is given: Consumers and their constraints: Only if [CONVENTIONS] is given: Existing conventions to follow exactly: Style: . If it is auto, choose REST, GraphQL or gRPC and justify the choice in one sentence based on the consumers.
- Restate the capability as the operations consumers need, phrased from their side ("list my open orders", not "query the orders table").
- Model the resources (or types, or services) and the operations on them. Keep names consistent, plural for collections, and free of internal storage details.
- Define every request and response schema: field names, types, required or optional, formats and constraints (length, range, enum values). Use opaque string ids, RFC 3339 UTC timestamps, and money as an integer amount in minor units plus an ISO 4217 currency code, unless the conventions say otherwise.
- Define the error model: one consistent shape (for HTTP, RFC 9457 problem details unless the conventions differ), the status or error codes each operation can return, and which errors are safe to retry.
- Add the cross-cutting behaviour that applies: pagination for lists (cursor-based by default), filtering and sorting, idempotency keys for operations that create or charge, optimistic concurrency (ETag and If-Match, or a version field) for updates, authentication and authorization scopes per operation, and rate limits.
- Write the evolution rules: what counts as a compatible change, how breaking changes are versioned, and how fields are deprecated.
- Design the contract only. No server implementation code.
- Do not invent business rules (limits, states, permissions, pricing). When the contract needs one that was not given, choose a placeholder, mark it as an assumption and list it under Assumptions and open questions.
- Follow the given conventions over these defaults whenever they conflict.
- Include one realistic request and response example for each main operation.
- Prefer fewer, well-shaped operations over one endpoint per screen.
- Separate what you verified from what you inferred. Mark inferences as such.
- When you do not know, say "I don't know" once and state what would settle it.
Summary
Style chosen and why, the resources, and the main design choices, in at most 6 lines.
Operations
Table: operation, method and path (or query, mutation or RPC name), purpose, auth scope, idempotent (yes or no).
Contract
One fenced block with the machine-readable contract: OpenAPI 3.1 YAML for REST, SDL for GraphQL, proto3 for gRPC. Include the examples.
Errors
Table: code, when it happens, retryable (yes or no).
Evolution and compatibility
Bullets.
Assumptions and open questions
Numbered. Each assumption says what it affects.
1 required value still a placeholder; the assistant will ask for it.
details
- kind
- Prompt: a task you run by name to get one finished thing back
- domain
- Software engineering
- category
- Architecture
- level
- Intermediate
- made for
- Backend engineer, Software architect, Full-stack engineer, Tech lead / staff engineer
- risk
- read-only
- version
- v1.0.0 · experimental
- reviewed
- 2026-10-02
- works in
- Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md, ChatGPT, claude.ai
use in
npx @hermes-hq/hodios install design-api-contract --target claude-codenpx skills add hermes-hq/hodios-dist --skill design-api-contract -a claude-codeclaude plugin marketplace add hermes-hq/hodios-distclaude plugin install hodios-software-engineering@hodiosThe plugin brings every entry in this domain at once.
pairs well with
All of ArchitectureSoftware architect
Acts as a pragmatic software architect who designs from requirements and constraints, names trade-offs and failure modes, and keeps designs as simple as the problem allows.
software-architectWrite an architecture decision record
Writes an architecture decision record that states one decision, the forces behind it, the options weighed and the honest consequences. Use when a significant technical choice is made or proposed.
write-adrCompare design options
Compares two to four technical options against the criteria that matter, weighs reversibility and risk, and recommends one. Use when a team is stuck choosing between approaches or tools.
compare-design-optionsReview a system design
Reviews a design document or proposal for failure modes, scaling limits, data and consistency risks and operability gaps, and returns ranked findings. Use before a design review or before building.
review-system-designWrite an engineering design doc
Writes an engineering design doc or RFC with context, goals and non-goals, options and trade-offs, the decision, risks and a rollout plan. Use before building a change that needs review or buy-in.
write-design-docAPI design track
Takes a new API from consumer needs to a resource model, a reviewed contract, error and versioning rules, and a mock with contract tests, pausing for approval between steps.
api-design-track