ericrisco/rsc-harness / skills/fastapi
fastapi
VerifiedUse when building, reviewing, testing, securing or shipping a FastAPI / async Python service — routers, Pydantic v2 schemas, dependency injection, async SQLAlchemy 2.0, OAuth2/JWT, ASGITransport tests, production wiring. NOT language-level Python or packaging (that is `python`), NOT engine-level SQL (that is `postgresdb`), NOT framework-agnostic REST contracts (that is `api-design`).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 19.6 KB |
| evals/README.md | markdown | 2.7 KB |
| evals/cases.yaml | config | 5.1 KB |
| references/database.md | markdown | 11.7 KB |
| references/production.md | markdown | 12.8 KB |
| references/security.md | markdown | 11.5 KB |
| references/testing.md | markdown | 11.5 KB |
| scripts/verify.shexecutable | script | 6.2 KB |
evals/cases.yaml
View on GitHubskill: fastapi
should_trigger:
- prompt: "Add a PATCH endpoint to update a user's email and full name, returning the updated record without leaking the password hash."
why: "FastAPI route + Pydantic Update/Response split + ORM serialization — the core of this skill's resource pattern."
- prompt: "My async route calls an external API with requests.get() and the whole server hangs under load. How should I fix it?"
why: "Blocking-call-on-the-event-loop anti-pattern; skill's decision rule #1 (httpx.AsyncClient / anyio.to_thread). User never names FastAPI but it's an async Python HTTP service."
- prompt: "How do I write tests for my endpoints that hit a real database session but roll everything back, without spinning up a live server?"
why: "ASGITransport + dependency_overrides + transactional fixture is this skill's testing playbook; no tool named but the in-process pattern is FastAPI-specific."
- prompt: "We need OAuth2 password login issuing JWTs, plus a require_roles guard so only admins can hit /api/v1/users. Wire it into our service."
why: "OAuth2 password flow + JWT claim validation + RBAC dependency — squarely in 'When to use' (auth)."
- prompt: "Set up pyproject.toml with ruff, mypy strict and uv for our Pydantic + SQLAlchemy 2.0 service, and add a CI gate."
why: "Tooling/dependency-management + mypy strict + CI gates for an async Python service is explicitly in scope."
- prompt: "Every handler returns errors in a different JSON shape. I want one consistent error response and 404/409 to be automatic. How?"
why: "Centralized exception handlers + single {error:{code,message,details}} envelope + AppError hierarchy — a named decision rule, phrased without mentioning FastAPI."
- prompt: "Our app builds the SQLAlchemy engine and reads os.environ at import time and it crashes in tests. What's the right structure?"
why: "App factory + lifespan + pydantic-settings injection; engine must live in lifespan, not at import — a core structural rule."
should_not_trigger:
- prompt: "Build a Next.js App Router page with a server action that posts a form and revalidates the cache."
route_to: "nextjs"
why: "Frontend/Next.js work; explicitly excluded in 'When NOT to use'."
- prompt: "Write the SQL and the Postgres index strategy for a fast keyset-paginated query over a 50M-row events table, and verify with EXPLAIN."
route_to: "postgresdb"
why: "Pure engine-level SQL/indexing/EXPLAIN below the SQLAlchemy layer; this is the postgresdb sibling's territory."
- prompt: "Explain the general principles for preventing injection and safely storing secrets, language-agnostic."
route_to: "security-audit"
why: "Generic security theory not specific to Python/FastAPI; the skill defers this to security-audit."
- prompt: "Write the Dockerfile and GitHub Actions pipeline to build and deploy our container image."
route_to: "deployment"
why: "Container/Compose/CI deploy mechanics belong to deployment; this skill keeps only a Docker note."
- prompt: "Convert this Flask blueprint with its sync SQLAlchemy ORM into cleaner Flask views."
route_to: "none"
why: "Flask/sync WSGI app explicitly excluded; no FastAPI sibling, and no other catalog skill covers Flask."
- prompt: "What HTTP status code and URL naming convention should I use for a bulk-delete REST endpoint, framework-agnostic?"
route_to: "none"
why: "Pure REST contract/design question (status codes, URL naming) — general REST-design territory, not the FastAPI implementation."
capability:
- scenario: "User asks: 'Add a POST /api/v1/users endpoint that creates a user. The request takes email, full_name, password; persist it and return the created user.'"
must_include:
- "Three Pydantic v2 models: UserCreate (with password) / UserResponse (no password or hashed_password field) / from_attributes=True (or model_config = ConfigDict(from_attributes=True))"
- "Thin route that delegates to a service/repository layer — no inline hashing, raw select(), or business logic in the handler"
- "DB session injected via Annotated[AsyncSession, Depends(get_db)] and the handler does NOT commit (get_db owns commit/rollback)"
- "async def handler; password hashed with argon2 (not stored or returned in plaintext); response_model=UserResponse declared"
- "status_code=201 and a Location header pointing at /api/v1/users/{id}"
- "Assertion/note that hashed_password never appears in the response payload"
- scenario: "User asks: 'Write a pytest test that POSTs to my create-user endpoint, asserts 201, and rolls back the DB afterward — no live server.'"
must_include:
- "httpx.AsyncClient with transport=ASGITransport(app=create_app()) — in-process, not a real network/uvicorn server"
- "app.dependency_overrides[get_db] = ... to swap in a transactional/test session"
- "Transactional fixture that rolls back (e.g. begin_nested / session rollback) so tests don't persist data"
- "pytest-asyncio with asyncio_mode = auto (no per-test @pytest.mark.asyncio needed)"
- "Asserts response.status_code == 201"
- "Asserts a secret field (e.g. 'hashed_password') is NOT in resp.json()"
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |