agentleFS
mattstrublemattstruble/skills/api-design/SKILL.md

api-design

Skill2 starsChanged 4 months agoMITView on GitHub

You MUST consult this skill when designing or reviewing any API — REST, gRPC, or OpenAPI specs. Also trigger on resource modeling, field naming, pagination, error handling, versioning, custom vs standard methods, or reviewing an existing API for consistency problems — even if the user doesn't mention AEP. NOT for implementation details (framework setup, middleware config) or general software design (see software-design).

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

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 165 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Prefer standard > batch > custom > streaming.

    line 62

“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

AEP-Compliant API Design

Design APIs following AEP (Google, Microsoft, Roblox, IBM). The payoff: Terraform providers, CLIs, UIs, and MCP servers auto-generate because they can predict the API shape from resource hierarchies.

Core principle: design resource hierarchies (nouns), not procedure collections (verbs).


Designing around caller intent

Design the API surface around what callers actually want, expressed in their vocabulary — not around how the implementation is structured internally. A networking API should expose connect, read_message, write_message, and disconnect. Exposing a "socket" instead leaks a Unix implementation concept that bundles unrelated concerns (files, network, device I/O) into a single abstraction callers never asked for. The right question is: what does the caller need to accomplish, and what are the fewest, most coherent calls that let them do it?

No footgun-by-omission. Nothing should fail silently because the caller forgot to set an obscure flag or initialize an optional field. Mandatory low-level knobs are a design smell; sensible, safe behavior should be the default, with explicit opt-in for deviation.

Separate the escape hatch. Provide raw or low-level bindings as a distinct layer for the rare callers who genuinely need them. The common-case API should not force everyone through low-level machinery. (See software-design's "layered interfaces" for the structural pattern.)

Difficulty is not a virtue. Jonathan Blow argues — with OpenGL and Vulkan as examples — that keeping a hard API because you feel pride in having mastered it is not a design principle; it is a cost imposed on every future caller. Complexity is only justified when it is essential to the problem domain, which is rare.


Design Process

For every API, answer these four questions in order:

  1. What are the resources (things)?
  2. What's the parent-child hierarchy?
  3. What does each resource's schema look like?
  4. Which standard methods does each resource need?

Before (verb-oriented — hard to auto-generate clients):

POST /v1/createProject
POST /v1/archiveProject
POST /v1/getProjectTasks

After (resource-oriented — predictable, tooling-friendly):

POST   /v1/projects                       # Create
GET    /v1/projects/{project_id}          # Get
GET    /v1/projects                       # List
PATCH  /v1/projects/{project_id}          # Update
DELETE /v1/projects/{project_id}          # Delete
POST   /v1/projects/{project_id}:archive  # Custom method (state transition)
GET    /v1/projects/{project_id}/tasks    # Nested collection

Model a resource hierarchy, not a database schema — the API is a contract, not a DB mirror. Resource relationships must form a DAG (no cycles).


Standard Methods (AEP-130–135)

Prefer standard > batch > custom > streaming. Each step down costs tooling compatibility.

MethodVerb + PathKey Rules
GetGET /v1/{path}Every resource needs Get so clients can verify mutations
ListGET /v1/{parent}/collectionResponse array is results, not the type name. Paginate from day one
CreatePOST /v1/{parent}/collection?id=XID is a query param, not body. Support user-specified IDs by default
UpdatePATCH /v1/{path}Merge-patch semantics (application/merge-patch+json). Never PUT
DeleteDELETE /v1/{path}Require force: bool when first-class children exist
CustomPOST /v1/{path}:verbState transitions that can't be expressed as field updates

OperationId naming: {Verb}{Singular} for standard (GetBook, CreateBook), List{Plural} for List (ListBooks).


Conventions That Diverge From Common Practice

These AEP rules are the ones most likely to be missed. Each exists for a specific reason:

  • results array in List responses — not books or users. A consistent name lets generic clients parse any collection without knowing the resource type.
  • id as query param on Create — POST /v1/tasks?id=my-task. Keeps the body a clean resource representation. Without user-specified IDs, Create isn't safely retryable and declarative clients (Terraform) can't reconcile state.
  • PATCH + merge-patch, never PUT — PUT requires the full resource, so adding a new schema field silently becomes breaking (old clients reset it to zero value on every update).
  • _time suffix on timestamps — create_time, update_time. Never _at, never camelCase. This makes timestamps recognizable across all AEP APIs.
  • Permissions before existence — always check auth first (-> 403), then existence (-> 404). Reversing this leaks which resources exist to unauthorized callers.
  • RFC 9457 errors — Content-Type: application/problem+json with type, status, title, detail. Dynamic variables in detail must also appear as top-level fields for programmatic access.
  • State transitions via custom methods — :archive, :publish, not PATCH on a state field. State machines need server-side validation that Update can't express.
  • Duplicate Create ID -> 409 ALREADY_EXISTS, unless caller can't see the duplicate -> 403 (avoids leaking existence info).

Review Checklist

  • Resources use nouns, not verbs; hierarchy forms a DAG
  • List response array is results
  • Create supports user-specified id as query param
  • Update uses PATCH + merge-patch, not PUT
  • Timestamps use _time suffix, RFC 3339 format
  • Pagination on all List methods from day one
  • Permissions checked before existence
  • Errors use application/problem+json (RFC 9457)
  • State transitions use custom methods, not Update
  • Delete with children requires force: bool
  • create_time, update_time, etag on mutable resources
  • path field is output-only on every resource
  • Long-running operations (LROs) return 202 Accepted with Operation resource
  • Does the surface expose caller intent, or leak an internal implementation concept?
  • When the API accepts raw input, does conversion raise on invalid data rather than silently accepting it? (parse, don't validate — see software-design/references/type-driven-design.md)
  • Does every method name accurately describe ALL of what it does, including side effects? (Least Astonishment)
  • Do consistent name patterns signal consistent behavior across the surface? (delete_* always deletes, never soft-deletes sometimes)
  • Are defaults safe? (fail closed, return empty collection not null, require explicit opt-in for dangerous behavior)

References

ReferenceWhen to read it
references/field-naming.mdDesigning paths, naming fields, or reviewing naming consistency
references/patterns.mdImplementing pagination, error responses, LROs, soft delete, state machines, idempotency, validate-only, singletons, or enumerations

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.