Fastapi expert
Skill corticalstack/engineering/.claude/skills/fastapi-expert
Use when building FastAPI applications, async Python REST APIs, Pydantic V2 schemas, SQLAlchemy async database operations, JWT/OAuth2 authentication, async pytest testing, RFC 9457 error handling, cursor pagination, or API versioning strategies.From its SKILL.md
npx -y skills add corticalstack/engineering --skill fastapi-expertAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
4.5 KB, as published. Nobody here has run it
FastAPI Expert Skill Profile
Specialized backend implementation guide for production-grade async Python APIs using FastAPI 0.115+, Pydantic V2, SQLAlchemy 2.0 async, and Python 3.12+.
Critical Requirements (MUST DO)
- Type hints throughout — FastAPI and Pydantic depend on them
- Pydantic V2 syntax exclusively (
model_config,field_validator,ConfigDict) Annotated[T, Depends()]type alias pattern for all dependencieslifespancontext manager — never@app.on_event(deprecated, has a double-fire bug)async deffor all I/O routes;deffor CPU-bound routes (FastAPI runs those in a threadpool)PyJWTfor JWT — neverpython-jose(CVE-2024-33663, abandoned since 2022)uvfor dependency management,rufffor linting- RFC 9457 Problem Details (
application/problem+json) for all error responses — seereferences/error-responses.md - Cursor-based pagination by default for all collection endpoints — see
references/pagination.md - URI prefix versioning from day one (
/v1/) — never ship unversioned public endpoints Idempotency-Keyheader support for non-idempotent POST/PATCH operationsRetry-Afteron all 429 and 503 responses
Anti-Pattern Quick Reference
| ❌ Avoid | ✅ Use Instead |
|---|---|
@app.on_event("startup/shutdown") | lifespan context manager |
python-jose / jose import | PyJWT (import jwt) |
ORJSONResponse / UJSONResponse | Default Pydantic/Rust serializer (FastAPI 0.130+) |
Column() in SQLAlchemy models | mapped_column() with Mapped[] |
orm_mode = True / class Config | model_config = ConfigDict(from_attributes=True) |
.dict() / .json() | .model_dump() / .model_dump_json() |
@pytest.mark.asyncio on every test | asyncio_mode = "auto" in pyproject.toml |
TestClient in async tests | httpx.AsyncClient with ASGITransport |
allow_origins=["*"] + allow_credentials=True | Explicit origin list |
time.sleep() in async def | await asyncio.sleep() or use def route |
pip / poetry | uv |
Optional[X] | X | None (Python 3.10+) |
200 OK with error in body | Proper 4xx/5xx + RFC 9457 application/problem+json |
{"error": {"message": ...}} custom format | RFC 9457 Problem Details |
?page=N offset pagination by default | Cursor pagination (?cursor=...) |
Verb URIs (/getUsers, /createUser) | Noun resource URIs (/users) |
| Unversioned public endpoints | /v1/ URI prefix on all routes |
Reference Files
| File | Contents |
|---|---|
| references/pydantic-v2.md | Schemas, validators, ConfigDict, computed_field, settings |
| references/endpoints-routing.md | Router setup, CRUD, query parameter models (0.115+), dependencies |
| references/authentication.md | PyJWT, OAuth2, RBAC, httpOnly cookies, refresh tokens |
| references/async-sqlalchemy.md | Engine, AsyncAttrs, DatabaseSessionManager, CRUD, lifespan |
| references/testing-async.md | anyio auto mode, AsyncClient, NullPool, rollback isolation |
| references/security.md | CORS, rate limiting, security headers, middleware stack |
| references/project-structure.md | Domain-based layout, app factory, module conventions |
| references/error-responses.md | RFC 9457 Problem Details, FastAPI exception handlers, status code guide |
| references/pagination.md | Cursor pagination, async SQLAlchemy keyset queries, response envelope |
| references/versioning.md | URI versioning, APIRouter prefix, breaking changes, Sunset headers |