api-design
БесплатноБез исполняемых скриптовНе проверенDesign or review an HTTP/REST/GraphQL API for versioning, pagination, error shapes, idempotency, auth, status codes, cache headers, and breaking-change…
от open-gsd★ 1 399 звёзд на GitHubОб этом скилле
Invocation points:
- Adding a new public API endpoint
- Redesigning an internal API boundary between services
- Code review of a PR that introduces HTTP handlers
- A slice whose acceptance criteria include "the API works"
- A GraphQL schema change
HONEST STATUS CODES. 200 OK with {"error": "not found"} is a lie. 404 says not found. Use the HTTP semantics the protocol offers — HTTP clients, caches, and intermediaries rely on them.
PAGINATION IS NON-OPTIONAL. Any list endpoint that doesn't paginate will eventually get a request for "all records" that kills your database.
Step 1: Gather the contract
Answer, or ask (one round, 1–3 questions):
- Who are the callers? Internal service / mobile app / public third-party / same-repo frontend.
- What's the versioning stance? None / URL-path (
/v1/) / header-based / GraphQL schema evolution. - Auth model? Public / API key / OAuth / session cookie / mTLS / none-but-internal-only.
- Idempotency expectation? Is a retry safe? Required?
- Consistency model? Read-your-writes, eventual, serializable?
Step 2: Resource and operation naming
REST
- Nouns not verbs in URLs:
POST /users, notPOST /createUser. - Plural resources:
/users/42, not/user/42. - Nested only when the relationship is hierarchical and the child has no independent identity:
/users/42/sessions/3. Otherwise flat:/sessions/3?userId=42. - Use subresources for actions that don't fit CRUD:
POST /users/42:deactivate(colon syntax) orPOST /users/42/actions/deactivate.
GraphQL
- Queries are nouns; mutations are verbs:
user(id),createUser(input),deactivateUser(id). - Group related mutations under an input type:
createUser(input: CreateUserInput!). - Return the affected object plus any derived/computed fields from mutations — lets clients avoid a refetch.
Step 3: Methods and status codes
REST
| Method | Intent | Idempotent? | Default success |
|---|---|---|---|
| GET | Read | Yes | 200, or 304 if conditional |
| POST | Create or non-idempotent action | No | 201 with Location on create, 200 on action |
| PUT | Replace (full-object) | Yes | 200 with body, or 204 |
| PATCH | Partial update | No (usually) | 200 with body |
| DELETE | Remove | Yes | 204 |
Errors:
- 400: caller screwed up the request shape
- 401: no/invalid auth
- 403: authed but not allowed
- 404: resource doesn't exist
- 409: conflict (version mismatch, unique constraint)
- 410: gone (vs 404 when the resource previously existed and you want to signal that)
- 422: validation failed
- 429: rate-limited — include
Retry-After - 500: genuinely unexpected server error
- 503: service down or overloaded — include
Retry-After
Never 200-with-error-body. Never 500 for a 4xx cause.
GraphQL
- Top-level errors (
errors[]) for transport-level failures. Domain errors (validation, not-found, forbidden) go in the typed return — use a union or result type. - Partial results are expected; design the schema so
nullon a field is meaningful, not a signal of generic failure.
Step 4: Pagination
- Cursor-based by default. Opaque cursor string,
limit, returnnextCursorwhen more exists. Scales, stable under writes. - Offset-based only when: dataset is small, user needs jump-to-page semantics (admin tables), and you're willing to accept stability drift.
- Never "return everything" as default. Put a hard upper bound on
limit(e.g., 200). - GraphQL: use Relay-style connections (
edges,pageInfo) if the ecosystem expects it; otherwise a simpler{items, nextCursor}is fine.
Step 5: Error shape
Standardize one shape and use it everywhere. Example REST:
{
"error": {
"code": "user_not_found",
"message": "No user with id 42",
"details": { "userId": 42 },
"requestId": "req_abc123"
}
}
codeis machine-readable; stable; documented.messageis human-readable; can change.detailscarries structured context.requestIdlets callers report bu
Установить api-design в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл api-design?
Design or review an HTTP/REST/GraphQL API for versioning, pagination, error shapes, idempotency, auth, status codes, cache headers, and breaking-change management. Use when asked to "design an API", "shape the endpoints", "design the schema", "add a new endpoint", "review this API", or when building/modifying a public or internal HTTP surface. HTTP-specific complement to `design-an-interface`.
Как установить скилл api-design?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл api-design запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic