api-designer
npx skills add https://github.com/icartsh/icartsh_plugin --skill api-designer
Agent 安装分布
Skill 文档
API Designer
Overview
ì´ SKILLì íëì ì¸ API를 ì¤ê³, 문ìí ë° êµ¬íí기 ìí í¬ê´ì ì¸ ê°ì´ë를 ì ê³µí©ëë¤. REST ë° GraphQL í¨ë¬ë¤ìì 모ë ë¤ë£¨ë©°, ì ê³ì ëª¨ë² ì¬ë¡, ëª íí 문ìí ë° ì ì§ë³´ì ê°ë¥í ìí¤í ì²ë¥¼ ê°ì¡°í©ëë¤. íì¥ ê°ë¥íê³ ìì íë©° ê°ë°ì ì¹íì ì¸ Production-ready API ì¤ê³ë¥¼ ìí´ ì´ SKILLì ì¬ì©íì¸ì.
Core Capabilities
REST API Design
- ì ì í URL 구조를 ê°ì¶ 리ìì¤ ì§í¥ ìëí¬ì¸í¸ ì¤ê³
- HTTP method ìë¯¸ë¡ ë° status code ì¬ì©
- ì¼ê´ë ëª ëª ê·ì¹ì ì ì©í Request/response payload ì¤ê³
- Pagination, filtering ë° sorting ì ëµ
- Error handling ë° validation í¨í´
GraphQL API Design
- Type system ë° ê´ê³ë¥¼ í¬í¨í Schema ì ì
- ì ì í input typeì ì¬ì©í Query ë° mutation ì¤ê³
- Resolver í¨í´ ë° ì±ë¥ ìµì í
- Fragment ì¬ì© ë° directive 구í
- N+1 문ì ë°©ì§ ì ëµ
API Documentation
- OpenAPI 3.0 specification ìì±
- Swagger UI를 íµí ëíí 문ìí
- Authentication ë° authorization 문ìí
- ë¤ìí ìë리ì¤ë¥¼ í¬í¨í Example requests/responses
- ì¬ì(Specification)ì¼ë¡ë¶í° ì½ë ìì±
Authentication & Authorization
- OAuth 2.0 flow (authorization code, client credentials, PKCE)
- JWT token ì¤ê³, validation ë° rotation
- API key ê´ë¦¬ ë° rotation ì ëµ
- Role-based access control (RBAC) 구í
- Rate limiting ë° throttling í¨í´
API Versioning
- URL versioning ë° header-based versioning ì ëµ
- API 릴리ì¤ë¥¼ ìí Semantic versioning
- Deprecation ê³í ë° ì»¤ë®¤ëì¼ì´ì
- Backward compatibility ì ì§
- Migration ê²½ë¡ ì¤ê³
When to Use This Skill
ì´ SKILLì ë¤ìê³¼ ê°ì ê²½ì°ì ì¬ì©íì¸ì:
- ìë¡ì´ API를 ì²ìë¶í° ì¤ê³íê±°ë 기존 ìëí¬ì¸í¸ë¥¼ 리í©í ë§í ë
- 문ìí를 ìí´ OpenAPI/Swagger ì¬ìì ìì±í ë
- Authentication ë° authorization flow를 구íí ë
- API versioning ë° deprecation ì ëµì ê³íí ë
- GraphQL schema ë° resolver를 ì¤ê³í ë
- API governance ë° ëª¨ë² ì¬ë¡ë¥¼ í립í ë
REST API Design Workflow
Step 1: Identify Resources
APIê° ë ¸ì¶í íµì¬ 리ìì¤(Noun)를 ìë³í©ëë¤:
Resources: Users, Posts, Comments
Collections:
- GET /users (모ë ì¬ì©ì ëª©ë¡ ì¡°í)
- POST /users (ì ì¬ì©ì ìì±)
Individual Resources:
- GET /users/{id} (í¹ì ì¬ì©ì ì¡°í)
- PUT /users/{id} (ì¬ì©ì êµì²´ - ì ì²´ ì
ë°ì´í¸)
- PATCH /users/{id} (ì¬ì©ì ì
ë°ì´í¸ - ì¼ë¶ ì
ë°ì´í¸)
- DELETE /users/{id} (ì¬ì©ì ìì )
Nested Resources:
- GET /users/{id}/posts (ì¬ì©ìì í¬ì¤í¸ ì¡°í)
- POST /users/{id}/posts (ì¬ì©ì를 ìí í¬ì¤í¸ ìì±)
Step 2: Design URL Structure
RESTful ëª ëª ê·ì¹ì ë°ë¦ ëë¤:
Best Practices:
- ë³µìí ëª
ì¬ ì¬ì©:
/users,/posts(/user,/postìë) - ì¬ë¬ ë¨ì´ë íì´í ì¬ì©:
/blog-posts(/blogPostsëë/blog_postsìë) - URLì ì문ìë¡ ì ì§
- Nestingì ìµë 2ë¨ê³ë¡ ì í
- Filteringì ìí´ query parameter ì¬ì©:
/posts?status=published&author=123
Quick Examples:
â
Good:
GET /users
GET /users/123/posts
GET /posts?published=true&limit=10
â Bad:
GET /getUsers
GET /users/123/posts/comments/likes (ë무 ê¹ì nesting)
GET /posts/published (ëì query param ì¬ì©)
Step 3: Choose HTTP Methods
ìì ì íì¤ HTTP methodì 매íí©ëë¤:
- GET: 리ìì¤ ì¡°í – Safe, idempotent, cacheable
- POST: ì 리ìì¤ ìì± – Location headerì í¨ê» 201 Created ë°í
- PUT: ì ì²´ 리ìì¤ êµì²´ – Idempotent, ì ì²´ êµì²´
- PATCH: ë¶ë¶ ì ë°ì´í¸ – í¹ì íëë§ ì ë°ì´í¸
- DELETE: 리ìì¤ ì ê±° – Idempotent, 204 ëë 200 ë°í
Step 4: Design Request/Response Payloads
JSON payload를 ì¼ê´ëê² êµ¬ì±í©ëë¤:
Naming Conventions:
- JSON íë ì´ë¦ì camelCase ì¬ì©
- íìì¤í¬íì ISO 8601 ì¬ì© (UTC)
- ì ëì¬ê° ìë ì¼ê´ë ID íì ì¬ì©:
usr_,post_ - ë©íë°ì´í° í¬í¨:
createdAt,updatedAt
Example Response:
{
"id": "usr_1234567890",
"username": "johndoe",
"email": "john@example.com",
"profile": {
"firstName": "John",
"lastName": "Doe"
},
"createdAt": "2025-10-25T10:30:00Z",
"updatedAt": "2025-10-25T10:30:00Z"
}
Step 5: Implement Error Handling
í¬ê´ì ì¸ ìë¬ ìëµì ì¤ê³í©ëë¤:
Error Response Format:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": [
{
"field": "email",
"message": "Email format is invalid"
}
],
"requestId": "req_abc123xyz",
"timestamp": "2025-10-25T10:30:00Z"
}
}
Key Status Codes:
200 OK: ì±ê³µì ì¸ GET, PUT, PATCH201 Created: ì±ê³µì ì¸ POST204 No Content: ì±ê³µì ì¸ DELETE400 Bad Request: ì í¨íì§ ìì ìì² ë°ì´í°401 Unauthorized: ì¸ì¦ ì ë³´ ëë½/ì í¨íì§ ìì403 Forbidden: ì¸ì¦ëìì¼ë ê¶í ìì404 Not Found: 리ìì¤ê° ì¡´ì¬íì§ ìì422 Unprocessable Entity: Validation ìë¬429 Too Many Requests: Rate limit ì´ê³¼500 Internal Server Error: ìë² ìë¬
Step 6: Add Pagination and Filtering
Cursor-Based Pagination (ëê·ëª¨ ë°ì´í°ì ì ê¶ì¥):
GET /posts?limit=20&cursor=eyJpZCI6MTIzfQ
Response:
{
"data": [...],
"pagination": {
"nextCursor": "eyJpZCI6MTQzfQ",
"hasMore": true
}
}
Offset-Based Pagination (ìê·ëª¨ ë°ì´í°ì ì ì í©):
GET /posts?limit=20&offset=40&sort=-createdAt
Response:
{
"data": [...],
"pagination": {
"total": 500,
"limit": 20,
"offset": 40
}
}
ìì¸í Pagination ì ëµ ë° filtering í¨í´ì references/rest_best_practices.md를 참조íì¸ì.
GraphQL API Design Workflow
Step 1: Define Schema Types
ëë©ì¸ì ìí type definitionì ìì±í©ëë¤:
type User {
id: ID!
username: String!
email: String!
profile: Profile
posts(limit: Int = 10): [Post!]!
createdAt: DateTime!
}
type Post {
id: ID!
title: String!
content: String!
published: Boolean!
author: User!
tags: [String!]!
createdAt: DateTime!
}
Step 2: Design Queries
Filteringì í¬í¨í ì¡°í ìì ì ì ìí©ëë¤:
type Query {
user(id: ID!): User
post(id: ID!): Post
users(
limit: Int = 10
offset: Int = 0
search: String
): UserConnection!
posts(
limit: Int = 10
published: Boolean
authorId: ID
tags: [String!]
): PostConnection!
}
Step 3: Design Mutations
Input type ë° error handlingì í¬í¨í ì°ê¸° ìì ì ì ìí©ëë¤:
type Mutation {
createUser(input: CreateUserInput!): CreateUserPayload!
updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
createPost(input: CreatePostInput!): CreatePostPayload!
}
input CreateUserInput {
username: String!
email: String!
password: String!
}
type CreateUserPayload {
user: User
errors: [Error!]
}
ì ì²´ GraphQL schema ììë examples/graphql_schema.graphqlì 참조íì¸ì.
Authentication Patterns
OAuth 2.0 Quick Reference
Authorization Code Flow (ë°±ìëê° ìë ì¹ ì±):
1. client_id, redirect_uri, scopeì í¨ê» /oauth/authorizeë¡ ë¦¬ë¤ì´ë í¸
2. ì¬ì©ìê° ì¸ì¦íê³ ê¶í ë¶ì¬
3. 리ë¤ì´ë í¸ë¥¼ íµí´ authorization code ìì
4. /oauth/tokenìì ì½ë를 access tokenì¼ë¡ êµí
5. Authorization headerì access token ì¬ì©
Client Credentials Flow (ìë¹ì¤ ê° íµì ):
POST /oauth/token
{
"grant_type": "client_credentials",
"client_id": "CLIENT_ID",
"client_secret": "SECRET"
}
PKCE Flow (모ë°ì¼/SPA – í¼ë¸ë¦ í´ë¼ì´ì¸í¸ì ê°ì¥ ìì ):
1. code_verifier ë° code_challenge ìì±
2. code_challengeì í¨ê» ê¶í ìì²
3. code_verifierë¡ ì½ë를 í í°ì¼ë¡ êµí (client_secret ë¶íì)
JWT Token Design
Token Structure:
{
"header": { "alg": "RS256", "typ": "JWT" },
"payload": {
"sub": "usr_1234567890",
"iat": 1698336000,
"exp": 1698339600,
"scope": ["read:posts", "write:posts"],
"roles": ["user", "editor"]
}
}
Usage:
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
API Key Authentication
X-API-Key: sk_live_abcdef1234567890
Best Practices:
- íê²½ë³(dev, staging, prod)ë¡ ë¤ë¥¸ í¤ ì¬ì©
- ë¡í ì´ì ì ìí´ ê³ì ë¹ ì¬ë¬ í¤ ì§ì
- Key expiration ë° ì¬ì© ë¡ê·¸ 구í
- í´ë¼ì´ì¸í¸ 측 ì½ëì í¤ë¥¼ ë ¸ì¶íì§ ìì
Refresh token, MFA ë° ë³´ì ëª¨ë² ì¬ë¡ë¥¼ í¬í¨í ì¢
í©ì ì¸ ì¸ì¦ í¨í´ì references/authentication.md를 참조íì¸ì.
API Versioning Strategies
URL Versioning (ê¶ì¥)
/v1/users
/v2/users
ì¥ì : ëª ííê³ ëª ìì ì´ë©°, ìºì± ë° ë¼ì°í ì´ ì¬ì ë¨ì : URL íì°, ì¬ë¬ ì½ëë² ì´ì¤ ê´ë¦¬
Header Versioning
Accept: application/vnd.myapi.v2+json
API-Version: 2
ì¥ì : ê¹ëí URL, ëì¼í ìëí¬ì¸í¸ ì ì§ ë¨ì : ë ê°ìì ì´ë©°, ë¸ë¼ì°ì ìì í ì¤í¸í기 ì´ë ¤ì
When to Version
ìë¡ì´ ë²ì ì´ íìí ê²½ì°:
- ìëí¬ì¸í¸ ëë íë ìì
- íë ì í ëë ì´ë¦ ë³ê²½
- ì¸ì¦ ë°©ë² ìì
- 기존 í´ë¼ì´ì¸í¸ ê³ì½(Contract) ìë°
ë²ì ê´ë¦¬ê° íì ìë ê²½ì°:
- ìë¡ì´ ì íì (Optional) íë ì¶ê°
- ìë¡ì´ ìëí¬ì¸í¸ ì¶ê°
- ë²ê·¸ ìì ëë ì±ë¥ í¥ì
ìì¸í Versioning ì ëµ, deprecation íë¡ì¸ì¤ ë° migration í¨í´ì references/versioning-strategies.md를 참조íì¸ì.
OpenAPI Specification
Basic Structure
openapi: 3.0.0
info:
title: My API
version: 1.0.0
description: API description
servers:
- url: https://api.example.com/v1
paths:
/users:
get:
summary: List users
parameters:
- name: limit
in: query
schema:
type: integer
default: 10
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/UserList'
components:
schemas:
User:
type: object
required:
- username
- email
properties:
id:
type: string
username:
type: string
email:
type: string
format: email
ì ì²´ OpenAPI ì¬ì ììë examples/openapi_spec.yamlì 참조íì¸ì.
Generating Documentation
Helper script를 ì¬ì©íì¬ ì¬ìì ìì±íê³ ê²ì¦í©ëë¤:
# ì½ëìì OpenAPI ì¬ì ìì±
python scripts/api_helper.py generate --input api.py --output openapi.yaml
# 기존 ì¬ì ê²ì¦
python scripts/api_helper.py validate --spec openapi.yaml
# 문ì ì¬ì´í¸ ìì±
python scripts/api_helper.py docs --spec openapi.yaml --output docs/
Best Practices Summary
Consistency
- 모ë ìëí¬ì¸í¸ìì ì¼ê´ë ëª ëª ê·ì¹ ì¬ì©
- ìë¬ ìëµ íì íì¤í
- 모ë ê³³ì ëì¼í ì¸ì¦ í¨í´ ì ì©
- íµì¼ë íìì¤í¬í íì ì¬ì© (ISO 8601 with UTC)
Security
- Productionììë íì HTTPS ì¬ì©
- 모ë ì ë ¥ ë°ì´í°ë¥¼ ì² ì í ê²ì¦
- ì¬ì©ì/í¤/IPë³ë¡ Rate limiting 구í
- 모ë ìëí¬ì¸í¸ì ì ì í ì¸ì¦ ì¬ì©
- URLì´ë ë¡ê·¸ì 민ê°í ë°ì´í°ë¥¼ ë ¸ì¶íì§ ìì
- ì ì í CORS êµ¬ì± êµ¬í
Performance
- ëê·ëª¨ ë°ì´í°ì ì Pagination ì¬ì©
- ìºì± í¤ë(ETag, Cache-Control) 구í
- ìì¶(gzip) ì§ì
- ì¤ìê° ë°ì´í°ì Cursor-based pagination ì¬ì©
- Sparse fieldsetsì ìí íë ì í(Field selection) 구í
Documentation
- 모ë ìëí¬ì¸í¸ë¥¼ OpenAPIë¡ ë¬¸ìí
- Example requests ë° responses ì ê³µ
- ìë¬ ì½ë ë° ì미 문ìí
- ì¸ì¦ ìë´ í¬í¨
- 문ì를 ì½ëì ë기íë ìíë¡ ì ì§
Maintainability
- ëª íí deprecation ì¼ì ì ê°ì§ê³ ì ì íê² API ë²ì ê´ë¦¬
- 기ë¥ì ì ê±°í기 ì ì deprecation ê²½ê³ ì ê³µ
- 모ë ìëí¬ì¸í¸ì ëí´ íµí© í ì¤í¸ ìì±
- API ì¬ì©ë, ìë¬ ë° ì±ë¥ 모ëí°ë§
- ê°ë¥í ê²½ì° Backward compatibility ì ì§
Common Patterns
Health Check
GET /health
Response: { "status": "ok", "timestamp": "2025-10-25T10:30:00Z" }
Batch Operations
POST /users/batch
{
"operations": [
{ "method": "POST", "path": "/users", "body": {...} },
{ "method": "PATCH", "path": "/users/123", "body": {...} }
]
}
Webhooks
POST /webhooks/configure
{
"url": "https://your-app.com/webhook",
"events": ["user.created", "post.published"],
"secret": "webhook_secret_key"
}
Idempotency, long-running operations, file uploads ë° soft deletes를 í¬í¨í ì¶ê° í¨í´ì references/common-patterns.md를 참조íì¸ì.
Quick Reference Checklists
REST Endpoint Design
- 컬ë ì ì ë³µìí ëª ì¬ ì¬ì©
- URL nestingì 2ë¨ê³ë¡ ì í
- ì ì í HTTP method ì¬ì©
- ì íí status code ë°í
- ì¼ê´ë ìë¬ íì 구í
- 컬ë ì ì Pagination ì¶ê°
- Filtering ë° sorting í¬í¨
- OpenAPIë¡ ë¬¸ìí
- Authentication 구í
- Rate limiting ì¶ê°
GraphQL Schema Design
- ëª íí type hierarchy ì ì
- Nullable typeì ì ì íê² ì¬ì©
- Pagination(connections) 구í
- Input typeì ì¬ì©í mutation ì¤ê³
- Payloadì ìë¬ ë°í
- ì¤ëª (Description)ì¼ë¡ ì¤í¤ë§ 문ìí
- Authentication/authorization 구í
- N+1 쿼리 ìµì í (DataLoader)
Additional Resources
Comprehensive References
references/rest_best_practices.md– ì ì²´ REST API í¨í´, status code ë° êµ¬í ì¸ë¶ ì ë³´references/authentication.md– OAuth 2.0, JWT, API keys, MFA ë° ë³´ì ëª¨ë² ì¬ë¡references/versioning-strategies.md– Versioning ì ê·¼ ë°©ì, deprecation ë° migration ì ëµreferences/common-patterns.md– Health check, webhooks, batch operations ë±
Examples
examples/openapi_spec.yaml– ë¸ë¡ê·¸ API를 ìí ì ì²´ OpenAPI 3.0 ì¬ìexamples/graphql_schema.graphql– Query, mutation ë° subscriptionì í¬í¨í ì ì²´ GraphQL schema
Tools
scripts/api_helper.py– API ì¬ì ìì±, ê²ì¦ ë° ë¬¸ìí ì í¸ë¦¬í°