agentsclimarketplace

Api design

Skill tungnt1405/tungnt-ai-skills-marketplace/skills/api-design

Use when the brainstorming skill is activated and invokes this skill; the skill is a supporting lens for brainstorming evaluation, design, and edits when working with APIsFrom its SKILL.md

Install
npx -y skills add tungnt1405/tungnt-ai-skills-marketplace --skill api-design

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

6.9 KB, as published. Nobody here has run it

API Design

Overview

Design the contract before implementation. A good API is resource-oriented, predictable, retryable, diagnosable, and stable over time; every observable behavior can become a customer dependency.

Use stricter local API standards first.

When to Use

  • Creating or changing REST/HTTP endpoints or public service contracts.
  • Defining request, response, error, pagination, filtering, sorting, or SDK-facing schemas.
  • Planning versioning, deprecation, idempotency, retries, long-running operations, or compatibility.
  • Reviewing an API for breaking changes or inconsistent behavior.

Do not use for private helpers unless they cross a team, package, process, or deployment boundary.

Domain Workflow Trigger

<HARD-GATE> ONLY ACTIVATE when invoked by the `brainstorming` skill. DO NOT automatically activate the skill, do not activate after other skills except the `brainstorming` skill.

IF not brainstorming, stop and return the message "The api-design skill was not activated because it was invoked by a skill other than brainstorming."

IF the brainstorming skill invokes to request support, notify Using the api-design skill to work...

IF the user self-activates by calling /api-design directly, only perform the exact task that the domain skill is responsible for and provide suggestions for the user.

Suggestion: To continue, use:

/brainstorming Based on the analysis from the /api-design skill above, continue building the spec and detailed implementation plan to execute.

ABSOLUTELY NO CODING, NO EDITING FILES when using the api-design skill. </HARD-GATE>

This is a domain skill for API contract design. It supplies API design judgment inside the selected process workflow; it does not choose or replace brainstorming or review skills, but will support brainstorming to make more specific judgments in decision-making.

Invoke this skill during a workflow only when the work involves designing, creating, updating, or reviewing REST/HTTP API contracts:

  • During brainstorming, use it when the user asks to create or change an API, endpoint, request schema, response schema, error semantics, pagination, filtering, sorting, versioning, idempotency, retry behavior, or compatibility behavior.
  • During execution, use it as a constraint when a plan task implements or changes API contract behavior; if implementation reveals a contract gap, stop and notify brainstorming to analyze the gap and make adjustments.
  • During review, use it as an API lens when the diff changes endpoints, schemas, errors, pagination, retries, idempotency, versioning, validation, or compatibility.

Do not invoke this skill for generic backend logic, private helpers, database-only changes, UI-only work, or implementation tasks that do not expose or change an API contract.

TDD Trigger Coverage

These are the RED scenarios this skill must prevent:

TriggerBaseline failureSkill counter
"Just add a simple CRUD API quickly"Verb URLs, handler-first design, no paginationContract-first resources, method semantics, list rules
"Ship now, document errors later"Raw exceptions or mixed error shapesOne structured error shape and stable machine codes
"We can change this field; only our app uses it"Breaking field/type/requiredness changesAdditive evolution and compatibility review
"POST is fine; clients can retry manually"Duplicate side effects on retriesIdempotency/repeatability requirement
"Third-party API already validates this"Untrusted external data enters logicBoundary validation for all external input

Core Pattern

ConcernRule
ResourcesUse clear plural nouns and readable URLs; avoid verb paths like /createTask.
ContractDefine typed request, response, and error schemas before handlers.
MethodsGET reads, PATCH partially updates, PUT replaces, POST creates service-named resources or actions, DELETE removes.
RetriesMake all operations retry-safe; use repeatability keys or equivalent for risky POST operations.
ListsAdd pagination from v1. Filtering and sorting must compose with every page and nextLink.
ValidationValidate path params, query params, headers, JSON bodies, and third-party responses at the boundary.
ErrorsReturn one structured shape everywhere. Top-level machine-readable error codes are contract.
EvolutionAdd optional fields or extensible enum values; do not remove fields, change meaning/type, or make optional data required.
ConcurrencyUse ETag/If-Match or equivalent version checks when updates can conflict.
Async workReturn 202 Accepted with a status monitor URL; the monitor supports GET, status, and retry-after while incomplete.

Example

GET /tasks?pageSize=50&continuationToken=abc&filter=status eq 'open'&orderby=createdAt desc
200 OK
{
  "value": [{ "id": "task_123", "title": "Review contract", "status": "open", "etag": "\"67ab43\"" }],
  "nextLink": "/tasks?pageSize=50&continuationToken=def&filter=status eq 'open'&orderby=createdAt desc"
}

PATCH /tasks/task_123
If-Match: "67ab43"
Content-Type: application/merge-patch+json
{ "title": "Review API contract" }

400 Bad Request
x-ms-error-code: InvalidTaskTitle
{ "error": { "code": "InvalidTaskTitle", "message": "Task title must be 1-120 characters.", "target": "title" } }

Why this works: the list is bounded, filters and sort order survive into nextLink, IDs are opaque strings, PATCH is partial, concurrency is explicit, and clients branch on stable error codes instead of parsing text.

Compatibility Review

Before shipping, answer:

  • What observable behavior might clients already depend on?
  • Can existing clients adopt the new service or SDK version without code changes?
  • Are new fields optional and safe for old clients to ignore?
  • Are enum-like strings extensible, or will unknown values break generated clients?
  • Is every retry path safe from duplicate side effects?

Common Mistakes

MistakeFix
Starting from handler codeWrite the endpoint contract first.
Returning raw exceptionsMap to the shared error shape and stable codes.
Using POST because it is convenientUse resource semantics; make POST repeatable when needed.
Adding required fields after v1Add optional fields, defaults, or a new operation.

Red Flags

  • Verb-first URLs, inconsistent path casing, or unclear resource names.
  • List endpoints without pagination.
  • Different success or error shapes across endpoints.
  • External input or third-party responses used without validation.
  • Removed fields, reinterpreted fields, narrowed enum values, or new required data.
  • No idempotency, versioning, deprecation, or migration plan.

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.