api-design-principles
Provides design principles for building intuitive REST and GraphQL APIs.
Install
mkdir -p .claude/skills/api-design-principles-repairyourtech && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/10739" && unzip -o skill.zip -d .claude/skills/api-design-principles-repairyourtech && rm skill.zipInstalls to .claude/skills/api-design-principles-repairyourtech
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.Key capabilities
- →Design REST APIs
- →Design GraphQL APIs
- →Standardize status codes
- →Implement pagination
How it works
It provides a set of design principles and a checklist for creating consistent, scalable APIs.
Inputs & outputs
When to use api-design-principles
- →Designing a new API endpoint
- →Reviewing API documentation
- →Standardizing API responses
About this skill
API Design Principles
Design APIs that developers love to use — consistent, predictable, and well-documented.
When to Use
- Designing new REST or GraphQL APIs
- Reviewing API specs before implementation
- Establishing API design standards for a team
- Migrating between API paradigms
When NOT to Use
- Framework-specific implementation details (use stack skills instead)
- Infrastructure-only work without API contracts
- Existing APIs that cannot be versioned
Core Rules
1. Resources Are Nouns, Methods Are Verbs
✅ GET /api/users → List users
✅ POST /api/users → Create user
✅ GET /api/users/{id} → Get user
✅ PATCH /api/users/{id} → Update user fields
✅ DELETE /api/users/{id} → Delete user
❌ POST /api/createUser
❌ GET /api/getUserById
❌ POST /api/deleteUser
2. HTTP Methods Have Meaning
| Method | Purpose | Idempotent | Safe | Request Body |
|---|---|---|---|---|
| GET | Read | ✅ | ✅ | No |
| POST | Create | ❌ | ❌ | Yes |
| PUT | Replace | ✅ | ❌ | Yes |
| PATCH | Partial update | ❌ | ❌ | Yes |
| DELETE | Remove | ✅ | ❌ | No |
3. Status Codes Tell the Story
| Code | When | Example |
|---|---|---|
| 200 | Success with body | GET returns resource |
| 201 | Created | POST creates new resource |
| 204 | Success, no body | DELETE succeeds |
| 400 | Client sent bad data | Malformed JSON |
| 401 | Not authenticated | Missing/invalid token |
| 403 | Authenticated but not authorized | Wrong role |
| 404 | Resource doesn't exist | Invalid ID |
| 409 | Conflict | Duplicate email |
| 422 | Valid JSON, invalid content | Email format wrong |
| 429 | Rate limited | Too many requests |
| 500 | Server error | Unhandled exception |
4. Error Responses Are Structured
{
"error": "ValidationError",
"code": "INVALID_EMAIL",
"message": "Email address is not valid",
"details": {
"field": "email",
"value": "not-an-email",
"constraint": "Must be a valid email format"
}
}
Rules:
- Same envelope for every error
- Machine-readable
codefor client logic - Human-readable
messagefor display detailsfor field-level validation errors- NEVER include stack traces in production
5. Always Paginate Collections
GET /api/users?page=2&page_size=20
Response:
{
"items": [...],
"total": 243,
"page": 2,
"page_size": 20,
"pages": 13
}
For GraphQL, use cursor-based pagination (Relay spec):
type UserConnection {
edges: [UserEdge!]!
pageInfo: PageInfo!
totalCount: Int!
}
6. Version From Day One
| Strategy | URL | Header | Query |
|---|---|---|---|
| Example | /api/v1/users | Accept: application/vnd.api+json; version=1 | /api/users?version=1 |
| Pros | Simple, visible | Clean URLs | Simple to add |
| Cons | URL pollution | Hidden from browsers | Caching complexity |
| Best for | Most APIs | Internal APIs | Quick prototypes |
7. Rate Limit Everything Public
Every public endpoint must return rate limit headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 42
X-RateLimit-Reset: 1625097600
API Design Checklist
Before implementing any endpoint:
- Resource name is a plural noun
- HTTP method matches the operation semantics
- Request/response schemas are defined (contract-first)
- Error responses use consistent envelope
- Pagination is implemented for collection endpoints
- Authentication and authorization rules are specified
- Rate limiting is configured
- API version is specified
- Input validation rules are documented per field
Anti-Patterns
| Don't | Do |
|---|---|
Verbs in URLs (/getUser) | Nouns + HTTP methods (GET /users) |
| 200 for everything | Correct status codes per operation |
| Generic errors ("Something went wrong") | Structured errors with codes |
| Return all fields always | Support field selection or use GraphQL |
| Nest resources >2 levels deep | /users/{id}/orders max; flatten after that |
| Ignore backward compatibility | Version APIs; deprecation headers before removal |
Extended Reference
See resources/implementation-playbook.md for:
- Full pagination implementation (FastAPI)
- HATEOAS patterns
- GraphQL schema design with Relay-style connections
- DataLoader patterns for N+1 prevention
- Complete code templates
When not to use it
- →Framework-specific implementation
Limitations
- →Not for existing APIs that cannot be versioned
How it compares
It focuses on API contract design rather than implementation details.
Compared to similar skills
api-design-principles side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| api-design-principles (this skill) | 0 | 3mo | No flags | Intermediate |
| openapi-spec-generation | 22 | 2mo | No flags | Intermediate |
| microsoft-code-reference | 7 | 5mo | Review | Beginner |
| openai-knowledge | 5 | 4mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by RepairYourTech
View all by RepairYourTech →You might also like
openapi-spec-generation
wshobson
Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns. Use when creating API documentation, generating SDKs, or ensuring API contract compliance.
microsoft-code-reference
github
Look up Microsoft API references, find working code samples, and verify SDK code is correct. Use when working with Azure SDKs, .NET libraries, or Microsoft APIs—to find the right method, check parameters, get working examples, or troubleshoot errors. Catches hallucinated methods, wrong signatures, and deprecated patterns by querying official docs.
openai-knowledge
openai
Use when working with the OpenAI API (Responses API) or OpenAI platform features (tools, streaming, Realtime API, auth, models, rate limits, MCP) and you need authoritative, up-to-date documentation (schemas, examples, limits, edge cases). Prefer the OpenAI Developer Documentation MCP server tools when available; otherwise guide the user to enable `openaiDeveloperDocs`.
agent-docs-api-openapi
ruvnet
Agent skill for docs-api-openapi - invoke with $agent-docs-api-openapi
openai-docs
openai
Use when the user asks how to build with OpenAI products or APIs and needs up-to-date official documentation with citations (for example: Codex, Responses API, Chat Completions, Apps SDK, Agents SDK, Realtime, model capabilities or limits); prioritize OpenAI docs MCP tools and restrict any fallback browsing to official OpenAI domains.
http-generate
spring-ai-alibaba
Generates HTTP request examples for Spring Boot Web interfaces according to task specification and saves them as .http files in module-generate.md directories