fastapi

Refactor FastAPI endpoints with Annotated parameters, response models, and router-level dependencies.

Updated Nov 24, 2025
One-click install
npx skills add https://github.com/oornnery/portfolio --skill fastapi-oornnery
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi
Source: https://github.com/oornnery/portfolio/tree/main/.agents/skills/fastapi
Command: npx skills add https://github.com/oornnery/portfolio --skill fastapi-oornnery

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides clear, up-to-date conventions and actionable guidance to avoid common FastAPI and Pydantic pitfalls, keep APIs secure and performant, and make codebases consistent and maintainable across versions.

Core Features & Use Cases

  • Typed Parameters & Dependencies: Prefer Annotated types for parameters and dependencies to keep signatures explicit and reusable.
  • Response Modeling & Safety: Encourage return types or response_model to prevent leaking sensitive data and to leverage Pydantic serialization performance.
  • Router & Async Patterns: Recommend router-level configuration, appropriate async vs sync usage, streaming patterns, and dependency lifecycles for production services.
  • Tooling & Ecosystem: Guidance on using tooling such as linters, type checkers, Asyncer, SQLModel, and HTTPX for robust development workflows.

Quick Start

Use the fastapi skill to refactor an endpoint to use Annotated parameters, an explicit response model, and a router-level dependency for shared authentication.

Frequently Asked Questions about fastapi

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

FAQPage Schema
How do I use Annotated parameter types for dependency injection in FastAPI?

Use Annotated parameter types for FastAPI dependency injection to keep function signatures explicit and reusable. This approach replaces older Depends defaults, improving code readability and ensuring consistent dependency management across your API endpoints.

How do I prevent sensitive data leaking from FastAPI response models?

Prevent sensitive data leaking in FastAPI response models by explicitly defining return types or setting response_model. This enforces strict Pydantic serialization, ensuring only specified fields are exposed to clients while maintaining optimal API performance.

What is the best way to organize routers and async patterns in FastAPI?

Organize FastAPI routers and async patterns by applying router-level configuration and appropriate async versus sync usage. This ensures production services handle streaming and dependency lifecycles efficiently, avoiding common asynchronous execution bottlenecks.

Does FastAPI work with SQLModel and HTTPX for production development?

FastAPI works seamlessly with SQLModel and HTTPX for production development. Leveraging these tools alongside linters, type checkers, and Asyncer establishes a robust workflow for database integration and asynchronous HTTP client operations.

Why should I use Annotated dependencies instead of default Depends in FastAPI?

Use Annotated dependencies instead of default Depends in FastAPI to make parameter declarations explicit and reusable. This modern pattern enhances type checking, reduces signature clutter, and standardizes dependency injection across complex router architectures.