fastapi

Implements FastAPI routing, dependency injection, and testing conventions for this project's API layer.

Updated Sep 13, 2026
One-click install
npx skills add https://github.com/abdulazeezoj/monovella-poc --skill fastapi-abdulazeezoj
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi
Source: https://github.com/abdulazeezoj/monovella-poc/tree/main/.agents/skills/fastapi
Command: npx skills add https://github.com/abdulazeezoj/monovella-poc --skill fastapi-abdulazeezoj

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Adding or changing HTTP endpoints in this project's FastAPI app without knowing its established conventions leads to inconsistent routers, misplaced startup logic, and tests that accidentally hit real infrastructure. This Skill encodes the project's exact patterns so new code matches the existing style. ## Core Features & Use Cases - Endpoint scaffolding: Step-by-step guide for adding a new resource end-to-end — Pydantic schemas, ORM model, router file, registration in main.py, and a CRUD test suite. - Dependency injection patterns: Conventions for per-request resources like database sessions via Depends() versus module-level singletons like settings. - Testing without a server: In-process testing with httpx AsyncClient, ASGITransport, and an in-memory SQLite database swapped in via dependency overrides. - Documented gotchas: Real failure modes such as missing init.py breaking the fastapi CLI, lifespan not running during tests, and sync drivers blocking the event loop. - Use Case: You need to add a new widgets resource to the API. Follow the guide to create the schema, model, router, registration, and tests that mirror the existing items resource exactly. ## Quick Start Ask the AI to add a new REST endpoint for a resource following this project's FastAPI conventions, including its router, schemas, and tests.

Frequently Asked Questions about fastapi

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

FAQPage Schema
How do I add a new endpoint to a FastAPI project?

Define Pydantic request/response schemas, create the ORM model, write a router file exporting an APIRouter with CRUD handlers, register it in main.py via include_router, and add a test module covering create, list, get, delete, and 404 cases.

How do I test FastAPI endpoints without running a server?

Use httpx.AsyncClient with ASGITransport pointed at the app object, sending requests in-process with no socket. Override the get_session dependency to use an in-memory SQLite database so tests need no external services.

When should a FastAPI handler be async def versus def?

Use async def the moment the handler awaits anything such as a database call or HTTP client. Handlers with no I/O stay plain def, since FastAPI runs them in a thread pool and unnecessary async adds risk of blocking mistakes.

Why does fastapi dev fail to find my app?

The fastapi CLI's directory-walk logic requires a top-level __init__.py in the package, even though pytest and plain imports work without it via namespace packages. Without it, the CLI computes the wrong root and the dev server fails to start.

Why doesn't FastAPI lifespan run during tests?

ASGITransport does not trigger lifespan startup or shutdown hooks by default, so init_db never executes in the test suite. Tests manage their own schema via metadata.create_all; use asgi_lifespan.LifespanManager only when testing startup behavior itself.