agentleFS
pecigonzalopecigonzalo/agent-skills/skills/standards-api-design/SKILL.md

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.

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
  1. Distinctive:

    Identifiers: Use stable identifiers. Do not expose auto-increment primary keys or internal storage paths unless you intend them to be part …

    line 44
  2. Very specific:

    Field design: Prefer explicit typed fields over overloaded strings or untyped blobs.

    line 46
  3. Distinctive:

    Precision-sensitive types: Treat timestamps, time zones, money, and decimal precision as contract decisions, not implementation details.

    line 48
  4. Distinctive:

    Keep every list endpoint bounded.

    line 58
  5. Distinctive:

    Prefer cursor-based pagination when the underlying data changes while clients page through it.

    line 62
  6. Distinctive:

    Document what happens when a cursor expires or becomes invalid.

    line 63
  7. Distinctive:

    Document which status codes are safe to retry and which are not.

    line 73
  8. Distinctive:

    Before shipping a breaking change, decide the versioning mechanism, the deprecation window, how consumers will be notified, and how you …

    line 86
  9. Distinctive:

    Before finalizing API work:

    line 105

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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:

DecisionQuestion to answer
AudienceInternal, partner, public, or SDK-only?
BoundaryWhat does this API own, and what must it never expose?
Authn/authzCaller identity, permissions, tenancy, and audit needs
ShapeRequest and response schemas, IDs, timestamps, nullability, enums
Failure modelValidation, auth, conflict, rate limit, and server errors
CompatibilityVersioning, deprecation, rollout, and migration plan
OperationsRate 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-security for authentication, tenancy, secrets, and PII handling.
  • Load standards-database when the API shape depends on persistence or migrations.
  • Load standards-testing for contract, integration, and compatibility tests.
  • Load standards-documentation for public or partner API documentation.
  • Load role-product-engineer when the contract is still being scoped.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.