fastapi

Enforce modern FastAPI best practices for clean, maintainable code.

3|Updated Jan 17, 2026
One-click install
npx skills add https://github.com/MehdiRtal/dotfiles --skill fastapi-mehdirtal
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi
Source: https://github.com/MehdiRtal/dotfiles/tree/main/dot_agents/skills/fastapi
Command: npx skills add https://github.com/MehdiRtal/dotfiles --skill fastapi-mehdirtal

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write clean, efficient, and up-to-date FastAPI code by enforcing best practices and leveraging the latest features.

Core Features & Use Cases

  • Best Practices Enforcement: Guides users on modern FastAPI patterns like Annotated for parameters and dependencies.
  • CLI Usage: Demonstrates how to use the fastapi CLI for development and production.
  • Response Modeling: Emphasizes the importance of return types and response_model for documentation, validation, and performance.
  • Router Conventions: Recommends best practices for including routers and applying shared dependencies.
  • Async/Sync Operations: Provides guidance on correctly using async and def for path operations and dependencies.
  • Streaming: Covers patterns for streaming JSON Lines, Server-Sent Events, and bytes.
  • Tooling Integration: Mentions helpful tools like uv, Ruff, and ty.
  • Library Recommendations: Suggests Asyncer, SQLModel, and HTTPX for enhanced development.

Quick Start

Use the fastapi skill to refactor the provided Python code to use Annotated for path parameters and dependencies.

Frequently Asked Questions about fastapi

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use Annotated for dependencies and path parameters in FastAPI?

Use the Annotated type hint for dependencies and path parameters in FastAPI to enforce modern conventions. This approach replaces older defaults, ensuring your API code remains clean and maintainable while improving type validation.

What is the best way to structure response models in FastAPI for validation?

Structuring response models in FastAPI requires defining explicit return types and using the response_model parameter. This ensures automatic documentation, strict data validation, and optimized performance for your API endpoints.

When should I use async def versus def for FastAPI path operations?

Use async def for FastAPI path operations when executing asynchronous code, and standard def for blocking operations. This distinction ensures correct async/sync operations, preventing performance bottlenecks in your web development workflow.

How do I stream JSON Lines and Server-Sent Events in a FastAPI application?

Stream JSON Lines, Server-Sent Events, and bytes in FastAPI by applying specific streaming patterns to your path operations. These methods enable efficient real-time data delivery for continuous API responses.

Does FastAPI work with Asyncer and SQLModel for database and sync operations?

FastAPI works seamlessly with Asyncer and SQLModel to enhance development workflows. Asyncer manages sync operations within async code, while SQLModel provides integrated database validation and modeling.