[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EEJX55DV8BG1NEEXPEAFBD":3,"skill-same:01M7EEJX55DV8BG1NEEXPEAFBD":91},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":46,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":49,"updatedAt":50,"install":51,"resources":64},"01M7EEJX55DV8BG1NEEXPEAFBD","api-design",null,"Use when settling the contract of an API you expose, before implementation: resources\u002FURLs, REST vs GraphQL, versioning, one RFC 9457 error envelope, pagination, idempotency — emitted as OpenAPI 3.1. NOT implementing the endpoints (that is `fastapi`\u002F`nestjs`\u002F`go`\u002F`nodejs`), NOT auth hardening (that is `secure-coding`), NOT consuming a third-party API (that is `api-connector-builder`).","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fapi-design\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: api-design\ndescription: \"Use when settling the contract of an API you expose, before implementation: resources\u002FURLs, REST vs GraphQL, versioning, one RFC 9457 error envelope, pagination, idempotency — emitted as OpenAPI 3.1. NOT implementing the endpoints (that is `fastapi`\u002F`nestjs`\u002F`go`\u002F`nodejs`), NOT auth hardening (that is `secure-coding`), NOT consuming a third-party API (that is `api-connector-builder`).\"\ntags: [api-design, rest, graphql, openapi, versioning, pagination, http, rfc9457, contract-design]\nrecommends: [fastapi, nestjs, go, nodejs, secure-coding, webhooks, api-connector-builder, code-review]\norigin: risco\n---\n\n# API design\n\n## Your one job\n\nYou design the **contract** an API exposes. You do not write the handler. The deliverable is a set of decisions a backend skill can implement directly: resource shapes, URLs, methods, the status-code map, one error envelope, pagination params, versioning rules — ideally captured as an **OpenAPI 3.1** document.\n\nWhen the user names a framework (FastAPI, NestJS, Go, Node), they own the build; you are pulled in for contract questions. Settle the contract first, then hand off (see [Handoff](#handoff)). Keep every decision framework-neutral: nothing here should mention an ORM, a router, or a DI container.\n\n## REST vs GraphQL vs hybrid\n\nPick on traffic shape, not fashion. Decide once, write it down.\n\n| Situation | Choose | Why |\n|---|---|---|\n| CRUD-ish resources, public API, HTTP caching matters | **REST** | URLs map to resources; CDN\u002Fproxy caching works on GET + ETag out of the box |\n| Many client shapes, deep nested graphs, mobile over-fetch is real | **GraphQL** | one round-trip, client picks fields; no N endpoints per screen |\n| Stable resource API + one rich read surface for a client app | **Hybrid** | REST for the system of record, a GraphQL read layer on top |\n\nOperational gotcha that decides monitoring: **GraphQL returns HTTP 200 even when a field errored** — failures live in an `errors[]` array next to partial `data`. Your dashboards cannot alert on 5xx; you must alert on the `errors[]` payload. REST signals failure with the HTTP status itself. If your ops team lives on status-code SLOs, that is a point for REST. Schema\u002Fnullability design, mutation and error-union conventions, and this error model in full: [`references\u002Fgraphql-design.md`](references\u002Fgraphql-design.md).\n\n## Resource & URL modeling\n\nResources are **nouns**; HTTP methods are the verbs. Never put a verb in a path.\n\nRules, each with its reason:\n- **Plural collections, consistent everywhere** — `\u002Fprojects`, `\u002Fprojects\u002F{id}`. Pick plural and never mix singular in; inconsistent naming is the most-cited design smell.\n- **Nest sub-resources one level** — `\u002Fprojects\u002F{id}\u002Ftasks`. Deeper than one level (`\u002Fprojects\u002F{p}\u002Ftasks\u002F{t}\u002Fcomments\u002F{c}`) gets unreadable; link to the flat resource instead (`\u002Fcomments\u002F{c}`).\n- **Methods carry intent** — `GET` read, `POST` create, `PUT` full replace, `PATCH` partial update, `DELETE` remove. A path never says what it does.\n- **Filter\u002Fsort\u002Fselect via query string, not new paths** — `?status=open&sort=-created_at&fields=id,title`. One `GET \u002Fprojects` handles all of it; don't mint `\u002Fprojects\u002Fopen` and `\u002Fprojects\u002FbyDate`.\n\n| Bad | Good | Why |\n|---|---|---|\n| `POST \u002FcreateProject` | `POST \u002Fprojects` | the method is the verb |\n| `GET \u002FgetUserOrders\u002F{id}` | `GET \u002Fusers\u002F{id}\u002Forders` | noun hierarchy, no verb |\n| `GET \u002Fproject` and `GET \u002Ftasks` | `GET \u002Fprojects` and `GET \u002Ftasks` | one plural convention |\n| `GET \u002Fprojects\u002Factive` | `GET \u002Fprojects?status=active` | filter is a query param |\n| `POST \u002Fprojects\u002F{id}\u002Fdelete` | `DELETE \u002Fprojects\u002F{id}` | method, not path segment |\n\nFull query grammar (filter operators, sparse fieldsets, sort syntax), content negotiation, rate-limit headers and a HATEOAS note: [`references\u002Frest-conventions.md`](references\u002Frest-conventions.md).\n\n## Status codes that matter\n\nYou need a small map, used consistently. Don't overload 200.\n\n```http\n200 OK            # read \u002F update succeeded, body returned\n201 Created       # resource created — include Location: \u002Fprojects\u002F{id}\n202 Accepted      # async accepted, not done — return a status URL\n204 No Content    # success, nothing to return (e.g. DELETE)\n400 Bad Request   # malformed syntax \u002F unparseable\n401 Unauthorized  # not authenticated — who are you?\n403 Forbidden     # authenticated but not allowed — I know you, no\n404 Not Found     # resource absent (or hidden from this caller)\n409 Conflict      # state collision — duplicate, version mismatch\n422 Unprocessable # syntactically fine, semantically invalid (validation)\n429 Too Many Req  # rate limited — include Retry-After\n5xx               # your fault, never the client's; never leak the stack\n```\n\nTwo distinctions agents get wrong:\n- **401 vs 403** — 401 means *unauthenticated* (no\u002Finvalid credentials); 403 means *authenticated but unauthorized*. Returning 401 on a permission failure leaks that re-auth might help when it won't.\n- **409 vs 422** — 409 is a *state* conflict (the request fights the current server state: dup key, stale version). 422 is a *content* problem (the body parses but fails business rules). Full status-code table with when-each in [`references\u002Frest-conventions.md`](references\u002Frest-conventions.md).\n\n## Error envelope: RFC 9457\n\nOne error shape across **every** endpoint. Adopt **RFC 9457 Problem Details** (the current standard; it obsoletes RFC 7807). Media type `application\u002Fproblem+json`. Standard members: `type`, `title`, `status`, `detail`, `instance`, plus your own extension members.\n\n```json\n{\n  \"type\": \"https:\u002F\u002Fapi.acme.com\u002Fproblems\u002Fvalidation-error\",\n  \"title\": \"Your request parameters didn't validate.\",\n  \"status\": 422,\n  \"detail\": \"due_date must be in the future.\",\n  \"instance\": \"\u002Fprojects\u002F8a3\u002Ftasks\",\n  \"errors\": [\n    { \"field\": \"due_date\", \"message\": \"must be in the future\" }\n  ],\n  \"correlation_id\": \"req_01H...\"\n}\n```\n\nRules:\n- **`type` is a stable, machine-readable URI** — clients branch on it, not on `detail`. Never change a `type` string once published.\n- **`title` is human, generic per type; `detail` is human, specific to this occurrence.** `detail` is for people, not parsers.\n- **Always carry a correlation\u002Frequest id** (extension member) so a support ticket maps to a log line.\n- **Never leak internals** — no stack traces, SQL, internal hostnames, or raw DB ids in `detail`. That is both an information leak and a coupling leak.\n\n## Pagination\n\nDefault to **cursor (keyset)** pagination. Use offset only for small, bounded sets.\n\n| Approach | Use when | Why |\n|---|---|---|\n| **Cursor \u002F keyset** | large or changing datasets, feeds, anything hot | opaque token over an indexed ordered column → constant-time, stable across inserts |\n| **Offset \u002F limit** | small bounded admin lists, fixed reference tables | simple, but the DB scans-and-discards skipped rows (degrades with depth) and **skips or duplicates rows** when data shifts between page loads |\n\nDecision line: if the list can grow unbounded or rows can be inserted between page fetches, use cursor.\n\nREST cursor envelope — same keys on every list endpoint:\n\n```json\n{\n  \"data\": [ { \"id\": \"...\", \"title\": \"...\" } ],\n  \"next_cursor\": \"eyJpZCI6MTI4N30\",\n  \"has_more\": true\n}\n```\n\nThe next page is `GET \u002Fprojects?cursor=eyJpZCI6MTI4N30&limit=50`. The cursor is opaque — clients must not parse or construct it.\n\nGraphQL has its own de-facto standard: **Relay Connections** — `edges { node, cursor }`, `pageInfo { hasNextPage, endCursor }`, args `first` \u002F `after`. Use it; don't invent a bespoke GraphQL pagination shape. See [`references\u002Fgraphql-design.md`](references\u002Fgraphql-design.md).\n\n## Versioning & evolution\n\n**Prefer additive, non-breaking evolution over a new version.** A new version forks your client base and your maintenance. Most changes don't need one.\n\n- **Non-breaking (no version bump):** adding an optional field, adding a new endpoint, adding a new optional query param, adding a new enum value clients are told to tolerate.\n- **Breaking (needs a version):** removing\u002Frenaming a field, changing a type, making an optional field required, changing status-code semantics, changing the error `type` for a case.\n\nWhen you must version, **use a URL path version (`\u002Fv1\u002F...`) for public APIs** — it is visible, cacheable, trivially testable in a browser, and the most common convention clients expect. Header\u002Fmedia-type versioning (`Accept: application\u002Fvnd.acme.v2+json`) keeps URLs clean but is harder to test and cache; query-param versioning (`?version=2`) pollutes every URL. Default to path.\n\nDeprecate gracefully with the `Deprecation` and `Sunset` response headers so clients get programmatic warning before removal:\n\n```http\nDeprecation: true\nSunset: Sat, 31 Oct 2026 23:59:59 GMT\nLink: \u003Chttps:\u002F\u002Fapi.acme.com\u002Fv2\u002Fprojects>; rel=\"successor-version\"\n```\n\nFull breaking-vs-non-breaking matrix, the three versioning mechanisms and the deprecation\u002Fsunset workflow: [`references\u002Fversioning-and-evolution.md`](references\u002Fversioning-and-evolution.md).\n\n## Idempotency & concurrency\n\n- **Make POST\u002FPATCH retry-safe with an `Idempotency-Key` header.** The client sends a unique key; the server replays the original response on a retry instead of double-creating. This is an IETF httpapi draft (not yet an RFC) but is the proven pattern across Stripe, PayPal, and others — adopt it for any create\u002Fcharge\u002Fpayment-like operation where a network retry could duplicate work.\n\n```http\nPOST \u002Fpayments\nIdempotency-Key: 9b1f7c2e-... \n```\n\n- **Use `ETag` + `If-Match` for optimistic concurrency** on PUT\u002FPATCH. The server returns an `ETag` (a version fingerprint) on read; the client sends it back in `If-Match` on write. If it no longer matches, the server returns **412 Precondition Failed** — no lost update. Use `If-None-Match` for conditional GET caching.\n\n## Anti-patterns\n\n| Anti-pattern | Why it bites | Do instead |\n|---|---|---|\n| Verbs in paths (`\u002FgetUsers`, `\u002FcreateProject`) | duplicates HTTP semantics, breaks caching\u002Ftooling | noun + HTTP method |\n| Mixed plural\u002Fsingular collections | clients can't predict URLs | one plural convention everywhere |\n| 200 on error (REST) | breaks status-code monitoring and client error handling | real 4xx\u002F5xx + RFC 9457 body |\n| Different error shape per endpoint | every client writes per-endpoint parsing | one `application\u002Fproblem+json` shape |\n| Leaking stack traces \u002F SQL \u002F DB ids in errors | info leak + couples clients to internals | generic `title`, safe `detail`, correlation id |\n| Offset pagination on a hot\u002Flarge feed | slow at depth; skips\u002Fdups rows on insert | cursor\u002Fkeyset pagination |\n| Unbounded list endpoint (no limit) | one client can pull the whole table | enforce a default + max `limit` |\n| New version for every change | forks clients, multiplies maintenance | additive non-breaking evolution |\n| Breaking a field in place on a live version | silently breaks existing clients | new field\u002Fversion + deprecation headers |\n| 401 for a permission failure | misleads client into re-authing | 403 when authenticated-but-forbidden |\n| 200 for a created resource | hides the create, no `Location` | 201 + `Location` header |\n| Ignoring GraphQL partial `errors[]` | failures invisible to monitoring | alert on `errors[]`, not just HTTP 5xx |\n\n## Handoff\n\nThe contract is the artifact. Emit it as an **OpenAPI 3.1** document — the checkable deliverable a framework skill generates code from. How to shape it, and what `scripts\u002Fverify.sh` checks: [`references\u002Fopenapi-contract.md`](references\u002Fopenapi-contract.md).\n\nHand off to the builder:\n- Python\u002Fasync → [`..\u002Ffastapi\u002FSKILL.md`](..\u002Ffastapi\u002FSKILL.md)\n- NestJS \u002F Node DI → [`..\u002Fnestjs\u002FSKILL.md`](..\u002Fnestjs\u002FSKILL.md)\n- Go `net\u002Fhttp` → [`..\u002Fgo\u002FSKILL.md`](..\u002Fgo\u002FSKILL.md)\n- Node generally → [`..\u002Fnodejs\u002FSKILL.md`](..\u002Fnodejs\u002FSKILL.md)\n\nAdjacent concerns you do **not** own:\n- Auth hardening, OWASP, CORS\u002FCSP threat-modeling → [`..\u002Fsecure-coding\u002FSKILL.md`](..\u002Fsecure-coding\u002FSKILL.md) (you only place 401\u002F403\u002Fscopes in the contract)\n- Receiving inbound webhooks (HMAC verify, replay, dedupe) → [`..\u002Fwebhooks\u002FSKILL.md`](..\u002Fwebhooks\u002FSKILL.md)\n- Building an outbound client to a third-party API → [`..\u002Fapi-connector-builder\u002FSKILL.md`](..\u002Fapi-connector-builder\u002FSKILL.md)\n- Reviewing handler code (not the design) → [`..\u002Fcode-review\u002FSKILL.md`](..\u002Fcode-review\u002FSKILL.md)\n","# API design\n\n## Your one job\n\nYou design the **contract** an API exposes. You do not write the handler. The deliverable is a set of decisions a backend skill can implement directly: resource shapes, URLs, methods, the status-code map, one error envelope, pagination params, versioning rules — ideally captured as an **OpenAPI 3.1** document.\n\nWhen the user names a framework (FastAPI, NestJS, Go, Node), they own the build; you are pulled in for contract questions. Settle the contract first, then hand off (see [Handoff](#handoff)). Keep every decision framework-neutral: nothing here should mention an ORM, a router, or a DI container.\n\n## REST vs GraphQL vs hybrid\n\nPick on traffic shape, not fashion. Decide once, write it down.\n\n| Situation | Choose | Why |\n|---|---|---|\n| CRUD-ish resources, public API, HTTP caching matters | **REST** | URLs map to resources; CDN\u002Fproxy caching works on GET + ETag out of the box |\n| Many client shapes, deep nested graphs, mobile over-fetch is real | **GraphQL** | one round-trip, client picks fields; no N endpoints per screen |\n| Stable resource API + one rich read surface for a client app | **Hybrid** | REST for the system of record, a GraphQL read layer on top |\n\nOperational gotcha that decides monitoring: **GraphQL returns HTTP 200 even when a field errored** — failures live in an `errors[]` array next to partial `data`. Your dashboards cannot alert on 5xx; you must alert on the `errors[]` payload. REST signals failure with the HTTP status itself. If your ops team lives on status-code SLOs, that is a point for REST. Schema\u002Fnullability design, mutation and error-union conventions, and this error model in full: [`references\u002Fgraphql-design.md`](references\u002Fgraphql-design.md).\n\n## Resource & URL modeling\n\nResources are **nouns**; HTTP methods are the verbs. Never put a verb in a path.\n\nRules, each with its reason:\n- **Plural collections, consistent everywhere** — `\u002Fprojects`, `\u002Fprojects\u002F{id}`. Pick plural and never mix singular in; inconsistent naming is the most-cited design smell.\n- **Nest sub-resources one level** — `\u002Fprojects\u002F{id}\u002Ftasks`. Deeper than one level (`\u002Fprojects\u002F{p}\u002Ftasks\u002F{t}\u002Fcomments\u002F{c}`) gets unreadable; link to the flat resource instead (`\u002Fcomments\u002F{c}`).\n- **Methods carry intent** — `GET` read, `POST` create, `PUT` full replace, `PATCH` partial update, `DELETE` remove. A path never says what it does.\n- **Filter\u002Fsort\u002Fselect via query string, not new paths** — `?status=open&sort=-created_at&fields=id,title`. One `GET \u002Fprojects` handles all of it; don't mint `\u002Fprojects\u002Fopen` and `\u002Fprojects\u002FbyDate`.\n\n| Bad | Good | Why |\n|---|---|---|\n| `POST \u002FcreateProject` | `POST \u002Fprojects` | the method is the verb |\n| `GET \u002FgetUserOrders\u002F{id}` | `GET \u002Fusers\u002F{id}\u002Forders` | noun hierarchy, no verb |\n| `GET \u002Fproject` and `GET \u002Ftasks` | `GET \u002Fprojects` and `GET \u002Ftasks` | one plural convention |\n| `GET \u002Fprojects\u002Factive` | `GET \u002Fprojects?status=active` | filter is a query param |\n| `POST \u002Fprojects\u002F{id}\u002Fdelete` | `DELETE \u002Fprojects\u002F{id}` | method, not path segment |\n\nFull query grammar (filter operators, sparse fieldsets, sort syntax), content negotiation, rate-limit headers and a HATEOAS note: [`references\u002Frest-conventions.md`](references\u002Frest-conventions.md).\n\n## Status codes that matter\n\nYou need a small map, used consistently. Don't overload 200.\n\n```http\n200 OK            # read \u002F update succeeded, body returned\n201 Created       # resource created — include Location: \u002Fprojects\u002F{id}\n202 Accepted      # async accepted, not done — return a status URL\n204 No Content    # success, nothing to return (e.g. DELETE)\n400 Bad Request   # malformed syntax \u002F unparseable\n401 Unauthorized  # not authenticated — who are you?\n403 Forbidden     # authenticated but not allowed — I know you, no\n404 Not Found     # resource absent (or hidden from this caller)\n409 Conflict      # state collision — duplicate, version mismatch\n422 Unprocessable # syntactically fine, semantically invalid (validation)\n429 Too Many Req  # rate limited — include Retry-After\n5xx               # your fault, never the client's; never leak the stack\n```\n\nTwo distinctions agents get wrong:\n- **401 vs 403** — 401 means *unauthenticated* (no\u002Finvalid credentials); 403 means *authenticated but unauthorized*. Returning 401 on a permission failure leaks that re-auth might help when it won't.\n- **409 vs 422** — 409 is a *state* conflict (the request fights the current server state: dup key, stale version). 422 is a *content* problem (the body parses but fails business rules). Full status-code table with when-each in [`references\u002Frest-conventions.md`](references\u002Frest-conventions.md).\n\n## Error envelope: RFC 9457\n\nOne error shape across **every** endpoint. Adopt **RFC 9457 Problem Details** (the current standard; it obsoletes RFC 7807). Media type `application\u002Fproblem+json`. Standard members: `type`, `title`, `status`, `detail`, `instance`, plus your own extension members.\n\n```json\n{\n  \"type\": \"https:\u002F\u002Fapi.acme.com\u002Fproblems\u002Fvalidation-error\",\n  \"title\": \"Your request parameters didn't validate.\",\n  \"status\": 422,\n  \"detail\": \"due_date must be in the future.\",\n  \"instance\": \"\u002Fprojects\u002F8a3\u002Ftasks\",\n  \"errors\": [\n    { \"field\": \"due_date\", \"message\": \"must be in the future\" }\n  ],\n  \"correlation_id\": \"req_01H...\"\n}\n```\n\nRules:\n- **`type` is a stable, machine-readable URI** — clients branch on it, not on `detail`. Never change a `type` string once published.\n- **`title` is human, generic per type; `detail` is human, specific to this occurrence.** `detail` is for people, not parsers.\n- **Always carry a correlation\u002Frequest id** (extension member) so a support ticket maps to a log line.\n- **Never leak internals** — no stack traces, SQL, internal hostnames, or raw DB ids in `detail`. That is both an information leak and a coupling leak.\n\n## Pagination\n\nDefault to **cursor (keyset)** pagination. Use offset only for small, bounded sets.\n\n| Approach | Use when | Why |\n|---|---|---|\n| **Cursor \u002F keyset** | large or changing datasets, feeds, anything hot | opaque token over an indexed ordered column → constant-time, stable across inserts |\n| **Offset \u002F limit** | small bounded admin lists, fixed reference tables | simple, but the DB scans-and-discards skipped rows (degrades with depth) and **skips or duplicates rows** when data shifts between page loads |\n\nDecision line: if the list can grow unbounded or rows can be inserted between page fetches, use cursor.\n\nREST cursor envelope — same keys on every list endpoint:\n\n```json\n{\n  \"data\": [ { \"id\": \"...\", \"title\": \"...\" } ],\n  \"next_cursor\": \"eyJpZCI6MTI4N30\",\n  \"has_more\": true\n}\n```\n\nThe next page is `GET \u002Fprojects?cursor=eyJpZCI6MTI4N30&limit=50`. The cursor is opaque — clients must not parse or construct it.\n\nGraphQL has its own de-facto standard: **Relay Connections** — `edges { node, cursor }`, `pageInfo { hasNextPage, endCursor }`, args `first` \u002F `after`. Use it; don't invent a bespoke GraphQL pagination shape. See [`references\u002Fgraphql-design.md`](references\u002Fgraphql-design.md).\n\n## Versioning & evolution\n\n**Prefer additive, non-breaking evolution over a new version.** A new version forks your client base and your maintenance. Most changes don't need one.\n\n- **Non-breaking (no version bump):** adding an optional field, adding a new endpoint, adding a new optional query param, adding a new enum value clients are told to tolerate.\n- **Breaking (needs a version):** removing\u002Frenaming a field, changing a type, making an optional field required, changing status-code semantics, changing the error `type` for a case.\n\nWhen you must version, **use a URL path version (`\u002Fv1\u002F...`) for public APIs** — it is visible, cacheable, trivially testable in a browser, and the most common convention clients expect. Header\u002Fmedia-type versioning (`Accept: application\u002Fvnd.acme.v2+json`) keeps URLs clean but is harder to test and cache; query-param versioning (`?version=2`) pollutes every URL. Default to path.\n\nDeprecate gracefully with the `Deprecation` and `Sunset` response headers so clients get programmatic warning before removal:\n\n```http\nDeprecation: true\nSunset: Sat, 31 Oct 2026 23:59:59 GMT\nLink: \u003Chttps:\u002F\u002Fapi.acme.com\u002Fv2\u002Fprojects>; rel=\"successor-version\"\n```\n\nFull breaking-vs-non-breaking matrix, the three versioning mechanisms and the deprecation\u002Fsunset workflow: [`references\u002Fversioning-and-evolution.md`](references\u002Fversioning-and-evolution.md).\n\n## Idempotency & concurrency\n\n- **Make POST\u002FPATCH retry-safe with an `Idempotency-Key` header.** The client sends a unique key; the server replays the original response on a retry instead of double-creating. This is an IETF httpapi draft (not yet an RFC) but is the proven pattern across Stripe, PayPal, and others — adopt it for any create\u002Fcharge\u002Fpayment-like operation where a network retry could duplicate work.\n\n```http\nPOST \u002Fpayments\nIdempotency-Key: 9b1f7c2e-... \n```\n\n- **Use `ETag` + `If-Match` for optimistic concurrency** on PUT\u002FPATCH. The server returns an `ETag` (a version fingerprint) on read; the client sends it back in `If-Match` on write. If it no longer matches, the server returns **412 Precondition Failed** — no lost update. Use `If-None-Match` for conditional GET caching.\n\n## Anti-patterns\n\n| Anti-pattern | Why it bites | Do instead |\n|---|---|---|\n| Verbs in paths (`\u002FgetUsers`, `\u002FcreateProject`) | duplicates HTTP semantics, breaks caching\u002Ftooling | noun + HTTP method |\n| Mixed plural\u002Fsingular collections | clients can't predict URLs | one plural convention everywhere |\n| 200 on error (REST) | breaks status-code monitoring and client error handling | real 4xx\u002F5xx + RFC 9457 body |\n| Different error shape per endpoint | every client writes per-endpoint parsing | one `application\u002Fproblem+json` shape |\n| Leaking stack traces \u002F SQL \u002F DB ids in errors | info leak + couples clients to internals | generic `title`, safe `detail`, correlation id |\n| Offset pagination on a hot\u002Flarge feed | slow at depth; skips\u002Fdups rows on insert | cursor\u002Fkeyset pagination |\n| Unbounded list endpoint (no limit) | one client can pull the whole table | enforce a default + max `limit` |\n| New version for every change | forks clients, multiplies maintenance | additive non-breaking evolution |\n| Breaking a field in place on a live version | silently breaks existing clients | new field\u002Fversion + deprecation headers |\n| 401 for a permission failure | misleads client into re-authing | 403 when authenticated-but-forbidden |\n| 200 for a created resource | hides the create, no `Location` | 201 + `Location` header |\n| Ignoring GraphQL partial `errors[]` | failures invisible to monitoring | alert on `errors[]`, not just HTTP 5xx |\n\n## Handoff\n\nThe contract is the artifact. Emit it as an **OpenAPI 3.1** document — the checkable deliverable a framework skill generates code from. How to shape it, and what `scripts\u002Fverify.sh` checks: [`references\u002Fopenapi-contract.md`](references\u002Fopenapi-contract.md).\n\nHand off to the builder:\n- Python\u002Fasync → [`..\u002Ffastapi\u002FSKILL.md`](..\u002Ffastapi\u002FSKILL.md)\n- NestJS \u002F Node DI → [`..\u002Fnestjs\u002FSKILL.md`](..\u002Fnestjs\u002FSKILL.md)\n- Go `net\u002Fhttp` → [`..\u002Fgo\u002FSKILL.md`](..\u002Fgo\u002FSKILL.md)\n- Node generally → [`..\u002Fnodejs\u002FSKILL.md`](..\u002Fnodejs\u002FSKILL.md)\n\nAdjacent concerns you do **not** own:\n- Auth hardening, OWASP, CORS\u002FCSP threat-modeling → [`..\u002Fsecure-coding\u002FSKILL.md`](..\u002Fsecure-coding\u002FSKILL.md) (you only place 401\u002F403\u002Fscopes in the contract)\n- Receiving inbound webhooks (HMAC verify, replay, dedupe) → [`..\u002Fwebhooks\u002FSKILL.md`](..\u002Fwebhooks\u002FSKILL.md)\n- Building an outbound client to a third-party API → [`..\u002Fapi-connector-builder\u002FSKILL.md`](..\u002Fapi-connector-builder\u002FSKILL.md)\n- Reviewing handler code (not the design) → [`..\u002Fcode-review\u002FSKILL.md`](..\u002Fcode-review\u002FSKILL.md)\n",{"name":5,"tags":24,"origin":33,"recommends":34,"description":7},[5,25,26,27,28,29,30,31,32],"rest","graphql","openapi","versioning","pagination","http","rfc9457","contract-design","risco",[35,36,37,38,39,40,41,42],"fastapi","nestjs","go","nodejs","secure-coding","webhooks","api-connector-builder","code-review","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","04-安全渗透\u002Fapi-design",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill api-design",{"tool":57,"command":58},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill api-design",{"tool":60,"command":61},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill api-design","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fapi-design\u002FSKILL.md",true,[65,71,75,79,83,87],{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"evals\u002Fcases.yaml","REFERENCE","参考文档",3161,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fapi-design\u002Fevals\u002Fcases.yaml",{"path":72,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":73,"sourceHtmlUrl":74},"evals\u002FREADME.md",518,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fapi-design\u002Fevals\u002FREADME.md",{"path":76,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fgraphql-design.md",2967,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fapi-design\u002Freferences\u002Fgraphql-design.md",{"path":80,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fopenapi-contract.md",3278,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fapi-design\u002Freferences\u002Fopenapi-contract.md",{"path":84,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Frest-conventions.md",3499,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fapi-design\u002Freferences\u002Frest-conventions.md",{"path":88,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fversioning-and-evolution.md",2784,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fapi-design\u002Freferences\u002Fversioning-and-evolution.md",[92,100,105,112,119,126],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":99},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":101,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":99},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":99},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":99},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":99},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":132,"publishedAt":99},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]