← Browse

@diegosouzapw/fastapi

B

FastAPI framework best practices including Pydantic schemas, dependency injection, and async patterns.

skillclaude

Install

agr install @diegosouzapw/fastapi --target claude

Writes 2 files into .claude/skills/, pinned to git-52e09b7c.

  • .claude/skills/fastapi/SKILL.md
  • .claude/skills/fastapi/metadata.json

Document


name: fastapi description: FastAPI framework best practices including Pydantic schemas, dependency injection, and async patterns. globs: ["/main.py", "/routers//*.py", "/schemas/**/*.py"] priority: 90 tags: ["framework"]

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

Trustgrade B

  • passBody integrity

    Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.

  • passType matchnot applicable to this artifact type

    Whether the artifact is really the kind of thing its metadata claims it is.

  • passFreshness

    How long since the source repository was last pushed to.

  • passPrompt injection

    Scans the artifact's own text for instructions aimed at your agent rather than at you.

  • warnLicenseno SPDX license detected

    Whether the source repository declares an SPDX license permissive enough to redistribute.

How the grade is calculated

Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:

  • Aevery check passed
  • Bone warning
  • Ctwo warnings
  • Dprompt injection or body integrity failed, or three warnings
  • Fone of those failed, and something else is wrong

These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.

Versions

  • git-52e09b7c64b82026-07-31