All skills
wshobson avatar

/api-design-principles

@be57c0b
by Seth Hobsonwshobson/agents40k stars
4,281

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.

Use this Skill: https://skilld.dev/gh/wshobson/agents/api-design-principles

This session only. Nothing lands on disk.

assetsapi-design-checklist.md

≈971 tokens on demand. Your agent reads this file only when SKILL.md points to it.

API Design Checklist

Pre-Implementation Review

Resource Design

  • Resources are nouns, not verbs
  • Plural names for collections
  • Consistent naming across all endpoints
  • Clear resource hierarchy (avoid deep nesting >2 levels)
  • All CRUD operations properly mapped to HTTP methods

HTTP Methods

  • GET for retrieval (safe, idempotent)
  • POST for creation
  • PUT for full replacement (idempotent)
  • PATCH for partial updates
  • DELETE for removal (idempotent)

Status Codes

  • 200 OK for successful GET/PATCH/PUT
  • 201 Created for POST
  • 204 No Content for DELETE
  • 400 Bad Request for malformed requests
  • 401 Unauthorized for missing auth
  • 403 Forbidden for insufficient permissions
  • 404 Not Found for missing resources
  • 422 Unprocessable Entity for validation errors
  • 429 Too Many Requests for rate limiting
  • 500 Internal Server Error for server issues

Pagination

  • All collection endpoints paginated
  • Default page size defined (e.g., 20)
  • Maximum page size enforced (e.g., 100)
  • Pagination metadata included (total, pages, etc.)
  • Cursor-based or offset-based pattern chosen

Filtering & Sorting

  • Query parameters for filtering
  • Sort parameter supported
  • Search parameter for full-text search
  • Field selection supported (sparse fieldsets)

Versioning

  • Versioning strategy defined (URL/header/query)
  • Version included in all endpoints
  • Deprecation policy documented

Error Handling

  • Consistent error response format
  • Detailed error messages
  • Field-level validation errors
  • Error codes for client handling
  • Timestamps in error responses

Authentication & Authorization

  • Authentication method defined (Bearer token, API key)
  • Authorization checks on all endpoints
  • 401 vs 403 used correctly
  • Token expiration handled

Rate Limiting

  • Rate limits defined per endpoint/user
  • Rate limit headers included
  • 429 status code for exceeded limits
  • Retry-After header provided

Documentation

  • OpenAPI/Swagger spec generated
  • All endpoints documented
  • Request/response examples provided
  • Error responses documented
  • Authentication flow documented

Testing

  • Unit tests for business logic
  • Integration tests for endpoints
  • Error scenarios tested
  • Edge cases covered
  • Performance tests for heavy endpoints

Security

  • Input validation on all fields
  • SQL injection prevention
  • XSS prevention
  • CORS configured correctly
  • HTTPS enforced
  • Sensitive data not in URLs
  • No secrets in responses

Performance

  • Database queries optimized
  • N+1 queries prevented
  • Caching strategy defined
  • Cache headers set appropriately
  • Large responses paginated

Monitoring

  • Logging implemented
  • Error tracking configured
  • Performance metrics collected
  • Health check endpoint available
  • Alerts configured for errors

GraphQL-Specific Checks

Schema Design

  • Schema-first approach used
  • Types properly defined
  • Non-null vs nullable decided
  • Interfaces/unions used appropriately
  • Custom scalars defined

Queries

  • Query depth limiting
  • Query complexity analysis
  • DataLoaders prevent N+1
  • Pagination pattern chosen (Relay/offset)

Mutations

  • Input types defined
  • Payload types with errors
  • Optimistic response support
  • Idempotency considered

Performance

  • DataLoader for all relationships
  • Query batching enabled
  • Persisted queries considered
  • Response caching implemented

Documentation

  • All fields documented
  • Deprecations marked
  • Examples provided
  • Schema introspection enabled

Source: SKILL.md on GitHub

No alerts15d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill provides a set of educational resources and templates for designing APIs using REST and GraphQL. It contains best practices, checklists, and code examples that incorporate security measures such as input validation, rate limiting, and CORS configuration. No malicious code or insecure patterns were detected.

  • Socket15d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer6mo

    5 files scanned · No issues

  • ZeroLeaks5mo

    1 finding · Score: 82/100

Signed by skilld at be57c0b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 4 months ago
  • Documentation
  • rest
  • graphql
  • api-design
  • versioning
  • http-methods
  • schema-design
  • pagination
  • error-handling

README badge

README badge for wshobson/agents/api-design-principles

Provides guidance on REST and GraphQL API design principles, covering resource-oriented architecture, schema-first development, versioning strategies, and best practices for each paradigm. Use when designing new APIs, establishing team standards, or reviewing API specifications.

Generated from the current SKILL.md.

Does this skill cover both REST and GraphQL API design?
Yes. The skill covers REST principles (resource-oriented architecture, HTTP methods, versioning) and GraphQL principles (schema-first development, queries, mutations, subscriptions).
What API versioning strategies does this skill describe?
The skill covers URL versioning (/api/v1), header versioning (Accept headers), and query parameter versioning (?version=1).
Does this skill include code examples or templates?
The skill provides pattern documentation in references/details.md and discusses best practices with specific examples like pagination strategies and DataLoader usage for GraphQL, but does not include runnable code templates.
Can I use this skill to review an existing API specification?
Yes. The skill is designed for reviewing API specifications before implementation, as well as for establishing design standards and refactoring existing APIs.

Generated from the current SKILL.md. These answers refresh after source changes.