API Development & Design — Quick Reference
This skill provides execution-ready patterns for designing, implementing, and documenting production-grade APIs. Claude should apply these patterns when users need REST API design, GraphQL schemas, OpenAPI specifications, API versioning, authentication flows, or API documentation.
Modern Best Practices (2025): OpenAPI 3.1, GraphQL Federation, gRPC for high-performance services, API-first development, contract testing, API gateways, rate limiting with Redis, JWT/OAuth2 patterns, and docs-as-code workflows.
When to Use This Skill
Claude should invoke this skill when a user requests:
- REST API design and endpoint structure
- GraphQL schema design and resolver patterns
- gRPC service definitions and protocol buffers
- OpenAPI/Swagger specification creation
- API versioning strategies (URL, header, content negotiation)
- Authentication and authorization flows (JWT, OAuth2, API keys)
- Rate limiting, throttling, and quota management
- API pagination, filtering, and sorting patterns
- Error response standardization
- API documentation and developer portals
- API security best practices (OWASP API Security Top 10)
- API testing strategies (contract testing, mock servers)
- API gateway configuration and management
Quick Reference
| Task |
Pattern/Tool |
Key Elements |
When to Use |
| Design REST API |
RESTful Design |
Nouns (not verbs), HTTP methods, proper status codes |
Resource-based APIs, CRUD operations |
| Version API |
URL Versioning |
/api/v1/resource, /api/v2/resource |
Breaking changes, client migration |
| Paginate results |
Cursor-Based |
cursor=eyJpZCI6MTIzfQ&limit=20 |
Real-time data, large collections |
| Handle errors |
RFC 7807 Problem Details |
type, title, status, detail, errors[] |
Consistent error responses |
| Authenticate |
JWT Bearer |
Authorization: Bearer <token> |
Stateless auth, microservices |
| Rate limit |
Token Bucket |
X-RateLimit-* headers, 429 responses |
Prevent abuse, fair usage |
| Document API |
OpenAPI 3.1 |
Swagger UI, Redoc, code samples |
Interactive docs, client SDKs |
| Flexible queries |
GraphQL |
Schema-first, resolvers, DataLoader |
Client-driven data fetching |
| High-performance |
gRPC + Protobuf |
Binary protocol, streaming |
Internal microservices |
Decision Tree: Choosing API Style
User needs: [API Type]
├─ Public API for third parties?
│ └─ REST with OpenAPI docs (broad compatibility)
│
├─ Internal microservices?
│ ├─ High throughput required? → **gRPC** (binary, fast)
│ └─ Simple CRUD? → **REST** (easy to debug)
│
├─ Client needs flexible queries?
│ ├─ Real-time updates? → **GraphQL Subscriptions** or **WebSockets**
│ └─ Complex data fetching? → **GraphQL** (avoid over-fetching)
│
├─ Mobile/web clients?
│ ├─ Many entity types? → **GraphQL** (single endpoint)
│ └─ Simple resources? → **REST** (cacheable)
│
└─ Streaming or bidirectional?
└─ **gRPC** (HTTP/2 streaming) or **WebSockets**
Navigation: Core API Patterns
RESTful API Design
Resource: resources/restful-design-patterns.md
- Resource-based URLs with proper HTTP methods (GET, POST, PUT, PATCH, DELETE)
- HTTP status code semantics (200, 201, 404, 422, 500)
- Idempotency guarantees (GET, PUT, DELETE)
- Stateless design principles
- URL structure best practices (collection vs resource endpoints)
- Nested resources and action endpoints
Pagination, Filtering & Sorting
Resource: resources/pagination-filtering.md
- Offset-based pagination (simple, static datasets)
- Cursor-based pagination (real-time feeds, recommended)
- Page-based pagination (UI with page numbers)
- Query parameter filtering with operators (
_gt, _contains, _in)
- Multi-field sorting with direction (
-created_at)
- Performance optimization with indexes
Error Handling
Resource: resources/error-handling-patterns.md
- RFC 7807 Problem Details standard
- HTTP status code reference (4xx client errors, 5xx server errors)
- Field-level validation errors
- Trace IDs for debugging
- Consistent error format across endpoints
- Security-safe error messages (no stack traces in production)
Authentication & Authorization
Resource: resources/authentication-patterns.md
- JWT (JSON Web Tokens) with refresh token rotation
- OAuth2 Authorization Code Flow for third-party auth
- API Key authentication for server-to-server
- RBAC (Role-Based Access Control)
- ABAC (Attribute-Based Access Control)
- Resource-based authorization (user-owned resources)
Rate Limiting & Throttling
Resource: resources/rate-limiting-patterns.md
- Token Bucket algorithm (recommended, allows bursts)
- Fixed Window vs Sliding Window
- Rate limit headers (
X-RateLimit-*)
- Tiered rate limits (free, paid, enterprise)
- Redis-based distributed rate limiting
- Per-user, per-endpoint, and per-API-key strategies
Navigation: Extended Resources
API Design & Best Practices
- api-design-best-practices.md - Comprehensive API design principles
- versioning-strategies.md - URL, header, and query parameter versioning
- api-security-checklist.md - OWASP API Security Top 10
GraphQL & gRPC
- graphql-patterns.md - Schema design, resolvers, N+1 queries, DataLoader
- gRPC patterns - See software-backend for Protocol Buffers and service definitions
OpenAPI & Documentation
- openapi-guide.md - OpenAPI 3.1 specifications, Swagger UI, Redoc
- Templates: templates/openapi-template.yaml - Complete OpenAPI spec example
LLM/Agent API Patterns
- llm-agent-api-contracts.md - Streaming, long-running jobs, safety guardrails, observability
Navigation: Templates
Production-ready, copy-paste API implementations with authentication, database, validation, and docs.
Framework-Specific Templates
FastAPI (Python): templates/fastapi/fastapi-complete-api.md
- Async/await, Pydantic v2, JWT auth, SQLAlchemy 2.0, pagination, OpenAPI docs
Express.js (Node/TypeScript): templates/express-nodejs/express-complete-api.md
- TypeScript, Zod validation, Prisma ORM, JWT refresh tokens, rate limiting
Django REST Framework: templates/django-rest/django-rest-complete-api.md
- ViewSets, serializers, Simple JWT, permissions, DRF filtering/pagination
Spring Boot (Java): templates/spring-boot/spring-boot-complete-api.md
- Spring Security JWT, Spring Data JPA, Bean Validation, Springdoc OpenAPI
Cross-Platform Patterns
- api-patterns-universal.md - Universal patterns for all frameworks
- Authentication strategies, pagination, caching, versioning, validation
External Resources
See data/sources.json for:
- Official REST, GraphQL, gRPC documentation
- OpenAPI/Swagger tools and validators
- API design style guides (Google, Microsoft, Stripe)
- Security standards (OWASP API Security Top 10)
- Testing tools (Postman, Insomnia, Paw)
Quick Decision Matrix
| Scenario |
Recommendation |
| Public API for third parties |
REST with OpenAPI docs |
| Internal microservices |
gRPC for performance, REST for simplicity |
| Client needs flexible queries |
GraphQL |
| Real-time updates |
GraphQL Subscriptions or WebSockets |
| Simple CRUD operations |
REST |
| Complex data fetching |
GraphQL |
| High throughput required |
gRPC |
| Mobile/web clients |
REST or GraphQL |
Anti-Patterns to Avoid
- Verbs in URLs:
/getUserById → /users/:id
- Ignoring HTTP methods: Using GET for mutations
- No versioning: Breaking changes without version bump
- Inconsistent error format: Different error structures per endpoint
- Missing pagination: Returning unbounded lists
- No rate limiting: Allowing unlimited requests
- Poor documentation: Missing examples, outdated specs
- Security by obscurity: Not using HTTPS, weak auth
Related Skills
This skill works best when combined with other specialized skills:
Backend Development
- software-backend - Production backend patterns (Node.js, Python, Java frameworks)
- Use when implementing API server infrastructure
- Covers database integration, middleware, error handling
Security & Authentication
- software-security-appsec - Application security patterns
- Critical for securing API endpoints
- Covers OWASP vulnerabilities, authentication flows, input validation
Database & Data Layer
- data-sql-optimization - SQL optimization and database patterns
- Essential for API performance (query optimization, indexing)
- Use when APIs interact with relational databases
Testing & Quality
- testing-automation - Test strategy and automation
- Contract testing for API specifications
- Integration testing for API endpoints
DevOps & Deployment
- ops-devops-platform - Platform engineering and deployment
- API gateway configuration
- CI/CD pipelines for API deployments
Documentation
- docs-technical-writing - Technical documentation standards
- API reference documentation structure
- Complements OpenAPI auto-generated docs
Architecture
Performance & Observability
Usage Notes
For Claude:
- Apply RESTful principles by default unless user requests GraphQL/gRPC
- Always include pagination for list endpoints
- Use RFC 7807 format for error responses
- Include authentication in all templates (JWT or API keys)
- Reference framework-specific templates for complete implementations
- Link to relevant resources for deep-dive guidance
Success Criteria: APIs are discoverable, consistent, well-documented, secure, and follow HTTP/GraphQL semantics correctly.
1---2name: dev-api-design3description: Production-grade API design patterns for REST, GraphQL, and gRPC. Covers API architecture, OpenAPI/Swagger specs, versioning strategies, authentication flows, rate limiting, pagination, error handling, and documentation best practices for modern API development.4---5
6# API Development & Design — Quick Reference
7
8This skill provides execution-ready patterns for designing, implementing, and documenting production-grade APIs. Claude should apply these patterns when users need REST API design, GraphQL schemas, OpenAPI specifications, API versioning, authentication flows, or API documentation.
9
10**Modern Best Practices (2025)**: OpenAPI 3.1, GraphQL Federation, gRPC for high-performance services, API-first development, contract testing, API gateways, rate limiting with Redis, JWT/OAuth2 patterns, and docs-as-code workflows.
11
12---
13
14## When to Use This Skill
15
16Claude should invoke this skill when a user requests:
17
18- REST API design and endpoint structure
19- GraphQL schema design and resolver patterns
20- gRPC service definitions and protocol buffers
21- OpenAPI/Swagger specification creation
22- API versioning strategies (URL, header, content negotiation)
23- Authentication and authorization flows (JWT, OAuth2, API keys)
24- Rate limiting, throttling, and quota management
25- API pagination, filtering, and sorting patterns
26- Error response standardization
27- API documentation and developer portals
28- API security best practices (OWASP API Security Top 10)
29- API testing strategies (contract testing, mock servers)
30- API gateway configuration and management
31
32---
33
34## Quick Reference
35
36| Task | Pattern/Tool | Key Elements | When to Use |
37|------|--------------|--------------|-------------|
38| **Design REST API** | RESTful Design | Nouns (not verbs), HTTP methods, proper status codes | Resource-based APIs, CRUD operations |
39| **Version API** | URL Versioning | `/api/v1/resource`, `/api/v2/resource` | Breaking changes, client migration |
40| **Paginate results** | Cursor-Based | `cursor=eyJpZCI6MTIzfQ&limit=20` | Real-time data, large collections |
41| **Handle errors** | RFC 7807 Problem Details | `type`, `title`, `status`, `detail`, `errors[]` | Consistent error responses |
42| **Authenticate** | JWT Bearer | `Authorization: Bearer <token>` | Stateless auth, microservices |
43| **Rate limit** | Token Bucket | `X-RateLimit-*` headers, 429 responses | Prevent abuse, fair usage |
44| **Document API** | OpenAPI 3.1 | Swagger UI, Redoc, code samples | Interactive docs, client SDKs |
45| **Flexible queries** | GraphQL | Schema-first, resolvers, DataLoader | Client-driven data fetching |
46| **High-performance** | gRPC + Protobuf | Binary protocol, streaming | Internal microservices |
47
48---
49
50## Decision Tree: Choosing API Style
51
52```text
53User needs: [API Type]
54 ├─ Public API for third parties?
55 │ └─ REST with OpenAPI docs (broad compatibility)
56 │
57 ├─ Internal microservices?
58 │ ├─ High throughput required? → **gRPC** (binary, fast)
59 │ └─ Simple CRUD? → **REST** (easy to debug)
60 │
61 ├─ Client needs flexible queries?
62 │ ├─ Real-time updates? → **GraphQL Subscriptions** or **WebSockets**
63 │ └─ Complex data fetching? → **GraphQL** (avoid over-fetching)
64 │
65 ├─ Mobile/web clients?
66 │ ├─ Many entity types? → **GraphQL** (single endpoint)
67 │ └─ Simple resources? → **REST** (cacheable)
68 │
69 └─ Streaming or bidirectional?
70 └─ **gRPC** (HTTP/2 streaming) or **WebSockets**
71```
72
73---
74
75## Navigation: Core API Patterns
76
77### RESTful API Design
78
79**Resource:** [resources/restful-design-patterns.md](resources/restful-design-patterns.md)
80
81- Resource-based URLs with proper HTTP methods (GET, POST, PUT, PATCH, DELETE)
82- HTTP status code semantics (200, 201, 404, 422, 500)
83- Idempotency guarantees (GET, PUT, DELETE)
84- Stateless design principles
85- URL structure best practices (collection vs resource endpoints)
86- Nested resources and action endpoints
87
88---
89
90### Pagination, Filtering & Sorting
91
92**Resource:** [resources/pagination-filtering.md](resources/pagination-filtering.md)
93
94- Offset-based pagination (simple, static datasets)
95- Cursor-based pagination (real-time feeds, recommended)
96- Page-based pagination (UI with page numbers)
97- Query parameter filtering with operators (`_gt`, `_contains`, `_in`)
98- Multi-field sorting with direction (`-created_at`)
99- Performance optimization with indexes
100
101---
102
103### Error Handling
104
105**Resource:** [resources/error-handling-patterns.md](resources/error-handling-patterns.md)
106
107- RFC 7807 Problem Details standard
108- HTTP status code reference (4xx client errors, 5xx server errors)
109- Field-level validation errors
110- Trace IDs for debugging
111- Consistent error format across endpoints
112- Security-safe error messages (no stack traces in production)
113
114---
115
116### Authentication & Authorization
117
118**Resource:** [resources/authentication-patterns.md](resources/authentication-patterns.md)
119
120- JWT (JSON Web Tokens) with refresh token rotation
121- OAuth2 Authorization Code Flow for third-party auth
122- API Key authentication for server-to-server
123- RBAC (Role-Based Access Control)
124- ABAC (Attribute-Based Access Control)
125- Resource-based authorization (user-owned resources)
126
127---
128
129### Rate Limiting & Throttling
130
131**Resource:** [resources/rate-limiting-patterns.md](resources/rate-limiting-patterns.md)
132
133- Token Bucket algorithm (recommended, allows bursts)
134- Fixed Window vs Sliding Window
135- Rate limit headers (`X-RateLimit-*`)
136- Tiered rate limits (free, paid, enterprise)
137- Redis-based distributed rate limiting
138- Per-user, per-endpoint, and per-API-key strategies
139
140---
141
142## Navigation: Extended Resources
143
144### API Design & Best Practices
145
146- **[api-design-best-practices.md](resources/api-design-best-practices.md)** - Comprehensive API design principles
147- **[versioning-strategies.md](resources/versioning-strategies.md)** - URL, header, and query parameter versioning
148- **[api-security-checklist.md](resources/api-security-checklist.md)** - OWASP API Security Top 10
149
150### GraphQL & gRPC
151
152- **[graphql-patterns.md](resources/graphql-patterns.md)** - Schema design, resolvers, N+1 queries, DataLoader
153- **gRPC patterns** - See [software-backend](../software-backend/SKILL.md) for Protocol Buffers and service definitions
154
155### OpenAPI & Documentation
156
157- **[openapi-guide.md](resources/openapi-guide.md)** - OpenAPI 3.1 specifications, Swagger UI, Redoc
158- **Templates:** [templates/openapi-template.yaml](templates/openapi-template.yaml) - Complete OpenAPI spec example
159
160### LLM/Agent API Patterns
161
162- **[llm-agent-api-contracts.md](resources/llm-agent-api-contracts.md)** - Streaming, long-running jobs, safety guardrails, observability
163
164---
165
166## Navigation: Templates
167
168Production-ready, copy-paste API implementations with authentication, database, validation, and docs.
169
170### Framework-Specific Templates
171
172- **FastAPI (Python)**: [templates/fastapi/fastapi-complete-api.md](templates/fastapi/fastapi-complete-api.md)
173 - Async/await, Pydantic v2, JWT auth, SQLAlchemy 2.0, pagination, OpenAPI docs
174
175- **Express.js (Node/TypeScript)**: [templates/express-nodejs/express-complete-api.md](templates/express-nodejs/express-complete-api.md)
176 - TypeScript, Zod validation, Prisma ORM, JWT refresh tokens, rate limiting
177
178- **Django REST Framework**: [templates/django-rest/django-rest-complete-api.md](templates/django-rest/django-rest-complete-api.md)
179 - ViewSets, serializers, Simple JWT, permissions, DRF filtering/pagination
180
181- **Spring Boot (Java)**: [templates/spring-boot/spring-boot-complete-api.md](templates/spring-boot/spring-boot-complete-api.md)
182 - Spring Security JWT, Spring Data JPA, Bean Validation, Springdoc OpenAPI
183
184### Cross-Platform Patterns
185
186- **[api-patterns-universal.md](templates/cross-platform/api-patterns-universal.md)** - Universal patterns for all frameworks
187 - Authentication strategies, pagination, caching, versioning, validation
188
189---
190
191## External Resources
192
193See [data/sources.json](data/sources.json) for:
194
195- Official REST, GraphQL, gRPC documentation
196- OpenAPI/Swagger tools and validators
197- API design style guides (Google, Microsoft, Stripe)
198- Security standards (OWASP API Security Top 10)
199- Testing tools (Postman, Insomnia, Paw)
200
201---
202
203## Quick Decision Matrix
204
205| Scenario | Recommendation |
206|----------|----------------|
207| Public API for third parties | REST with OpenAPI docs |
208| Internal microservices | gRPC for performance, REST for simplicity |
209| Client needs flexible queries | GraphQL |
210| Real-time updates | GraphQL Subscriptions or WebSockets |
211| Simple CRUD operations | REST |
212| Complex data fetching | GraphQL |
213| High throughput required | gRPC |
214| Mobile/web clients | REST or GraphQL |
215
216---
217
218## Anti-Patterns to Avoid
219
220- **Verbs in URLs**: `/getUserById` → `/users/:id`
221- **Ignoring HTTP methods**: Using GET for mutations
222- **No versioning**: Breaking changes without version bump
223- **Inconsistent error format**: Different error structures per endpoint
224- **Missing pagination**: Returning unbounded lists
225- **No rate limiting**: Allowing unlimited requests
226- **Poor documentation**: Missing examples, outdated specs
227- **Security by obscurity**: Not using HTTPS, weak auth
228
229---
230
231## Related Skills
232
233This skill works best when combined with other specialized skills:
234
235### Backend Development
236
237- **[software-backend](../software-backend/SKILL.md)** - Production backend patterns (Node.js, Python, Java frameworks)
238 - Use when implementing API server infrastructure
239 - Covers database integration, middleware, error handling
240
241### Security & Authentication
242
243- **[software-security-appsec](../software-security-appsec/SKILL.md)** - Application security patterns
244 - Critical for securing API endpoints
245 - Covers OWASP vulnerabilities, authentication flows, input validation
246
247### Database & Data Layer
248
249- **[data-sql-optimization](../data-sql-optimization/SKILL.md)** - SQL optimization and database patterns
250 - Essential for API performance (query optimization, indexing)
251 - Use when APIs interact with relational databases
252
253### Testing & Quality
254
255- **[testing-automation](../testing-automation/SKILL.md)** - Test strategy and automation
256 - Contract testing for API specifications
257 - Integration testing for API endpoints
258
259### DevOps & Deployment
260
261- **[ops-devops-platform](../ops-devops-platform/SKILL.md)** - Platform engineering and deployment
262 - API gateway configuration
263 - CI/CD pipelines for API deployments
264
265### Documentation
266
267- **[docs-technical-writing](../docs-technical-writing/SKILL.md)** - Technical documentation standards
268 - API reference documentation structure
269 - Complements OpenAPI auto-generated docs
270
271### Architecture
272
273- **[software-architecture-design](../software-architecture-design/SKILL.md)** - System design patterns
274 - Microservices architecture with APIs
275 - API gateway patterns, service mesh integration
276
277### Performance & Observability
278
279- **[quality-observability-performance](../quality-observability-performance/SKILL.md)** - Performance optimization and monitoring
280 - API latency monitoring, distributed tracing
281 - Performance budgets for API endpoints
282
283---
284
285## Usage Notes
286
287**For Claude:**
288
289- Apply RESTful principles by default unless user requests GraphQL/gRPC
290- Always include pagination for list endpoints
291- Use RFC 7807 format for error responses
292- Include authentication in all templates (JWT or API keys)
293- Reference framework-specific templates for complete implementations
294- Link to relevant resources for deep-dive guidance
295
296**Success Criteria:** APIs are discoverable, consistent, well-documented, secure, and follow HTTP/GraphQL semantics correctly.