agentleFS
MindrallyMindrally/skills/fastapi-python/SKILL.md

fastapi-python

Skill275 starsChanged 34 days agoApache-2.0View on GitHub

Expert in FastAPI Python development with best practices for APIs and async operations

11 other projects use a version of this, 11 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use fastapi-templates and python-performance-optimization.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • xfstudioSkill

    fastapi-templates

    Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

    Also in 3 projects that use this

  • AJBcodingSkill

    python-performance-optimization

    Profile and optimize Python code using cProfile, memory profilers, and performance best practices. Use when debugging slow Python code, optimizing bottlenecks, or improving application performance.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

12 rules. 10 are common, 0 are distinctive, and 2 are very specific to this project.

  • 10

    Common

    Most of the 11 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Common:

    Write concise, technical responses with accurate Python examples

    line 15
  2. Very specific:

    Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission)

    line 18
  3. Common:

    Follow the RORO (Receive an Object, Return an Object) pattern

    line 21
  4. Very specific:

    Use def for pure functions, async def for asynchronous operations

    line 25
  5. Common:

    Use type hints for all function signatures.

    line 26
  6. Common:

    Write concise one-line conditional syntax

    line 29
  7. Common:

    Place happy path logic last

    line 35
  8. Common:

    Avoid unnecessary else statements.

    line 36
  9. Common:

    Use functional components (plain functions) and Pydantic models for input validation

    line 42
  10. Common:

    Prefer lifespan context managers for managing startup and shutdown events

    line 44
  11. Common:

    Use HTTPException for expected errors and model them as specific HTTP responses

    line 46
  12. Common:

    Use lazy loading for large datasets

    line 54

“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

FastAPI Python

You are an expert in FastAPI and Python backend development.

Key Principles

  • Write concise, technical responses with accurate Python examples
  • Favor functional, declarative programming over class-based approaches
  • Prioritize modularization to eliminate code duplication
  • Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission)
  • Employ lowercase with underscores for file/directory naming (e.g., routers/user_routes.py)
  • Export routes and utilities explicitly
  • Follow the RORO (Receive an Object, Return an Object) pattern

Python/FastAPI Standards

  • Use def for pure functions, async def for asynchronous operations
  • Use type hints for all function signatures. Prefer Pydantic models over raw dictionaries
  • Structure: exported router, sub-routes, utilities, static content, types (models, schemas)
  • Omit curly braces for single-line conditionals
  • Write concise one-line conditional syntax

Error Handling

  • Handle edge cases at function entry points
  • Employ early returns for error conditions
  • Place happy path logic last
  • Avoid unnecessary else statements; use if-return patterns
  • Implement guard clauses for preconditions
  • Provide proper error logging and user-friendly messaging

FastAPI-Specific Guidelines

  • Use functional components (plain functions) and Pydantic models for input validation
  • Declare routes with clear return type annotations
  • Prefer lifespan context managers for managing startup and shutdown events
  • Leverage middleware for logging, error monitoring, and optimization
  • Use HTTPException for expected errors and model them as specific HTTP responses
  • Apply Pydantic's BaseModel consistently for validation

Performance Optimization

  • Minimize blocking I/O; use async for all database and API calls
  • Implement caching with Redis or in-memory stores
  • Optimize Pydantic serialization/deserialization
  • Use lazy loading for large datasets

Key Conventions

  1. Rely on FastAPI's dependency injection system
  2. Prioritize API performance metrics (response time, latency, throughput)
  3. Structure routes and dependencies for readability and maintainability

Dependencies

FastAPI, Pydantic v2, asyncpg/aiomysql, SQLAlchemy 2.0

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.