home / skills / ehtbanton / claudeskillsrepo / fastapi-endpoint-generator

fastapi-endpoint-generator skill

/fastapi-endpoint-generator

This skill generates complete FastAPI router files with async CRUD endpoints and Pydantic models for rapid backend API development.

npx playbooks add skill ehtbanton/claudeskillsrepo --skill fastapi-endpoint-generator

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
767 B
---
name: fastapi-endpoint-generator
description: Generate FastAPI endpoint files with Pydantic models, dependency injection, and async handlers. Triggers on "create fastapi endpoint", "generate fastapi router", "python API endpoint", "fastapi route".
---

# FastAPI Endpoint Generator

Generate FastAPI router files with Pydantic models, dependency injection, and async handlers.

## Output Requirements

**File Output:** `*.py` router files
**Format:** Valid Python 3.10+ with FastAPI
**Standards:** FastAPI best practices

## When Invoked

Immediately generate a complete FastAPI router with CRUD endpoints and Pydantic models.

## Example Invocations

**Prompt:** "Create FastAPI router for products"
**Output:** Complete `products.py` with async CRUD endpoints.

Overview

This skill generates complete FastAPI router files including Pydantic models, dependency injection stubs, and async CRUD handlers. It produces ready-to-use Python 3.10+ code following FastAPI best practices so you can drop the file into a project and iterate quickly.

How this skill works

When invoked with a resource name or prompt like "create fastapi endpoint" it synthesizes a single .py router file containing Pydantic schemas, a dependency-injected service interface, and async route handlers (create, read, update, delete, list). The generated code targets idiomatic FastAPI patterns: APIRouter, dependency injection via Depends, response models, status codes, and type annotations.

When to use it

  • Scaffolding a new resource API quickly (e.g., products, users, orders)
  • Prototyping endpoints to validate frontend integration fast
  • Creating consistent CRUD routes across multiple services
  • Generating a starting point before wiring database or business logic
  • Onboarding new team members with uniform route structure

Best practices

  • Review and customize generated service/dependency stubs to connect to your database or domain logic
  • Keep business logic out of route handlers; implement it in injected services
  • Adjust Pydantic models to include validation, field defaults, and ORM mode as needed
  • Add tests and API documentation examples once endpoints are wired
  • Use background tasks or event-driven patterns for long-running operations instead of blocking handlers

Example use cases

  • Create a products.py router with ProductCreate/ProductRead models and async CRUD handlers
  • Generate a users.py router with dependency placeholders for authentication and user service
  • Spin up a temporary endpoints file for frontend testing while backend logic is implemented
  • Standardize new microservice entry points by using the same generated layout across repos
  • Produce example endpoints to demonstrate integration patterns for junior developers

FAQ

What Python/FastAPI version does the output target?

The generated code targets Python 3.10+ and modern FastAPI idioms (APIRouter, async handlers, Pydantic v1/v2-compatible patterns).

Does it include database implementation?

No. It generates dependency-injected service stubs you should implement to connect your ORM or database layer.