[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74G6TSJVBB9VQAXQCM2E5RK":3,"skill-same:01M74G6TSJVBB9VQAXQCM2E5RK":44},{"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":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M74G6TSJVBB9VQAXQCM2E5RK","api-design-rest",null,"Design a REST endpoint or resource — URL, method, status codes, request\u002Fresponse shape, errors, idempotency, versioning.","MohammadBafkar\u002Fpolymath","MohammadBafkar","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F34940462?v=4","01M74G540TQFZWK6KVAPKFVGNR","Mohammad Bafkar","01M74G541HG19QP9V5DQCJVKYE",0,"MIT","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-backend\u002Fskills\u002Fapi-design-rest\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: api-design-rest\ndescription: Design a REST endpoint or resource — URL, method, status codes, request\u002Fresponse shape, errors, idempotency, versioning.\n---\n\n# api-design-rest\n\n> Specify a REST endpoint before implementing it. Output is a one-page design that surfaces the trade-offs.\n\n**Mode:** analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked `[TBD]` or `[VERIFY]`, never filled in.\n\n## When to use\n\n- Adding a new endpoint.\n- An existing endpoint's contract is ambiguous and a caller asks \"what does this do?\".\n- A workflow invokes `polymath-backend:api-design-rest`.\n\n## Inputs\n\n- Resource and operation in plain English.\n- Existing API conventions in the repo (read the most recent endpoint).\n\n## Project localization\n\nBefore the procedure, resolve the project snapshot —\n`${POLYMATH_DATA_DIR:-$HOME\u002F.polymath\u002Fdata}\u002Fpolymath-core\u002Fproject-context.json`\n(ignore it if its `_meta.source` belongs to another repo; absent → read\n`.polymath\u002Fproject.yaml` directly; neither → built-in defaults). Then apply\n(contract: `polymath-core:project-context`):\n\n- `conventions_docs`: read roles `api-style` and `backend-stack`; follow\n  `conventions.api_style_guide` when set. Project rules win over the\n  generic defaults below.\n\n## Procedure\n\n1. **Resource shape** — name the resource (noun, plural) and its identifier scheme. URLs operate on resources, not actions: `POST \u002Forders\u002F:id\u002Frefunds` ≫ `POST \u002FrefundOrder`.\n2. **AuthN + AuthZ** — the scope\u002Frole required, and the object-level check: the caller may act on *this* `:id` (broken object-level authorization is the most common API vulnerability). Decide 403 vs 404 for \"exists but not yours\" — 404 avoids confirming the resource exists.\n3. **Method** — choose by semantics, not by accident:\n   - GET — safe, idempotent, cacheable.\n   - POST — create \u002F non-idempotent action.\n   - PUT — full replace (idempotent).\n   - PATCH — partial update (idempotent if the patch is value-based; not if it's \"append\").\n   - DELETE — idempotent.\n4. **Status codes** — pick from this short list and stick to it:\n   - 200 OK (response has body), 201 Created (with Location), 202 Accepted (async work), 204 No Content (no body).\n   - 400 Bad Request (validation), 401 Unauthorized (no\u002Finvalid creds), 403 Forbidden (creds OK but not allowed), 404 Not Found, 409 Conflict (concurrent edit \u002F unique constraint), 410 Gone, 422 Unprocessable Entity (semantic validation), 429 Too Many Requests.\n   - 500 Internal Server Error, 503 Service Unavailable (retry hint via Retry-After).\n5. **Request\u002Fresponse shape** — JSON. snake_case OR camelCase, pick one for the whole service. Show one happy-path example.\n6. **Errors** — one error envelope for the whole service (RFC 9457 `application\u002Fproblem+json` is the standard option if the service has none yet):\n\n   ```jsonc\n   { \"error\": { \"code\": \"RATE_LIMIT_EXCEEDED\", \"message\": \"…\", \"details\": { \"retry_after_seconds\": 60 } } }\n   ```\n\n   `code` is machine-readable, `message` is human-readable, `details` is structured context. Don't surface stack traces.\n7. **Idempotency** — for `POST` (and non-idempotent `PATCH`) writes that may be retried: require an `Idempotency-Key` header. (`PUT` and `DELETE` are idempotent by definition.) Store the request fingerprint and response against the key for ≥ 24h; a reused key with a *different* payload returns `422`, and a request arriving while the first is still in flight returns `409`.\n8. **Versioning** — pick one and stick to it: URL (`\u002Fv1\u002Forders`) or header (`Accept: application\u002Fvnd.example+json; version=1`). URL is simpler and works with caches.\n9. **Pagination** — cursor-based for collections that can grow. Page size capped server-side; expose `next_cursor` in the response.\n10. **Rate limit signaling** — `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset` headers (or the legacy `X-` variants if the service already uses them).\n\n## Output\n\n```text\nEndpoint: POST \u002Fv1\u002Forders\u002F:order_id\u002Frefunds\n\nPurpose: Initiate a refund for an order.\n\nAuth: Bearer (scope=orders:refund).\nIdempotency: required (Idempotency-Key header).\n\nRequest body:\n  { \"amount_cents\": int, \"reason\": string, \"refund_to\": \"original\"|\"credit\" }\n\nResponses:\n  201 Created         { \"refund\": { \"id\": \"...\", \"status\": \"processing\", ... } }\n  400 Bad Request     amount_cents not int \u002F missing reason\n  404 Not Found       order_id unknown\n  409 Conflict        order already fully refunded\n  422 Unprocessable   amount_cents exceeds order total\n  429 Too Many Requests  (Retry-After: 60)\n\nErrors envelope: standard. Codes used: VALIDATION, ORDER_NOT_FOUND,\nALREADY_REFUNDED, EXCEEDS_TOTAL, RATE_LIMIT.\n```\n\n## Anti-patterns to avoid\n\n- Verbs in URLs (`\u002FgetOrder`).\n- 200 OK for everything (use 201\u002F204 where appropriate).\n- \"Errors\" returned as 200 with an `error` field in body.\n- Surfacing internal IDs \u002F stack traces in error responses.\n- Skipping idempotency on a payment \u002F refund \u002F send-email endpoint.\n- Checking that the caller is logged in but not that they own the `:id` they're acting on.\n","# api-design-rest\n\n> Specify a REST endpoint before implementing it. Output is a one-page design that surfaces the trade-offs.\n\n**Mode:** analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked `[TBD]` or `[VERIFY]`, never filled in.\n\n## When to use\n\n- Adding a new endpoint.\n- An existing endpoint's contract is ambiguous and a caller asks \"what does this do?\".\n- A workflow invokes `polymath-backend:api-design-rest`.\n\n## Inputs\n\n- Resource and operation in plain English.\n- Existing API conventions in the repo (read the most recent endpoint).\n\n## Project localization\n\nBefore the procedure, resolve the project snapshot —\n`${POLYMATH_DATA_DIR:-$HOME\u002F.polymath\u002Fdata}\u002Fpolymath-core\u002Fproject-context.json`\n(ignore it if its `_meta.source` belongs to another repo; absent → read\n`.polymath\u002Fproject.yaml` directly; neither → built-in defaults). Then apply\n(contract: `polymath-core:project-context`):\n\n- `conventions_docs`: read roles `api-style` and `backend-stack`; follow\n  `conventions.api_style_guide` when set. Project rules win over the\n  generic defaults below.\n\n## Procedure\n\n1. **Resource shape** — name the resource (noun, plural) and its identifier scheme. URLs operate on resources, not actions: `POST \u002Forders\u002F:id\u002Frefunds` ≫ `POST \u002FrefundOrder`.\n2. **AuthN + AuthZ** — the scope\u002Frole required, and the object-level check: the caller may act on *this* `:id` (broken object-level authorization is the most common API vulnerability). Decide 403 vs 404 for \"exists but not yours\" — 404 avoids confirming the resource exists.\n3. **Method** — choose by semantics, not by accident:\n   - GET — safe, idempotent, cacheable.\n   - POST — create \u002F non-idempotent action.\n   - PUT — full replace (idempotent).\n   - PATCH — partial update (idempotent if the patch is value-based; not if it's \"append\").\n   - DELETE — idempotent.\n4. **Status codes** — pick from this short list and stick to it:\n   - 200 OK (response has body), 201 Created (with Location), 202 Accepted (async work), 204 No Content (no body).\n   - 400 Bad Request (validation), 401 Unauthorized (no\u002Finvalid creds), 403 Forbidden (creds OK but not allowed), 404 Not Found, 409 Conflict (concurrent edit \u002F unique constraint), 410 Gone, 422 Unprocessable Entity (semantic validation), 429 Too Many Requests.\n   - 500 Internal Server Error, 503 Service Unavailable (retry hint via Retry-After).\n5. **Request\u002Fresponse shape** — JSON. snake_case OR camelCase, pick one for the whole service. Show one happy-path example.\n6. **Errors** — one error envelope for the whole service (RFC 9457 `application\u002Fproblem+json` is the standard option if the service has none yet):\n\n   ```jsonc\n   { \"error\": { \"code\": \"RATE_LIMIT_EXCEEDED\", \"message\": \"…\", \"details\": { \"retry_after_seconds\": 60 } } }\n   ```\n\n   `code` is machine-readable, `message` is human-readable, `details` is structured context. Don't surface stack traces.\n7. **Idempotency** — for `POST` (and non-idempotent `PATCH`) writes that may be retried: require an `Idempotency-Key` header. (`PUT` and `DELETE` are idempotent by definition.) Store the request fingerprint and response against the key for ≥ 24h; a reused key with a *different* payload returns `422`, and a request arriving while the first is still in flight returns `409`.\n8. **Versioning** — pick one and stick to it: URL (`\u002Fv1\u002Forders`) or header (`Accept: application\u002Fvnd.example+json; version=1`). URL is simpler and works with caches.\n9. **Pagination** — cursor-based for collections that can grow. Page size capped server-side; expose `next_cursor` in the response.\n10. **Rate limit signaling** — `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset` headers (or the legacy `X-` variants if the service already uses them).\n\n## Output\n\n```text\nEndpoint: POST \u002Fv1\u002Forders\u002F:order_id\u002Frefunds\n\nPurpose: Initiate a refund for an order.\n\nAuth: Bearer (scope=orders:refund).\nIdempotency: required (Idempotency-Key header).\n\nRequest body:\n  { \"amount_cents\": int, \"reason\": string, \"refund_to\": \"original\"|\"credit\" }\n\nResponses:\n  201 Created         { \"refund\": { \"id\": \"...\", \"status\": \"processing\", ... } }\n  400 Bad Request     amount_cents not int \u002F missing reason\n  404 Not Found       order_id unknown\n  409 Conflict        order already fully refunded\n  422 Unprocessable   amount_cents exceeds order total\n  429 Too Many Requests  (Retry-After: 60)\n\nErrors envelope: standard. Codes used: VALIDATION, ORDER_NOT_FOUND,\nALREADY_REFUNDED, EXCEEDS_TOTAL, RATE_LIMIT.\n```\n\n## Anti-patterns to avoid\n\n- Verbs in URLs (`\u002FgetOrder`).\n- 200 OK for everything (use 201\u002F204 where appropriate).\n- \"Errors\" returned as 200 with an `error` field in body.\n- Surfacing internal IDs \u002F stack traces in error responses.\n- Skipping idempotency on a payment \u002F refund \u002F send-email endpoint.\n- Checking that the caller is logged in but not that they own the `:id` they're acting on.\n",{"name":5,"description":7},"main","23f6e21841a39580c9da2b5ec941f39dda17cd86","plugins\u002Fpolymath-backend\u002Fskills\u002Fapi-design-rest","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath","https:\u002F\u002Fgithub.com\u002FMohammadBafkar","2026-10-29 18:34:59",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add MohammadBafkar\u002Fpolymath --skill api-design-rest",{"tool":36,"command":37},"bunx","bunx skills add MohammadBafkar\u002Fpolymath --skill api-design-rest",{"tool":39,"command":40},"pnpm","pnpm dlx skills add MohammadBafkar\u002Fpolymath --skill api-design-rest","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-backend\u002Fskills\u002Fapi-design-rest\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M74GN87EBRHM9N87M7AP1HDD","runbook","Write or refresh an operational runbook for an alert\u002Fsymptom; structured as TL;DR + Pre-checks + Steps + Verification + Rollback + Escalation.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Frunbook\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M74GN5GPKEC1JEKP2DFQNEQJ","rfc","Draft a lightweight design RFC to docs\u002Frfcs\u002F\u003Cslug>.md; Summary, Motivation, Detailed design, Drawbacks, Alternatives, Unresolved questions. A proposal to debate, not a recorded decision (adr).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Frfc\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M74GN2F4CWPMV4X09TG4E304","editorial-pass","Review and tighten prose in a Markdown artifact for a target tone (terse, formal, friendly) without dropping information; preserve quotations and load-bearing constraints.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Feditorial-pass\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M74GMZWGYMZ37C4DYGT6P23G","architecture-review-facilitation","Run an architecture review as a process — entry criteria, reviewer checklist, decision log, and follow-up actions — pairing the design artifact with a red-team pass.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Farchitecture-review-facilitation\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M74GMXVX0YX3ETDXS527XDGM","architecture-doc","Write a C4-style architecture document; System Context + Containers (+ Components when interesting) with mermaid diagrams. Describes structure, not a decision (adr) or proposal (rfc).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Farchitecture-doc\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M74GMVG1WSMCK066S3KE6V5K","adr","Write an Architecture Decision Record (Michael Nygard format) to docs\u002Fadrs\u002FNNNN-\u003Cslug>.md; frontmatter validated by the ADR artifact schema. Records a made decision, not a proposal to debate (rfc).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Fadr\u002FSKILL.md",[],[]]