agentleFS
d-padmanabhand-padmanabhan/agent-engineering-handbook/skills/api-design/SKILL.md

api-design

Skill17 starsChanged 55 days agoMITView on GitHub

Designs and reviews production APIs across REST/HTTP, OpenAPI, GraphQL, gRPC, webhooks, asynchronous operations, batch endpoints, SSE, and WebSockets. Use when defining resources, routes, methods, status codes, problem details, pagination, idempotency, conditional writes, API schemas, compatibility, deprecation, authentication, authorization, rate limits, or protocol contracts.

191 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use db-design, everything-claude-code and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • yuexueyuSkill

    db-design

    数据库工程师技能 - Schema设计、索引优化、并发安全、数据库审计。当你涉及数据库表/字段/索引/SQL/迁移/MCP数据库操作、建表改表、写查询时必须使用此技能。即使用户只是说"加个字段"或"查下数据",也应触发。

    Also in 4 projects that use this

  • InfopibeSkill

    everything-claude-code

    Also in 9 projects that use this

  • mryeastcodeSkill

    everything-claude-code-conventions

    Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

    Also in 8 projects that use this

  • tpavanipradeepSkill

    nextjs-turbopack

    Next.js 16+ and Turbopack — incremental bundling, FS caching, dev speed, and when to use Turbopack vs webpack.

    Also in 15 projects that use this

  • Indium-AI-LabsSkill

    data-pipeline-design

    Design batch or incremental ETL and ELT pipelines and warehouse models: grain, partitioning, idempotent loads, late-arriving data, data quality tests, PII controls, and cost monitoring, before building them. Use when adding or changing a dbt model, warehouse table, scheduled transformation, or ingestion job. Not for transactional schema design (use the database-design skill) or event-sourced stores (use the event-sourcing-architecture skill).

    Also in 3 projects that use this

  • thejordanleopoldSkill

    third-party-integration

    Use when integrating with external APIs, payment processors (Stripe), webhooks, or third-party services. Use when implementing API clients with authentication and rate limiting, handling webhooks with signature verification and idempotency, writing contract tests for external services, or isolating third-party dependencies behind adapters. Triggers: \"Stripe\", \"payment integration\", \"webhook\", \"third-party API\", \"external service\", \"API client\", \"integrate with\", \"signature verification\", \"idempotency key\".

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 0 are common, 9 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 165 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Follow HTTP safety, idempotency, cache, conditional-request, and status-code semantics.

    line 19
  2. Distinctive:

    Use RFC 9457 Problem Details for new public HTTP error contracts unless an existing compatibility commitment requires another documented …

    line 26
  3. Distinctive:

    Treat the API description as a versioned contract.

    line 32
  4. Distinctive:

    Keep secrets, credentials, raw payloads, and unnecessary personal data out of errors and telemetry.

    line 36
  5. Distinctive:

    Do not start by listing endpoints.

    line 53
  6. Very specific:

    Use the networking transport skill (${HANDBOOK_ROOT}/skills/networking-transport/SKILL.md) for transport and wire format selection.

    line 71
  7. Distinctive:

    use stable, lowercase collection nouns and one multiword convention.

    line 79
  8. Distinctive:

    use opaque identifiers and avoid exposing storage topology.

    line 80
  9. Distinctive:

    use query parameters for filtering, sorting, pagination, field selection, and other optional refinement.

    line 82
  10. Very specific:

    never place state-changing behavior behind GET, HEAD, or a query action such as ?action=delete.

    line 84
  11. Distinctive:

    use an explicit command endpoint only when no honest resource lifecycle fits, then document its authorization, idempotency, result, and …

    line 86
  12. Very specific:

    Use the REST and HTTP contracts reference (${HANDBOOK_ROOT}/skills/api-design/references/rest-http-contracts.md).

    line 109
  13. Very specific:

    Use the security and resilience reference (${HANDBOOK_ROOT}/skills/api-design/references/security-resilience.md), the service resilience …

    line 130
  14. Very specific:

    Use the evolution and OpenAPI reference (${HANDBOOK_ROOT}/skills/api-design/references/evolution-openapi.md).

    line 147
  15. Very specific:

    Use the GraphQL, gRPC, and streaming reference (${HANDBOOK_ROOT}/skills/api-design/references/graphql-grpc-streaming.md).

    line 157

“Common” is measured: kept by at least 6 in 10 of the 165 edited versions of this file we could read. “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

Mandatory API gates are owned by the API rule (${HANDBOOK_ROOT}/rules/320-api-design.mdc). This skill owns design workflow, trade-offs, examples, and protocol-specific guidance.

Non-Negotiables

  • Design from consumers, business invariants, trust boundaries, and failure behavior before choosing endpoint shapes.
  • Let resource identifiers name nouns and protocol operations express behavior. Model a business action as a subordinate resource when that produces a clear lifecycle.
  • Follow HTTP safety, idempotency, cache, conditional-request, and status-code semantics. Idempotence means the intended server effect is stable, not that every response is byte-identical.
  • Authenticate the principal and authorize every protected object, tenant, relationship, field, and action on the server.
  • Validate and bound every path, query, header, cookie, message, and body input. Serialize responses from allowlisted schemas rather than persistence objects.
  • Use RFC 9457 Problem Details for new public HTTP error contracts unless an existing compatibility commitment requires another documented shape.
  • Make retryable mutations safe with a stable operation identity, atomic state, and reconciliation. Never imply that transport delivery proves exactly-once business processing.
  • Protect mutable resources from lost updates when concurrency matters.
  • Treat the API description as a versioned contract. Detect breaking changes, provide migration evidence, and deprecate deliberately.
  • Bound payloads, pagination, batches, queries, streams, execution time, concurrency, retries, queues, and per-principal cost.
  • Keep secrets, credentials, raw payloads, and unnecessary personal data out of errors and telemetry.

Design Workflow

1. Define Consumers and Guarantees

Document:

  • consumers, trust levels, environments, and ownership;
  • critical operations and business invariants;
  • latency, availability, durability, freshness, and consistency needs;
  • authentication mechanism and authorization policy inputs;
  • expected load, object size, request size, page size, concurrency, and growth;
  • retry, duplicate, ordering, and partial-failure behavior;
  • compatibility window, support policy, and deprecation owner.

Do not start by listing endpoints.

2. Select the Interface Style

Choose the smallest interface that fits:

  • REST/HTTP for resource-oriented public or broadly interoperable APIs;
  • GraphQL for consumer-selected graphs when demand control and field authorization are enforceable;
  • gRPC for typed service-to-service contracts, streaming, and generated clients where HTTP/2 and Protobuf are operationally supported;
  • webhook delivery for provider-initiated notifications;
  • SSE for server-to-client event streams over HTTP;
  • WebSockets for bounded bidirectional sessions;
  • asynchronous operation resources for long-running work;
  • batch endpoints only when network savings justify their authorization, isolation, and partial-result complexity.

Use the networking transport skill (${HANDBOOK_ROOT}/skills/networking-transport/SKILL.md) for transport and wire format selection.

3. Model Resources and Operations

For REST/HTTP:

  • use stable, lowercase collection nouns and one multiword convention;
  • use opaque identifiers and avoid exposing storage topology;
  • nest only for true containment or scope;
  • use query parameters for filtering, sorting, pagination, field selection, and other optional refinement;
  • never place state-changing behavior behind GET, HEAD, or a query action such as ?action=delete;
  • use an explicit command endpoint only when no honest resource lifecycle fits, then document its authorization, idempotency, result, and failure semantics.

Examples of resource-modeled actions include an order cancellation resource, an export job, or a password-reset request.

4. Define the Contract

Specify:

  • method or operation semantics;
  • request media type, schema, requiredness, defaults, unknown-field policy, and size limit;
  • success status, headers, body schema, and empty-body behavior;
  • RFC 9457 problem types, safe details, field pointers, and retryability;
  • JSON naming, timestamp, identifier, decimal, money, unit, enum, null, and absent-value conventions;
  • filtering operators, sort grammar, deterministic tie-break order, duplicate parameter behavior, and maximum page size;
  • cache scope, validators, conditional reads, and conditional writes;
  • asynchronous status, polling, cancellation, result, failure, expiry, and retention behavior.

Use the REST and HTTP contracts reference (${HANDBOOK_ROOT}/skills/api-design/references/rest-http-contracts.md).

5. Design Security and Failure Behavior

Define authentication separately from authorization. Apply bounded schemas before policy or business logic, and apply output filtering after authorization.

For mutations and remote dependencies, define:

  • idempotency key ownership, request fingerprint, atomic persistence, replayed response, conflict behavior, and retention;
  • optimistic concurrency and stale-write response;
  • one end-to-end deadline, attempt timeouts, retry owner, transient failure classes, backoff, jitter, and retry budget;
  • rate-limit principal, quota unit, window, response headers, and overload behavior;
  • outbound destination and redirect policy;
  • webhook signature, timestamp, replay, durable handoff, and redelivery policy;
  • redacted audit, logs, metrics, and traces.

Use the security and resilience reference (${HANDBOOK_ROOT}/skills/api-design/references/security-resilience.md), the service resilience skill (${HANDBOOK_ROOT}/skills/service-resilience/SKILL.md), and the distributed transactions skill (${HANDBOOK_ROOT}/skills/distributed-transactions/SKILL.md).

6. Define Evolution

Choose the newest OpenAPI version supported by the repository's validated toolchain. Do not copy a version number from a handbook example without checking generator, validator, gateway, and documentation compatibility.

Classify changes across request schemas, response schemas, requiredness, defaults, enums, error types, status codes, ordering, pagination, authorization, and observable behavior. Additive syntax can still be behaviorally breaking.

Use the evolution and OpenAPI reference (${HANDBOOK_ROOT}/skills/api-design/references/evolution-openapi.md).

7. Apply Protocol-Specific Controls

GraphQL, gRPC, webhooks, SSE, WebSockets, and batch APIs retain the same identity, authorization, validation, resource, compatibility, and observability requirements. Add protocol-specific demand, flow-control, deadline, schema, and connection-lifecycle controls.

Use the GraphQL, gRPC, and streaming reference (${HANDBOOK_ROOT}/skills/api-design/references/graphql-grpc-streaming.md).

8. Verify the Contract

Run applicable:

  • schema lint and validation;
  • request and response conformance tests;
  • authorization tests for object, tenant, relationship, action, and field boundaries;
  • negative tests for unknown, malformed, oversized, duplicate, stale, replayed, and out-of-order inputs;
  • OpenAPI or Protobuf breaking-change checks;
  • consumer contract and generated-client tests;
  • retry, timeout, idempotency, concurrency, and partial-failure tests;
  • load, abuse, rate-limit, streaming, and backpressure tests;
  • documentation examples against the production contract.

Review Output

For a design or review, report:

  1. consumers, invariants, and trust boundaries;
  2. interface style and resource or operation model;
  3. request, response, error, pagination, and async contracts;
  4. authentication, authorization, validation, and abuse controls;
  5. idempotency, concurrency, retry, and partial-failure behavior;
  6. compatibility, versioning, and deprecation plan;
  7. verification, observability, and unresolved risks.

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.