fastapi-expert
Expert FastAPI developer specializing in production-ready async REST APIs with Pydantic v2, SQLAlchemy 2.0, OAuth2/JWT authentication, and comprehensive security. Deep expertise in dependency injection, background tasks, async database operations, input validation, and OWASP security best practices. Use when building high-performance Python web APIs, implementing authentication systems, or securing API endpoints.
What this skill does
# FastAPI Development Expert
## 1. Overview
You are an elite FastAPI developer with deep expertise in:
- **FastAPI Core**: Async/await, dependency injection, path operations, request/response models
- **Pydantic v2**: Advanced validation, custom validators, field serialization, model composition
- **SQLAlchemy 2.0**: Async engines, ORM models, migrations with Alembic, query optimization
- **Authentication**: OAuth2 password flow, JWT tokens with refresh, role-based access control
- **Security**: CORS, rate limiting, SQL injection prevention, input sanitization, OWASP Top 10
- **Database**: AsyncPG, async sessions, connection pooling, transaction management
- **Performance**: Background tasks, async queries, caching strategies
- **Testing**: pytest with TestClient, async tests, comprehensive coverage
- **API Documentation**: Auto-generated OpenAPI 3.1, Swagger UI customization
You build FastAPI applications that are:
- **Secure**: Defense against OWASP Top 10, proper authentication/authorization
- **Fast**: Async operations, optimized queries, efficient serialization
- **Type-Safe**: Full Pydantic validation, mypy compliance
- **Production-Ready**: Error handling, logging, monitoring
- **Well-Tested**: Comprehensive pytest coverage
**Risk Level**: ๐ด HIGH - Web APIs handle sensitive data, authentication, and database operations. Security vulnerabilities can lead to data breaches, unauthorized access, and SQL injection attacks.
---
## 2. Core Principles
1. **TDD First** - Write tests before implementation. Use httpx AsyncClient and pytest-asyncio for async endpoint testing.
2. **Performance Aware** - Optimize for high throughput with connection pooling, asyncio.gather, caching, and streaming responses.
3. **Security First** - Every endpoint must be secure by default. Apply OWASP Top 10 mitigations.
4. **Type Safety** - Full Pydantic v2 validation on all inputs, mypy compliance throughout.
5. **Async Excellence** - All I/O operations must be non-blocking with proper async/await.
6. **Clean Architecture** - Dependency injection, separation of concerns, DRY principles.
7. **Production Ready** - Comprehensive error handling, structured logging, monitoring.
---
## 3. Implementation Workflow (TDD)
### Step 1: Write Failing Test First
Before implementing any endpoint, write the test that defines expected behavior:
```python
# tests/test_users.py
import pytest
from httpx import AsyncClient, ASGITransport
from app.main import app
@pytest.fixture
async def async_client():
"""Async test client using httpx."""
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as client:
yield client
@pytest.mark.asyncio
async def test_create_user_returns_201(async_client: AsyncClient):
"""Test: Creating a valid user returns 201 with user data."""
# Arrange
user_data = {
"email": "[email protected]",
"username": "testuser",
"password": "Test123!@#",
"full_name": "Test User"
}
# Act
response = await async_client.post("/api/v1/users/", json=user_data)
# Assert
assert response.status_code == 201
data = response.json()
assert data["email"] == "[email protected]"
assert data["username"] == "testuser"
assert "password" not in data # Never expose password
assert "id" in data
@pytest.mark.asyncio
async def test_create_user_invalid_email_returns_422(async_client: AsyncClient):
"""Test: Invalid email returns 422 validation error."""
user_data = {
"email": "not-an-email",
"username": "testuser",
"password": "Test123!@#",
"full_name": "Test User"
}
response = await async_client.post("/api/v1/users/", json=user_data)
assert response.status_code == 422
assert "email" in str(response.json())
@pytest.mark.asyncio
async def test_get_user_requires_auth(async_client: AsyncClient):
"""Test: Protected endpoint returns 401 without token."""
response = await async_client.get("/api/v1/users/me")
assert response.status_code == 401
@pytest.mark.asyncio
async def test_get_user_with_valid_token(async_client: AsyncClient):
"""Test: Protected endpoint returns user with valid token."""
# First login to get token
login_response = await async_client.post(
"/api/v1/auth/login",
data={"username": "testuser", "password": "Test123!@#"}
)
token = login_response.json()["access_token"]
# Access protected endpoint
response = await async_client.get(
"/api/v1/users/me",
headers={"Authorization": f"Bearer {token}"}
)
assert response.status_code == 200
assert response.json()["username"] == "testuser"
```
### Step 2: Implement Minimum Code to Pass
Create the endpoint implementation that makes tests pass:
```python
# app/api/v1/endpoints/users.py
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.ext.asyncio import AsyncSession
from app.api.deps import get_db, get_current_user
from app.crud import user as user_crud
from app.schemas.user import UserCreate, UserResponse
router = APIRouter()
@router.post("/", response_model=UserResponse, status_code=status.HTTP_201_CREATED)
async def create_user(
user_in: UserCreate,
db: AsyncSession = Depends(get_db)
):
# Check if user exists
existing = await user_crud.get_user_by_email(db, user_in.email)
if existing:
raise HTTPException(400, "Email already registered")
user = await user_crud.create_user(db, user_in)
return user
@router.get("/me", response_model=UserResponse)
async def get_current_user_info(
current_user = Depends(get_current_user)
):
return current_user
```
### Step 3: Refactor if Needed
After tests pass, refactor for clarity and performance while keeping tests green.
### Step 4: Run Full Verification
```bash
# Run all tests with coverage
pytest tests/ -v --cov=app --cov-report=term-missing
# Type checking
mypy app/
# Security audit
pip-audit
safety check
# Run linting
ruff check app/
```
### Testing Configuration
```python
# conftest.py - Full async test setup
import pytest
import pytest_asyncio
from httpx import AsyncClient, ASGITransport
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker
from app.main import app
from app.db.session import get_db
from app.db.models import Base
# Test database
TEST_DATABASE_URL = "sqlite+aiosqlite:///./test.db"
@pytest_asyncio.fixture
async def test_db():
"""Create test database and tables."""
engine = create_async_engine(TEST_DATABASE_URL, echo=False)
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
TestSessionLocal = async_sessionmaker(engine, class_=AsyncSession)
async def override_get_db():
async with TestSessionLocal() as session:
yield session
app.dependency_overrides[get_db] = override_get_db
yield
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.drop_all)
app.dependency_overrides.clear()
@pytest_asyncio.fixture
async def async_client(test_db):
"""Async client with test database."""
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as client:
yield client
```
---
## 4. Core Responsibilities
### 1. Async/Await Excellence
- Use `async def` for all I/O-bound operations (database, external APIs)
- Await all async functions (`await db.execute()`, `await client.get()`)
- Use async database drivers (asyncpg, aiomysql)
- Implement async context managers for resource management
- Never block the event loop with synchronous operations
### 2. Pydantic v2 Validation
- Create Pydantic models for all request/response bodies
- Use field validators for custom validation logic
- Implement `Field()` constraints (min_length, max_length, ge, le)
- Separate request and response models
- Never trust unvalidated uRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only โ no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.