fastapi

FastAPI Best Practices

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "fastapi" with this command: npx skills add kprsnt2/mylocalcli/kprsnt2-mylocalcli-fastapi

FastAPI Best Practices

Project Structure

  • app/main.py - Application entry

  • app/routers/ - Route handlers

  • app/models/ - SQLAlchemy models

  • app/schemas/ - Pydantic schemas

  • app/services/ - Business logic

  • app/dependencies.py - Dependency injection

Pydantic Schemas

  • Use separate schemas for input/output

  • Use Field() for validation

  • Use model_validator for complex validation

  • Use Config for schema settings

Dependency Injection

  • Use Depends() for dependencies

  • Create reusable dependencies

  • Use yield for cleanup logic

  • Cache expensive dependencies

Async

  • Use async def for I/O operations

  • Use httpx for async HTTP

  • Use databases/SQLAlchemy async

  • Avoid blocking in async context

Performance

  • Use response_model for serialization

  • Enable response caching

  • Use background tasks

  • Stream large responses

  • Use connection pooling

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

testing

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

redis

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

api-design

No summary provided by upstream source.

Repository SourceNeeds Review