rest-api-design
REST API design with semantic HTTP methods, status codes, and resource modeling. Use when designing new APIs or reviewing existing API designs.
от sethdford★ 51 звезда на GitHub
Установить rest-api-design в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
REST API Design
Designing HTTP APIs following REST principles: resources (nouns), methods (verbs), semantic status codes, and hypermedia.
Context
You are designing or reviewing a REST API. Your role is to:
- Identify resources in the domain
- Map CRUD operations to HTTP methods semantically
- Use status codes correctly (not 200 for errors)
- Design URLs as resources, not RPC endpoints
- Consider idempotency and caching implications
REST is architectural style, not HTTP CRUD framework. Treat it with discipline.
Domain Context
Based on Roy Fielding's dissertation and REST maturity model (Richardson Level 0-3):
- Resources: Nouns (users, orders, products). Identified by URLs.
- HTTP Methods: GET (read), POST (create), PUT (replace all), PATCH (partial), DELETE (remove)
- Status Codes: 1xx (info), 2xx (success), 3xx (redirect), 4xx (client error), 5xx (server error)
- Idempotency: GET, PUT, DELETE are idempotent. POST is not.
- Hypermedia: Links in responses guide clients to related resources
- Statelessness: Each request contains all context needed; no session state on server
When to Use This Skill
- Designing a new public API
- Auditing existing API for REST compliance
- Deciding between REST, gRPC, or GraphQL
- Designing complex resource hierarchies
- Handling pagination, filtering, or versioning
Prerequisites
- Understand domain entities and relationships
- Know HTTP methods and status codes (or willing to learn)
- Have clear acceptance criteria for API behavior
- Can write test requests (curl, Postman, HTTP client)
Instructions (Detailed)
1. Identify Resources
Ask: "What are the nouns in this domain?"
Example (E-commerce API):
- Resource: User, Product, Order, Cart, Review, Inventory
For each resource, define:
- Identity: What uniquely identifies it? (id, email, SKU)
- Relationships: How does it relate to others? (User → many Orders)
- Operations: What actions apply? (CRUD + domain actions)
2. Design Resource Paths
/resource - collection of resource
/resource/{id} - individual resource
/resource/{id}/sub - sub-resource (collection)
/resource/{id}/sub/{id} - individual sub-resource
Good paths:
GET /users - list all users
POST /users - create user
GET /users/123 - get user 123
PUT /users/123 - replace user 123
PATCH /users/123 - partially update user 123
DELETE /users/123 - delete user 123
GET /users/123/orders - get user 123's orders
POST /users/123/orders - create order for user 123
Bad paths (RPC-style, avoid):
GET /getUser?id=123
GET /user/create
POST /user?action=update
GET /deleteUser?id=123
3. Map HTTP Methods Semantically
- GET: Retrieve without side effects. Safe and idempotent.
- POST: Create new resource. Not idempotent (multiple POSTs = multiple resources).
- PUT: Replace entire resource. Idempotent (same PUT twice = same result).
- PATCH: Partial update. May or may not be idempotent (depends on implementation).
- DELETE: Remove resource. Idempotent (delete twice = idempotent; second delete returns 404).
Example:
POST /orders - create NEW order → 201 Created
PUT /orders/123 - REPLACE entire order (all fields) → 200 OK
PATCH /orders/123 - UPDATE some fields → 200 OK
GET /orders/123 - RETRIEVE order → 200 OK
DELETE /orders/123 - REMOVE order → 204 No Content (or 200)
4. Use Status Codes Correctly
Success:
200 OK- Request succeeded, response includes result201 Created- Resource created; response includes resource and Location header202 Accepted- Request accepted for processing (async operations)204 No Content- Success but no response body (DELETE often returns this)
Redirection:
301 Moved Permanently- Resource moved to new URL303 See Other- Result is at a different URL (use for POST redirect)304 Not Modified- Resource unchanged since client's If-Modified-Since
Client Error:
400 Bad Request- Malformed request (missing field, invalid JSON)401 Unauthorized- Missing authentication403 Forbidden- Authenticated but no permission404 Not Found- Resource doesn't exist409 Conflict- Request conflicts with current state (e.g., duplicate email)422 Unprocessable Entity- Well-formed but semantically invalid (e.g., invalid email format)
Server Error:
500 Internal Server Error- Server bug, not client's fault503 Service Unavailable- Server overloaded or down
5. Handle Errors Consistently
Define a standard error response:
{
"error": {
"code": "INVALID_EMAIL",
"message": "Email address is invalid",
"details": {
"field": "email",
"value": "not-an-email"
}
}
}
Use same error structure for ALL endpoints. Clients can parse errors consistently.
6. **Design
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
- 01
Read - 02
Grep - 03
Glob - 04
Write - 05
Edit
Вложенные файлы
- examples/example-output.md
- template.md
FAQ
Что делает скилл rest-api-design?
REST API design with semantic HTTP methods, status codes, and resource modeling. Use when designing new APIs or reviewing existing API designs.
Как установить скилл rest-api-design?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл rest-api-design запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis 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…