api-design
БесплатноБез исполняемых скриптовНе проверенDesign clean, scalable, and maintainable REST and GraphQL APIs following industry best practices. Use when designing public or internal APIs, planning…
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
API Design - Building Clean, Scalable REST & GraphQL APIs
When to use this skill
- Designing new REST or GraphQL APIs from scratch
- Planning endpoint structures and URL patterns
- Defining request/response contracts and data schemas
- Establishing API versioning and deprecation strategies
- Implementing authentication and authorization patterns
- Creating API documentation (OpenAPI/Swagger)
- Designing error response formats and status codes
- Planning pagination, filtering, and sorting strategies
- Establishing rate limiting and throttling policies
- Designing webhooks or event-driven integrations
- Creating service contracts for microservices
- Optimizing API performance and caching strategies
When to use this skill
- Designing public or internal APIs, planning endpoints, defining contracts between services.
- When working on related tasks or features
- During development that requires this expertise
Use when: Designing public or internal APIs, planning endpoints, defining contracts between services.
Core Principles
- Consistency - Predictable patterns across endpoints
- Simplicity - Easy to understand and use
- Versioning - Support evolution without breaking clients
- Security - Authentication, authorization, rate limiting
- Documentation - Clear, up-to-date API specs
REST API Design
1. Resource-Based URLs
✅ Good - Nouns, not verbs
GET /users - List users
GET /users/:id - Get specific user
POST /users - Create user
PUT /users/:id - Update user (full replace)
PATCH /users/:id - Update user (partial)
DELETE /users/:id - Delete user
GET /users/:id/posts - Get user's posts
POST /users/:id/posts - Create post for user
❌ Bad - Verbs in URLs
GET /getUsers
POST /createUser
POST /users/delete/:id
2. HTTP Methods & Status Codes
// ✅ Proper HTTP method usage
app.get('/users', async (req, res) => {
const users = await db.users.findAll();
res.json(users); // 200 OK
});
app.post('/users', async (req, res) => {
const user = await db.users.create(req.body);
res.status(201) // 201 Created
.location(`/users/${user.id}`)
.json(user);
});
app.put('/users/:id', async (req, res) => {
const user = await db.users.update(req.params.id, req.body);
if (!user) {
return res.status(404).json({ error: 'User not found' });
}
res.json(user); // 200 OK
});
app.delete('/users/:id', async (req, res) => {
await db.users.delete(req.params.id);
res.status(204).send(); // 204 No Content
});
// ✅ Common status codes
// 2xx Success
200 OK - Request succeeded
201 Created - Resource created
204 No Content - Succeeded, no response body
// 4xx Client Errors
400 Bad Request - Invalid input
401 Unauthorized - Not authenticated
403 Forbidden - Authenticated but no permission
404 Not Found - Resource doesn't exist
409 Conflict - Duplicate or conflicting state
422 Unprocessable - Validation failed
429 Too Many Requests - Rate limited
// 5xx Server Errors
500 Internal Error - Something broke on server
503 Service Unavailable - Temporarily down
3. Request/Response Format
// ✅ Consistent response structure
interface ApiResponse<T> {
data: T;
meta?: {
page?: number;
limit?: number;
total?: number;
};
links?: {
self: string;
next?: string;
prev?: string;
};
}
// Success response
{
"data": {
"id": "123",
"name": "John Doe",
"email": "[email protected]"
}
}
// List response with pagination
{
"data": [
{ "id": "1", "name": "User 1" },
{ "id": "2", "name": "User 2" }
],
"meta": {
"page": 1,
"limit": 20,
"total": 100
},
"links": {
"self": "/users?page=1",
"next": "/users?page=2"
}
}
// Error response
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid email format",
"details": [
{
"field": "email",
"message": "Must be valid email"
}
]
}
}
4. Filtering, Sorting, Pagination
// ✅ Query parameters for filtering
GET /users?status=active&role=admin
GET /posts?author=john&tags=tech,programming
GET /products?minPrice=10&maxPrice=100
app.get('/users', async (req, res) => {
const { status, role, page = 1, limit = 20, sort = 'createdAt' } = req.query;
const query = {};
if (status) query.status = status;
if (role) query.role = role;
const users = await db.users.findMany({
where: query,
skip: (page - 1) * limit,
take: limit,
orderBy: { [sort]: 'desc' }
});
const total = await db.users.count({ where: query });
res.json({
data: users,
meta: { page, limit, total },
links: {
self: `/users?page=${page}`,
next: page * limit < total ? `/users?page=${page + 1}` : null
}
});
});
// ✅ Sorting
Установить api-design в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл api-design?
Design clean, scalable, and maintainable REST and GraphQL APIs following industry best practices. Use when designing public or internal APIs, planning endpoint structures, defining request/response contracts, establishing versioning strategies, implementing authentication patterns, designing data models, creating API documentation, ensuring consistent error handling, optimizing for performance, or establishing service contracts between microservices.
Как установить скилл api-design?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл api-design запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic