agentleFS
kapadiaskapadias/nonna/.claude/skills/api-design/SKILL.md

api-design

Skill0 starsChanged 2 months agoMITView on GitHub

Designing or changing an interface — library API, service endpoint, or module boundary. Contracts, input validation, idempotency, versioning, public surface.

125 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use data-modeling, ci-pipeline and 9 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.
  • mmondoraSkill

    data-modeling

    Schema design, multi-tenant data isolation, and migration management. Firestore and PostgreSQL patterns, RLS, UUID v7 conventions. Use when designing database schemas, writing migrations, or implementing multi-tenant data access.

    Also in 7 projects that use this

  • vndeeSkill

    ci-pipeline

    Use when creating or updating CI/CD pipelines with GitHub Actions or GitLab CI for Go, Python, or React projects

    Also in 4 projects that use this

  • pluginagentmarketplaceSkill

    microservices

    Microservices architecture patterns and best practices. Service decomposition, inter-service communication, and distributed data management.

    Also in 4 projects that use this

  • kevinaimonsterSkill

    typescript-strict

    TypeScript strict mode and advanced type system assistant. Helps write strictly-typed TypeScript code with generics, type guards, utility types, conditional types, mapped types, and template literal types. Trigger when user says 'TypeScript types' 'type gymnastics' 'TypeScript generics' 'strict TypeScript' 'type guard' 'TS类型' 'TypeScript严格模式' '类型体操' '泛型怎么写' 'TS type help'. Keywords: TypeScript, strict mode, generics, type guard, utility types, conditional types, mapped types, template literal types, infer, extends, keyof, typeof, type narrowing, discriminated unions, type assertion, type predicate, type gymnastics, TS, 类型体操, 泛型, 类型守卫, 严格类型

    Also in 4 projects that use this

  • InfopibeSkill

    deployment-patterns

    Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.

    Also in 10 projects that use this

  • DatabricksSkill

    load-testing

    Load test a Databricks App to find its maximum QPS. Use when: (1) User says 'load test', 'benchmark', 'QPS', 'throughput', or 'performance test', (2) User wants to find how many queries per second their app can handle, (3) User wants to set up load testing scripts for their agent, (4) User wants to view load test results/dashboard, (5) User wants to validate results or observe latency/error rate with MLflow tracing.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 104 edited versions we read keep these.

  • 2

    Distinctive

    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. Very specific:

    Make illegal states unrepresentable: Prefer a closed set (enum/union) over a free string.

    line 18
  2. Distinctive:

    Minimize surface area: Every public symbol is a forever-promise.

    line 20
  3. Distinctive:

    Write the contract test against the boundary, then implement behind it — the implementation is replaceable.

    line 80

“Common” is measured: kept by at least 6 in 10 of the 104 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

An API is a contract and a promise of stability. Design the boundary so callers fall into the pit of success — and so illegal states are unrepresentable rather than merely discouraged.

Contracts: types in, types out, errors in between

The contract is the whole signature: the accepted input types, the returned type, and the errors the caller must handle. Errors are part of the contract, not an afterthought — enumerate them.

  • Types carry intent. Money(currency, minor_units) beats a bare float; UserId beats a str. The type system rejects whole classes of misuse for free.
  • Make illegal states unrepresentable. Prefer a closed set (enum/union) over a free string; prefer a type that can't hold a bad combination over runtime validation of one that can.
  • Minimize surface area. Every public symbol is a forever-promise. Expose the smallest set that serves the use case; keep the rest internal. You can add later; you can't quietly remove.

Validate untrusted input at the edge

Everything from outside — request bodies, query params, file contents, another service — is hostile until checked. Validate at the boundary, convert to a trusted internal type, and let the core assume validity. Reject out-of-range; never clamp-and-proceed silently. (.claude/rules/boundaries.md)

# edge: parse-and-validate into a trusted type, or reject
def create_order(raw):
    qty = require_int(raw["qty"], min=1, max=10_000)     # reject, don't clamp
    sku = require_known_sku(raw["sku"])
    return place(Order(sku=sku, qty=qty))                # core trusts the type

Errors: typed, meaningful, never swallowed

Return errors that tell the caller what to do: distinguish invalid input (caller's fault, don't retry) from transient failure (retry with backoff) from conflict (re-read and reconcile). Use typed errors or a result type — never a bare boolean or a null that erases the reason. Never swallow an error to keep a signature clean; an unhandled failure that vanishes is the worst outcome.

Idempotency and retry safety for mutations

Networks retry. A mutation that runs twice must not act twice.

  • Stable idempotency keys. The caller supplies a key; the server records it and returns the original result on replay. Same key + same request → one effect. (.claude/rules/safety.md)
  • Reads are safe; writes are guarded. Design GET-shaped operations to be side-effect-free so retries are free. For writes, define what a duplicate means before shipping.

Consistency, least surprise, and bounded collections

Like things look alike: consistent naming, argument order, pagination shape, and error format across the whole surface. Name for intent — cancel_order, not set_status; expires_at, not flag. Any endpoint returning a list must bound its output — there is no "return all." Page with a stable cursor (not a fragile offset), cap page size with a server-side maximum, and document the default.

Versioning — additive is safe, breaking needs a version

Additive changes are safe (new optional field, new endpoint); breaking changes need a new version (removing/renaming a field, tightening a type, changing semantics). Default new fields so old clients keep working; deprecate with a window and a migration path — never yank. Full policy — version schemes, the deprecation sequence, sunset headers, and compatibility gates — in references/versioning-and-deprecation.md.

Design the contract first, then test it, then implement

# bad: ambiguous in, lossy out, unbounded, untyped error
def transfer(a, b, amt) -> bool         # which way? what currency? false = ?

# good: intent in the types, errors enumerated, idempotent, bounded
def transfer(
    src: AccountId, dst: AccountId, amount: Money, idempotency_key: str,
) -> Result[Receipt, TransferError]     # InsufficientFunds | AccountFrozen | Duplicate

Write the contract test against the boundary, then implement behind it — the implementation is replaceable; the contract is not. Copy-ready starting points in templates/: contract.test.ts (a request/response contract test asserting validate-at-edge, typed errors, and idempotent retry) and openapi-contract.stub.yaml (an endpoint schema with typed money, enumerated errors, a required idempotency key, and capped pagination).

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.