standards-api-design
Skill0 starsChanged 4 months agoMITView on GitHub
Use this skill when designing or reviewing APIs, including REST, GraphQL, RPC, webhooks, SDK interfaces, and public contracts, and for error models, pagination, idempotency, versioning, and backward compatibility decisions, even if the user only describes an endpoint. Use standards-security for the auth and input-handling implementation behind those contracts.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- mcpSkill
- pattern-orchestration-complexSkill
- pattern-task-breakdownSkill
- role-architectSkill
- role-code-reviewSkill
- role-data-engineerSkill
- role-developerSkill
- role-orchestratorSkill
- role-product-engineerSkill
- role-qa-engineerSkill
- role-security-auditorSkill
- role-site-reliability-engineerSkill
- role-technical-writerSkill
- standards-analysisSkill
- standards-codeSkill
- standards-databaseSkill
- standards-documentationSkill
- standards-go-concurrencySkill
- standards-go-performanceSkill
- standards-goSkill
- standards-go-testingSkill
- standards-markdownSkill
- standards-observabilitySkill
- standards-pulumi-typescriptSkill
- standards-pythonSkill
- standards-securitySkill
- standards-shellSkill
- standards-skill-authoringSkill
- standards-testingSkill
- standards-typescriptSkill
- tool-storeSkill
- workflow-debuggingSkill
- workflow-pi-extensionSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 8 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 44
Identifiers: Use stable identifiers. Do not expose auto-increment primary keys or internal storage paths unless you intend them to be part …
- Very specific: line 46
Field design: Prefer explicit typed fields over overloaded strings or untyped blobs.
- Distinctive: line 48
Precision-sensitive types: Treat timestamps, time zones, money, and decimal precision as contract decisions, not implementation details.
- Distinctive: line 58
Keep every list endpoint bounded.
- Distinctive: line 62
Prefer cursor-based pagination when the underlying data changes while clients page through it.
- Distinctive: line 63
Document what happens when a cursor expires or becomes invalid.
- Distinctive: line 73
Document which status codes are safe to retry and which are not.
- Distinctive: line 86
Before shipping a breaking change, decide the versioning mechanism, the deprecation window, how consumers will be notified, and how you …
- Distinctive: line 105
Before finalizing API work:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API Design Standards
Provides: Contract design decisions, error model conventions, pagination and idempotency patterns, and compatibility review criteria.
Quick Reference
Golden Rule: APIs are contracts; optimize for predictable clients
Default Stance:
- Contract first: name resources, schemas, and errors before writing code
- Be boring: use platform conventions over clever custom patterns
- Make failure explicit: stable error codes, actionable messages, retry guidance
- Evolve safely: additive changes first, breaking changes need migration paths
Never: leak storage internals, return unbounded lists, or overload one field with multiple meanings
Required Decisions
Settle these before implementation:
| Decision | Question to answer |
| Audience | Internal, partner, public, or SDK-only? |
| Boundary | What does this API own, and what must it never expose? |
| Authn/authz | Caller identity, permissions, tenancy, and audit needs |
| Shape | Request and response schemas, IDs, timestamps, nullability, enums |
| Failure model | Validation, auth, conflict, rate limit, and server errors |
| Compatibility | Versioning, deprecation, rollout, and migration plan |
| Operations | Rate limits, idempotency, pagination, observability, support |
The audience decision drives the rest. A public contract cannot be changed on your schedule; an internal one can.
Contract Guidelines
Identifiers: Use stable identifiers. Do not expose auto-increment primary keys or internal storage paths unless you intend them to be part of the contract forever.
Field design: Prefer explicit typed fields over overloaded strings or untyped blobs. A status string that callers parse for substrings is a contract you cannot change.
Precision-sensitive types: Treat timestamps, time zones, money, and decimal precision as contract decisions, not implementation details. State the format (for example RFC 3339 with an explicit offset) and the unit (for example minor currency units as an integer).
Modeling: Shape the contract around user workflows, not around database tables. A response that mirrors your schema forces clients to reimplement your joins.
Errors: Separate validation failures from business conflicts. A malformed request and a request that conflicts with current state need different codes because clients handle them differently: one is a bug to fix, the other is a state to resolve. Return enough context to debug, and never expose secrets, stack traces, or internal hostnames.
Pagination
Keep every list endpoint bounded. An endpoint that returns all rows will eventually time out on your largest customer.
- Define a default page size and a maximum page size, and enforce both.
- Define sort stability. Pagination over a non-unique sort key skips and repeats rows as data changes; add a unique tiebreaker to the sort.
- Prefer cursor-based pagination when the underlying data changes while clients page through it. Offset pagination is acceptable for stable or small datasets.
- Document what happens when a cursor expires or becomes invalid.
Idempotency and Retries
Make mutations idempotent wherever retries are likely, which is any network call a client might time out on.
- Accept a client-supplied idempotency key on unsafe operations, and return the original result when the key repeats.
- State how long an idempotency key is honored.
- Document which status codes are safe to retry and which are not.
- Include retry guidance for rate limits: how long to wait, and whether to back off.
A client that cannot tell a timeout from a failure will retry a charge twice.
Compatibility
Additive changes are safe: new optional fields, new endpoints, new enum values in responses only if clients are documented to tolerate unknown values.
Breaking changes need a path: removing or renaming a field, tightening validation, changing a type, making an optional field required, or adding an enum value that clients must handle.
Before shipping a breaking change, decide the versioning mechanism, the deprecation window, how consumers will be notified, and how you will verify nobody is still using the old shape.
Webhooks and Events
Published events are a contract with weaker delivery guarantees, so they need more metadata than a synchronous response:
- Event ID so consumers can deduplicate redelivery.
- Timestamp for event time, distinct from delivery time.
- Schema version so consumers can handle multiple shapes during a migration.
- Replay strategy: whether consumers can request historical events, and over what window.
Assume at-least-once delivery and out-of-order arrival unless you have built stronger guarantees. Consumers must be able to process the same event twice safely.
Checklist
Before finalizing API work:
- The contract matches user workflows, not database tables
- Authorization is defined per operation and per tenant boundary
- Input validation and error responses are consistent across endpoints
- Pagination, filtering, and sorting semantics are documented, with a stable sort
- Idempotency and retry behavior are stated for every mutation
- Timestamp, time zone, money, and precision formats are specified
- Breaking-change risk and the versioning path are addressed
- Error responses expose no secrets, stack traces, or internal identifiers
- Tests cover success, validation, authorization, conflict, and retry cases
See also
- Load
standards-securityfor authentication, tenancy, secrets, and PII handling. - Load
standards-databasewhen the API shape depends on persistence or migrations. - Load
standards-testingfor contract, integration, and compatibility tests. - Load
standards-documentationfor public or partner API documentation. - Load
role-product-engineerwhen the contract is still being scoped.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

