Index of every page on this site: llms.txt
All skills
mindrally avatar

/fastapi-python

@7682ca7
by mindrallymindrally/skills311 stars
45
Run it yourself

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

Use this Skill: https://skilld.dev/gh/mindrally/skills/fastapi-python

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈26 tokens for metadata: the name and description. ≈563 when used: this file.

Description uses 1.3% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈103 characters, or 1.3%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

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

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo5 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    This skill provides safe development guidelines and best practices for FastAPI and Python backend development.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

  • Runlayer8mo

    1 file scanned · No issues

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 7682ca7. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated last month
Other metadata
metadata
{
  "maintainer": "Mindrally",
  "source": "https://github.com/Mindrally/skills"
}

README badge

README badge for mindrally/skills/fastapi-python

Instructs Claude to write FastAPI Python backends following functional programming patterns, async-first design, and Pydantic validation. Covers routing, error handling with early returns, dependency injection, and performance optimization for async database operations.

Generated from the current SKILL.md.

Does this skill cover async database operations?
Yes. The skill emphasizes async/await patterns with asyncpg and aiomysql, and prioritizes minimizing blocking I/O across all database and API calls.
What Python version and FastAPI patterns does this assume?
The skill targets modern FastAPI with Pydantic v2, SQLAlchemy 2.0, and functional (non-class-based) route handlers with full type hints and dependency injection.
Does this cover error handling and validation?
Yes. It covers HTTPException usage, guard clauses with early returns, input validation via Pydantic models, and user-friendly error messaging strategies.
What about caching and performance optimization?
The skill includes guidance on Redis or in-memory caching, lazy loading for large datasets, and optimizing Pydantic serialization to reduce latency.

Generated from the current SKILL.md. These answers refresh after source changes.