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

api-design

Skill1 starsChanged 46 days agoMITView on GitHub

Language-agnostic framework for designing, evaluating, and standardizing HTTP APIs (REST and GraphQL). Triggers whenever an agent is asked to "design an API", "add an endpoint", "review this API contract", "how should I version this?", "REST vs GraphQL", "design pagination", or when selecting HTTP status codes. Enforces clean noun-based REST routing, strict HTTP method semantics, RFC 9457 error contracts, cursor/offset pagination, rate limiting, and spec-first OpenAPI documentation.

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

5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 165 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use exact status codes (see references/status-codes.md):

    line 67
  2. Distinctive:

    Every error response must return a machine-readable code, human title, and field-level invalid parameters.

    line 77
  3. Very specific:

    Add Sunset: <date> and Deprecation: true HTTP headers to deprecated endpoints.

    line 93
  4. Distinctive:

    Every collection endpoint must enforce a default limit (e.g.

    line 101
  5. Very specific:

    Every endpoint specification must state its authorization tier: Public, AuthenticatedUser, or Role(Admin).

    line 114

“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 & Contract Standards

A language-agnostic operational standard for designing, reviewing, and versioning HTTP APIs (REST-first, with GraphQL guidance).

Sibling Standards:

  • For input validation and injection prevention at the controller layer, see universal-coding-standards.
  • For vetting third-party routing or gateway packages, see package-security-vetting.

1. Resource & URL Architecture (REST)

  • 1.1 Nouns, Not Verbs in Paths:
    • ✅ /orders, /users/42/invoices, /subscriptions
    • ❌ /getOrders, /createUser, /api/update_order
  • 1.2 Plural Resource Names: Always use plural nouns for collections (/products, /customers).
  • 1.3 Consistent URL Casing: Use kebab-case for multi-word path segments (/payment-methods, /shipping-addresses).
  • 1.4 Shallow Nesting ($\le 2$ Levels):
    • Nest resources only when a strict parent-child ownership exists:
      • ✅ /organizations/{org_id}/members
      • ✅ /orders/{order_id}/items
    • Avoid deep nesting:
      • ❌ /authors/12/books/4/chapters/8/paragraphs/2
      • ✅ Top-level resource by ID: /chapters/8/paragraphs
  • 1.5 Strict HTTP Method Semantics:
    • GET: Safe, idempotent, no side effects, returns resource. Never mutates state.
    • POST: Creates a child resource or executes a non-idempotent operation.
    • PUT: Full replacement of resource representation; idempotent.
    • PATCH: Partial update of specific fields; non-idempotent or idempotent.
    • DELETE: Deletes the resource; idempotent (subsequent calls return 204 or 404).

2. Request & Response Contracts

  • 2.1 Consistent Envelope Architecture:
    • Choose one style across the entire API and never mix:
      • No Envelope (Clean REST standard): Return raw entity or array: { "id": "...", "name": "..." }.
      • Enveloped: { "data": { ... }, "meta": { ... } }.
  • 2.2 Uniform Field Casing:
    • Strictly enforce one JSON casing style across all endpoints (camelCase or snake_case). Never return user_id on one endpoint and userId on another.
  • 2.3 Stable Invariant Types:
    • A field must never change type based on state (e.g. returning null vs "" vs 0, or returning a string sometimes and an integer other times).
    • Explicit ISO-8601 strings for timestamps: "2026-09-28T02:30:00Z".

3. Error Handling & Status Codes

  • 3.1 Accurate HTTP Status Codes:
    • 🚫 Never return HTTP 200 OK with an error payload!
    • Use exact status codes (see references/status-codes.md):
      • 400 Bad Request: Malformed JSON or unparseable syntax.
      • 401 Unauthorized: Unauthenticated (missing/expired token).
      • 403 Forbidden: Authenticated, but lacks required role or permission.
      • 404 Not Found: Target resource does not exist.
      • 409 Conflict: Unique constraint violation or state collision.
      • 422 Unprocessable Content: Valid syntax, but business validation failed.
      • 429 Too Many Requests: Rate limit exceeded (include Retry-After).
      • 500 Internal Server Error: Unhandled server-side fault.
  • 3.2 Standardized Error Body (RFC 9457 Problem Details):
    • Every error response must return a machine-readable code, human title, and field-level invalid parameters.
  • 3.3 Zero Internal Leakage:
    • Strip stack traces, raw SQL queries, internal database table names, and server hostnames from error payloads.

4. Versioning Strategy

  • 4.1 Explicit Versioning Scheme:
    • Select and document the versioning mechanism before launching v1:
      • URI Path (Most common & debuggable): /v1/invoices
      • Header-based: X-API-Version: 2026-09-28 or Accept: application/vnd.company.v1+json
  • 4.2 Additive Changes Do Not Require Version Bumps:
    • Adding a new endpoint, optional query parameter, or new response field is backwards-compatible.
    • Breaking changes (removing a field, renaming a field, changing a type, altering required headers) require a new version.
  • 4.3 Graceful Deprecation:
    • Add Sunset: <date> and Deprecation: true HTTP headers to deprecated endpoints.
    • Support previous versions for a published deprecation window before terminating.

5. Pagination, Filtering & Sorting

  • 5.1 Never Allow Unbounded Queries:
    • Every collection endpoint must enforce a default limit (e.g. 20) and a maximum hard ceiling (e.g. 100).
  • 5.2 Choose the Right Pagination Mechanism:
    • Offset/Limit (?limit=20&offset=40): Simple, permits jumping to page N. Slower on deep tables and susceptible to phantom row skips under live writes.
    • Cursor-Based (?limit=20&starting_after=order_123): High-performance on large datasets, stable against insertions/deletions, recommended for real-time feeds.
  • 5.3 Consistent Filter & Sort Syntax:
    • Sorting: ?sort=-created_at,status (minus prefix for descending).
    • Filtering: ?status=pending&customer_id=42.

6. Security, Rate Limiting & Auth

  • 6.1 Explicit Auth Scopes:
    • Every endpoint specification must state its authorization tier: Public, AuthenticatedUser, or Role(Admin).
  • 6.2 Rate Limiting:
    • Protect all public and compute-heavy endpoints. Return 429 Too Many Requests with a Retry-After: 60 header.
  • 6.3 Boundary Input Validation:
    • Validate and sanitize all query parameters, route IDs, and request JSON bodies before invoking service logic.

7. Spec-First Documentation

  • Contract Before Code: Author the OpenAPI 3.1 specification or GraphQL schema alongside implementation.
  • Complete Endpoint Schema: Every endpoint definition must include:
    1. Purpose & summary description.
    2. Authentication requirement / OAuth scopes.
    3. JSON request payload schema with required fields.
    4. Response schemas for 2xx success and 4xx/5xx failure modes.
    5. One copy-pasteable cURL or JSON request/response example.

Detailed References

  • references/status-codes.md: Full status code semantics, RFC 9457 Problem Details JSON format, and common anti-patterns (such as HTTP 200 with error bodies).
  • references/graphql-notes.md: GraphQL schema-first patterns, nullability discipline, DataLoaders for N+1 prevention, query depth/complexity security limits, and REST vs GraphQL decision matrix.

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.