Designing rest apis
Like everyone else, I'm sharing my agent stuff.
npx -y skills add msewell/agent-stuff --skill designing-rest-apisAssembled 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.
What its author says it does
Copied from the file, not written here
Guides designing, reviewing, and governing RESTful APIs — resource modeling, URL structure, HTTP methods, status codes, error handling (RFC 9457), pagination, versioning, security, authentication, caching, idempotency, bulk operations, async patterns, file uploads, OpenAPI documentation, API-first process, and AI-agent consumers. Use when designing new REST API endpoints, reviewing existing API designs, adopting API-first development, running API design sessions, enforcing API contracts in CI/CD, governing an API program, choosing between REST patterns (cursor vs offset pagination, PUT vs PATCH, polling vs webhooks), writing OpenAPI specs, designing for AI-agent consumers (MCP), or making API evolution and deprecation decisions.
SKILL.md
7.7 KB, as published. Nobody here has run it
Designing REST APIs
Workflow: Designing a new API
- Model resources as nouns. Identify domain entities. Use plural nouns for collection URLs (
/orders, not/getOrders). Express relationships with sub-resources, max 2–3 levels deep. - Assign HTTP methods by semantics. GET=read, POST=create, PUT=full replace, PATCH=partial update, DELETE=remove. For non-CRUD actions, use POST with a clear resource name (
POST /orders/7/cancellation). - Define request/response schemas. Use camelCase for JSON fields, UPPER_SNAKE_CASE for enums, RFC 3339 for dates in UTC. Wrap collections in
{ "data": [...] }. Use string type for IDs. Represent money as smallest currency unit + currency code. - Select status codes. Return the most specific code:
201for creation (withLocationheader),204for no-content success,409for conflicts,422for business rule violations. Never return200with an error body. - Design error responses using RFC 9457 (Problem Details). Include
type(URI),title,status,detail. Return all validation errors at once. Never leak stack traces. - Add pagination to every list endpoint. Default: cursor-based pagination. Use offset pagination only for small/static datasets needing jump-to-page. Always include
has_moreor anextlink. - Plan versioning. Use URI path versioning (
/v1/). Only bump for breaking changes. Support at least one prior version with 6–12 month migration window. Signal deprecation viaDeprecationandSunsetheaders. - Address cross-cutting concerns. Add rate limiting headers on every response. Use
Cache-Control+ ETags. Require idempotency keys for POST endpoints with side effects. UseAuthorization: Bearerfor auth. - Write the OpenAPI spec first (design-first, not code-first). Use OpenAPI 3.1. Document every endpoint, every status code, every error type. Lint with Spectral or Redocly CLI.
Workflow: Adopting API-first process
- Identify consumers. List every team and system that will call the API before designing anything. If consumers aren't in the room, the API will be optimized for the producer.
- Run a design session. Start from the consumer's workflow, not the data model. Sketch endpoints and payloads informally before writing YAML. Name disagreements immediately — they're cheap to resolve now, expensive later.
- Write the spec first. Formalize the agreed design as an OpenAPI spec. Review it via PR with automated linting, consumer sign-off, and breaking change detection. Change the spec first, then the implementation — never the reverse.
- Generate mocks immediately. Unblock consumers with a mock server (Prism, Postman Mock Server) the moment the spec is agreed. Consumers build against the mock while the backend builds against the same spec.
- Enforce the contract in CI/CD. Lint specs on every PR. Detect breaking changes before merge. Validate implementation responses against the spec. Run consumer contract tests. Automate all of this — process discipline alone erodes under deadline pressure.
- Govern lightly. Maintain an API catalog tracking each API's lifecycle stage (draft → active → deprecated → retired). Signal deprecation via
DeprecationandSunsetheaders with a migration guide and sunset date. - Design for AI-agent consumers. Write
descriptionfields as if explaining to a non-expert. Provideexamplevalues for every field. Use clearoperationIdvalues. A complete, well-described OpenAPI spec is nearly MCP-compatible for free.
For detailed guidance: references 09–11.
Workflow: Reviewing an existing API
- Check resource modeling. Flag verb-based URLs, deep nesting (>3 levels), inconsistent pluralization, trailing slashes, or file extensions in URLs.
- Check HTTP method usage. Flag GET with side effects, POST used for retrieval, PUT used for partial updates, missing
Locationheader on201responses. - Check error handling. Flag custom error formats (should use RFC 9457),
200with error bodies, leaked internals, one-error-at-a-time validation. - Check pagination. Flag unbounded list endpoints, offset pagination on large datasets, missing
has_more/nextindicators. - Check security. Verify HTTPS-only, object-level authorization (not just endpoint-level), input validation, rate limiting, CORS whitelist (no
*on authenticated endpoints). - Check naming consistency. Flag mixed casing conventions, nullable booleans (should be enums), integer enum values (should be strings), bare array responses.
- Report findings grouped by severity (breaking issues → best practice violations → suggestions).
Key decisions (defaults with escape hatches)
| Decision | Default | Alternative (when) |
|---|---|---|
| Pagination | Cursor-based | Offset — small/static data needing page numbers |
| Partial update | PATCH with JSON Merge Patch (RFC 7396) | JSON Patch (RFC 6902) — need array ops or conditional updates |
| Versioning | URI path (/v1/) | Content negotiation — per-resource granularity needed |
| Auth | OAuth 2.0 + JWT (RS256, 15–30 min TTL) | API keys — simple server-to-server; mTLS — service mesh |
| Async pattern | 202 Accepted + status polling | Webhooks — server-to-server event-driven |
| Upload method | Multipart form data (1–100 MB) | Presigned URLs — cloud-native; Resumable — >100 MB |
| Error format | RFC 9457 (Problem Details) | — (no alternative; this is the standard) |
| Rate limiting | Token bucket | Sliding window — smoother enforcement |
| JSON casing | camelCase | snake_case — Python/Ruby-centric ecosystem |
Reference material
Consult these for detailed guidance, examples, and tradeoff analysis:
- 01 — Resource & URL design, Statelessness
- 02 — Naming conventions, Schema design, HTTP methods
- 03 — Status codes, Error handling (RFC 9457)
- 04 — Versioning, Pagination, Filtering & sorting
- 05 — Bulk & batch operations, Async & long-running operations
- 06 — File uploads & binary data
- 07 — Security (OWASP Top 10), Authentication & authorization, Rate limiting
- 08 — Caching (ETags, Cache-Control), Idempotency, Content negotiation
- 09 — HATEOAS, OpenAPI documentation, Observability, Testing
- 10 — Evolution & deprecation, API-first process, Governance
- 11 — AI-agent consumers (MCP), Organizational adoption, Tooling reference