agentleFS
MesteriisMesteriis/Engineering-Bible-AI/skills/api-and-interface-design/SKILL.md

api-and-interface-design

Skill2 starsChanged 5 months agoMITView on GitHub

Use when designing or changing an API, RPC, CLI, endpoint, schema, public function signature or plugin contract: «спроектируй API/интерфейс», «добавь эндпоинт», «поменяй контракт», breaking changes, versioning, pagination, retries, error format. Not for internal module seams (architecture-principles).

92 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use observability-and-instrumentation, accessibility-engineering 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.
  • jaydubya818Skill

    observability-and-instrumentation

    Add or review logs, metrics, traces, and actionable alerts.

    Also in 50 projects that use this

  • steven123397Skill

    accessibility-engineering

    Audits existing interfaces for WCAG 2.2 AA conformance and remediates the violations found. Use when auditing a page or component for accessibility, running axe-core or pa11y, triaging a11y violations, or checking screen reader and contrast issues before shipping.

    Also in 4 projects that use this

  • MrCipherSmithSkill

    constraint-driven-development

    Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.

    Also in 22 projects that use this

  • seikaikyoSkill

    doubt-driven-development

    對非平凡決策啟動新鮮 context 對抗審查(找碴不背書),在修正還便宜的時候抓出錯誤方向。適用:高風險改動(production、資安敏感邏輯、不可逆操作)、不熟的程式碼、要宣稱「這樣是安全的 / 可行的」之前。機械性操作與一行修改不適用。

    Also in 59 projects that use this

  • jaydubya818Skill

    deprecation-and-migration

    Retire APIs or migrate consumers and persistent data across releases.

    Also in 47 projects that use this

  • HK-hubSkill

    code-simplification

    Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

    Also in 65 projects that use this

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 10 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 87 edited versions we read keep these.

  • 10

    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:

    Treat every observable behaviour of a published interface as a commitment.

    line 17
  2. Distinctive:

    Prefer one live version of a thing: extend rather than fork.

    line 19
  3. Distinctive:

    Write the contract (types, schema, signatures, documented errors) before the implementation, and commit it with the code.

    line 23
  4. Distinctive:

    Keep input shapes separate from output shapes.

    line 26
  5. Distinctive:

    Do not mix throwing, returning null and returning an error object for the same kind of failure.

    line 37
  6. Distinctive:

    Treat third-party responses as untrusted data: check shape and content before use.

    line 44
  7. Distinctive:

    Prefer additive change: new optional fields, new operations, new enum values that old clients can ignore or default.

    line 51
  8. Distinctive:

    Do not remove or rename fields, change types, tighten validation or change defaults in place.

    line 53
  9. Distinctive:

    Check consumers (search the repo, clients, docs) before declaring a change safe.

    line 57
  10. Distinctive:

    Keep keys longer than the longest retry or replay path.

    line 71

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

Skill: api-and-interface-design

Design interfaces that are stable, documented and hard to misuse. Applies to HTTP/RPC APIs, CLIs, schemas, public library functions and plugin contracts.

Hyrum's law

With enough users, every observable behaviour becomes depended on, whatever the contract says: error text, ordering, timing, undocumented quirks.

  • Be deliberate about what is exposed; do not leak implementation details.
  • Treat every observable behaviour of a published interface as a commitment.
  • Plan deprecation at design time; tests alone do not catch undocumented use.
  • Prefer one live version of a thing: extend rather than fork.

Contract first

Write the contract (types, schema, signatures, documented errors) before the implementation, and commit it with the code. For each operation state inputs, outputs, server-generated fields, error cases and whether it is safe to retry. Keep input shapes separate from output shapes. Model variants as explicit tagged unions, not flags and nullable fields.

Error model

Pick one error strategy and use it everywhere.

  • One structured shape: machine-readable code, human message, optional details. Clients branch on code, never on message text.
  • Map causes consistently: invalid input, unauthenticated, forbidden, not found, conflict, unprocessable, internal. Never expose internals in server errors.
  • Do not mix throwing, returning null and returning an error object for the same kind of failure.

Validate at the edge

  • Validate where external input enters: request handlers, CLI arguments, config and environment loading, parsing of third-party responses.
  • Treat third-party responses as untrusted data: check shape and content before use.
  • Inside the trusted core rely on types; do not scatter re-validation through internal functions or over data read from your own store.

Backwards compatibility

  • Prefer additive change: new optional fields, new operations, new enum values that old clients can ignore or default.
  • Do not remove or rename fields, change types, tighten validation or change defaults in place; that is a breaking change.
  • Breaking change: introduce a new version or name, run both with a documented deprecation window, and say who is affected. Do not keep many versions alive.
  • Check consumers (search the repo, clients, docs) before declaring a change safe.

Idempotency and retries

  • Mark each state-changing operation as idempotent or document it unsafe to retry. Deletes and PUT-style replaces should be idempotent.
  • Derive an idempotency key from the intent (stable across retries, different across intents), supplied by the client or initiating event; never a fresh random value or timestamp per attempt.
  • Claim the key atomically (unique constraint), not check-then-act. Reusing a key with a different payload must fail loudly. Decide what an in-flight duplicate gets: reject (conflict), wait with a bound, or return pending plus a status location.
  • A timeout means outcome unknown, not failure. Record intent before the call.
  • Keep keys longer than the longest retry or replay path.

Pagination and limits

  • Paginate every list operation from the start; prefer cursors for changing data.
  • Enforce and document a maximum page size, a default, and a stable sort order.
  • Bound request size, filter complexity and rate; state the limits in the contract and the error returned when exceeded.
  • Support partial update (patch semantics) where full replacement forces clients to send data they do not own.

Naming

  • One convention per surface; follow what the repository already uses.
  • Resources as nouns; operations as verbs only where the style is RPC or CLI.
  • Booleans read as questions (is_, has_, can_); units and time zones are part of the name or the type; identifiers are distinct types where the language allows.
  • Same concept, same word, everywhere.

Red flags

  • Same operation returning different shapes by condition.
  • Inconsistent error formats; verbs in resource paths.
  • List operations without pagination or limits.
  • Breaking changes to existing fields without a version or deprecation path.
  • Idempotency key read then written in separate steps.
  • Third-party data used without validation.

Verification

  • Every operation has typed input and output and documented errors.
  • One error format; validation only at the edge.
  • Lists paginated with documented limits.
  • New fields additive; breaking changes versioned and announced.
  • State-changing operations idempotent or documented unsafe to retry.
  • Contract committed with the implementation; consumers checked.

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.