arabelatso/api-design-assistant
Design and review APIs with suggestions for endpoints, parameters, return types, and best practices. Use when designing new APIs from requirements, reviewing existing API designs, generating API documentation, or getting implementation guidance. Supports REST APIs with focus on endpoint structure, request/response schemas, authentication, pagination, filtering, versioning, and OpenAPI specifications. Triggers when users ask to design, review, document, or improve APIs.
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill api-design-assistant
Assist with designing well-structured, RESTful APIs by suggesting endpoints, parameters, return types, and best practices. Generate OpenAPI specifications and provide implementation guidance.
When designing a new API or reviewing an existing one, first understand:
For new API design:
For API review:
Follow these steps based on the use case:
Step 1: Identify Resources
Map domain concepts to API resources:
/users/products/orders/users/{userId}/ordersStep 2: Define Endpoints
For each resource, determine needed operations:
# Users resource
GET /users # List users
POST /users # Create user
GET /users/{id} # Get specific user
PUT /users/{id} # Replace user
PATCH /users/{id} # Update user
DELETE /users/{id} # Delete user
# Nested resources
GET /users/{id}/orders # Get user's orders
POST /users/{id}/orders # Create order for user
# Actions
POST /users/{id}/activate # Activate user
POST /orders/{id}/cancel # Cancel order
Step 3: Design Request/Response Schemas
Define what data each endpoint expects and returns. See best-practices.md for detailed examples.
Step 4: Add Supporting Features
Step 5: Generate OpenAPI Specification
Create formal API documentation. See openapi-template.md for complete templates.
Step 1: Analyze Consistency
Check for:
Step 2: Identify Issues
Common problems:
/getUsers instead of GET /users)/user vs /users)Step 3: Suggest Improvements
Provide specific recommendations:
/getUsers to GET /users"GET /users endpoint"Step 4: Propose Migration Path
If breaking changes are needed:
/v2/users)Consult best-practices.md for detailed guidance on:
Depending on user needs, provide:
## POST /users
Create a new user account.
### Request
**Headers:**
- `Content-Type: application/json`
- `Authorization: Bearer <token>`
**Body:**
{
"name": "John Doe",
"email": "[email protected]",
"role": "user"
}
### Response
**Success (201 Created):**
{
"id": 123,
"name": "John Doe",
"email": "[email protected]",
"role": "user",
"created_at": "2024-01-15T10:30:00Z"
}
**Error (400 Bad Request):**
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input data",
"details": [
{
"field": "email",
"message": "Email format is invalid"
}
]
}
}
Generate formal OpenAPI specs using templates from openapi-template.md.
Provide language/framework-specific guidance when requested:
Example for Express.js:
// POST /users
app.post('/users', async (req, res) => {
try {
const { name, email, role } = req.body;
// Validation
if (!name || !email) {
return res.status(400).json({
error: {
code: 'VALIDATION_ERROR',
message: 'Name and email are required'
}
});
}
// Create user
const user = await User.create({ name, email, role });
res.status(201)
.location(`/users/${user.id}`)
.json(user);
} catch (error) {
res.status(500).json({
error: {
code: 'INTERNAL_ERROR',
message: 'Failed to create user'
}
});
}
});
Recommend appropriate pagination strategy:
Suggest authentication approach:
Recommend when to version:
Don't version for:
Design filtering for different data types:
Exact match:
GET /users?status=active&role=admin
Range queries:
GET /products?price_min=10&price_max=100
GET /events?start_date=2024-01-01&end_date=2024-12-31
Pattern matching:
GET /users?name_contains=john
GET /products?search=laptop
Multiple values:
GET /users?status=active,pending
GET /products?category=electronics,computers
User request:
> "Design an API for a blog platform. Users should be able to create posts, comment on posts, and like posts."
Response approach:
# Posts
GET /posts
POST /posts
GET /posts/{postId}
PUT /posts/{postId}
DELETE /posts/{postId}
# Comments on posts
GET /posts/{postId}/comments
POST /posts/{postId}/comments
DELETE /posts/{postId}/comments/{commentId}
# Likes on posts
POST /posts/{postId}/likes
DELETE /posts/{postId}/likes
GET /posts/{postId}/likes
// Post
{
"id": 123,
"title": "My Post",
"content": "Post content...",
"author_id": 456,
"created_at": "2024-01-15T10:30:00Z",
"likes_count": 10,
"comments_count": 5
}
User request:
> "Review this API design: GET /getUserById?id=123, POST /createUser, POST /updateUser"
Response approach:
# Before
GET /getUserById?id=123
POST /createUser
POST /updateUser
# After
GET /users/{id}
POST /users
PUT /users/{id} # Full replacement
PATCH /users/{id} # Partial update
User request:
> "Generate OpenAPI documentation for a user management API"
Response approach:
Start with resources, not actions:
Be consistent:
Think about the consumer:
Plan for evolution:
Document early:
Validate thoroughly:
For detailed information, consult these references:
Take arabelatso/api-design-assistant from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.