AP

api-design-patterns

Guides RESTful API design. Use this for structured endpoints, validation, and error handling patterns.

Install

mkdir -p .claude/skills/api-design-patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/18835" && unzip -o skill.zip -d .claude/skills/api-design-patterns && rm skill.zip

Installs to .claude/skills/api-design-patterns

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.

Apply RESTful and FastAPI design best practices for endpoints, error handling, validation, and DI. Use when designing APIs, creating new endpoints, or reviewing API structure with backend-architect.
198 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Apply RESTful conventions for endpoint naming
  • Use appropriate HTTP status codes for API responses
  • Implement consistent error response shapes
  • Validate request models using Pydantic v2
  • Structure FastAPI applications with routers and dependencies

How it works

This skill provides guidelines and examples for designing APIs following RESTful principles and FastAPI best practices.

Inputs & outputs

You give it
API design requirements or existing API structure
You get back
Recommendations for RESTful endpoints, error handling, validation, and FastAPI structure

When to use api-design-patterns

  • Structure new API endpoints
  • Design RESTful resources
  • Implement standard error handling
  • Refactor FastAPI router logic

About this skill

API Design Patterns (FastAPI)

Quick Reference

REST Conventions

  • Nouns, not verbs: /users not /get_users
  • Plural resources: /products not /product
  • Nested for relationships: /users/123/orders for user's orders
  • HTTP methods: GET (read), POST (create), PUT/PATCH (update), DELETE (remove)

Status Codes

Use starlette.status (e.g. status.HTTP_200_OK). Return via HTTPException or response class.

CodeUse
200Success (GET, PUT, PATCH)
201Created (POST)
204No content (DELETE)
400Bad request (validation failed)
401Unauthorized (not authenticated)
403Forbidden (authenticated but not allowed)
404Not found
409Conflict (duplicate, state conflict)
422Unprocessable (FastAPI default for Pydantic validation errors)
500Server error

Error Response Shape

Keep consistent; e.g. use FastAPI exception handlers to return:

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Human-readable message",
    "details": [{ "field": "email", "reason": "Invalid format" }]
  }
}

Use HTTPException(status_code=..., detail=...); never expose stack traces to client.

Validation

  • Validate at boundary with Pydantic v2 request models (body, query, path)
  • FastAPI returns 422 with field-level details for validation errors
  • Use Pydantic validators and model_dump for response shape

Structure

  • Routers: Group routes by resource; use APIRouter(prefix="/users", tags=["users"])
  • Dependencies: Use Depends() for DB session, current user, auth; keep handlers thin
  • Async: Use async route handlers and async service functions for I/O

Security

  • Never expose stack traces in production
  • Log errors server-side (structlog); return generic messages to client
  • Rate limit public or auth endpoints where applicable
  • Validate content-type and body size; use Pydantic for request body limits

When not to use it

  • When designing APIs for non-FastAPI frameworks
  • When the user asks for implementation details not related to API design
  • When the user asks to expose stack traces to clients

Limitations

  • Specific to FastAPI framework
  • Does not cover API design for other frameworks
  • Does not expose stack traces to clients

How it compares

This skill offers a structured approach to API design within FastAPI, promoting consistency and maintainability compared to ad-hoc development.

Compared to similar skills

api-design-patterns side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
api-design-patterns (this skill)014dNo flagsIntermediate
fastapi-templates5202moNo flagsIntermediate
fastapi-pro793moNo flagsAdvanced
fastapi-router-py512dNo flagsBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

5201,086

fastapi-pro

sickn33

Build high-performance async APIs with FastAPI, SQLAlchemy 2.0, and Pydantic V2. Master microservices, WebSockets, and modern Python async patterns. Use PROACTIVELY for FastAPI development, async optimization, or API architecture.

79181

fastapi-router-py

microsoft

Create FastAPI routers with CRUD operations, authentication dependencies, and proper response models. Use when building REST API endpoints, creating new routes, implementing CRUD operations, or adding authenticated endpoints in FastAPI applications.

525

pydantic-models-py

microsoft

Create Pydantic models following the multi-model pattern with Base, Create, Update, Response, and InDB variants. Use when defining API request/response schemas, database models, or data validation in Python applications using Pydantic v2.

325

backend-architect

sickn33

Expert backend architect specializing in scalable API design, microservices architecture, and distributed systems. Masters REST/GraphQL/gRPC APIs, event-driven architectures, service mesh patterns, and modern backend frameworks. Handles service boundary definition, inter-service communication, resilience patterns, and observability. Use PROACTIVELY when creating new backend services or APIs.

1014

supabase-python

alinaqi

FastAPI with Supabase and SQLAlchemy/SQLModel

05

Search skills

Search the agent skills registry