[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EN0DBP2XM7DXMCKBK7R1S3":3,"skill-same:01M7EN0DBP2XM7DXMCKBK7R1S3":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M7EN0DBP2XM7DXMCKBK7R1S3","fastapi-pro",null,"FastAPI guidance — typed endpoints, Pydantic validation, dependency injection, async patterns, and production deployment.","TanNhatCMS\u002Fjarvis","TanNhatCMS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F113796420?v=4","01M753MV17KG5CD3152G3WQEQY","KietNT","01M7EKEDYVYQ6PWVJJMZ911VMX",0,"MIT","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fams-fastapi-pro\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: fastapi-pro\ndescription: FastAPI guidance — typed endpoints, Pydantic validation, dependency injection, async patterns, and production deployment.\ncategory: development\n---\n\n## Overview\n\nFastAPI is a modern Python web framework built on Starlette and Pydantic, where type annotations double as request validation, serialization, and automatic OpenAPI documentation. Declare a Pydantic model and you get parsing, validation errors, and interactive docs for free. Its native async support makes it a strong default for I\u002FO-bound Python APIs. This skill covers designing FastAPI services well: dependency injection, background work, database patterns, and production deployment.\n\n## When to use\n\n- Building a typed, documented REST API in Python.\n- Designing dependency injection (DB sessions, auth, settings) the FastAPI way.\n- Mixing async endpoints with sync libraries (SQLAlchemy, boto3) safely.\n- Generating OpenAPI clients or serving interactive docs.\n- Deploying FastAPI behind a production ASGI server.\n- Adding WebSockets or SSE to a Python API.\n- Structuring a large FastAPI codebase across teams.\n\n## Core concepts\n\n- **Types are the contract.** Annotations on path params, query params, and Pydantic request\u002Fresponse models produce validation and docs automatically. Use `response_model` to strip internal fields — never return ORM objects directly.\n- **Dependency injection with `Depends`.** Dependencies are reusable, composable functions: `get_db()`, `get_current_user()`, settings. They can yield (setup\u002Fteardown), be cached per-request, and nested. This is the framework's extension mechanism — prefer it over globals and middleware for request-scoped needs.\n- **Async done right.** `async def` endpoints run on the event loop; call async libraries with `await`. Blocking sync code (most ORMs' sync APIs, `requests`, heavy CPU work) inside `async def` endpoints stalls every request — run it in a threadpool via `anyio.to_thread` or use `def` endpoints and let FastAPI thread them.\n- **Pydantic v2.** Models validate on assignment optionally, serialize fast, and support strict types, custom validators, and `computed_field`. Keep validation logic in models, not in route handlers.\n- **Routers and versioning.** `APIRouter` with prefixes and tags organizes large APIs; version via URL prefix (`\u002Fv1`) from the start if the API is public.\n- **BackgroundTasks vs workers.** `BackgroundTasks` run after the response is sent — fine for quick post-response work (sending an email). Anything slow, retryable, or critical belongs in a real queue (Celery, arq, Dramatiq).\n- **Lifespan events.** The modern `lifespan` context manager (replacing `on_event`) handles startup\u002Fshutdown: connect pools, load models, then yield; cleanup after. One place for resource lifecycle.\n- **Middleware vs dependencies.** Middleware sees every request (good for logging, CORS, request IDs); dependencies are opt-in per endpoint (good for auth, DB). Don't implement auth as middleware when only some routes need it.\n- **Response classes.** `JSONResponse` default; `StreamingResponse` for large\u002Fstreaming payloads; `FileResponse` for downloads — pick deliberately, and set media types explicitly.\n- **OpenAPI customization.** Operation IDs, tags, and descriptions shape generated clients; callbacks and webhooks document async flows; keep the schema clean because it becomes your public contract.\n\n## Practical workflow\n\n1. **Scaffold the project.** Separate API, domain, and infrastructure:\n   ```\n   app\u002F\n     main.py        # app factory, router mounting, middleware\n     api\u002Fv1\u002F        # routers\n     schemas\u002F       # Pydantic models (request\u002Fresponse)\n     services\u002F      # business logic\n     core\u002F          # settings, security, dependencies\n   ```\n2. **Define the app factory.** Build the app in a `create_app()` function so tests can construct isolated instances; configure CORS, trusted hosts, and exception handlers there.\n   ```python\n   def create_app() -> FastAPI:\n       app = FastAPI(title=\"Shop API\", lifespan=lifespan)\n       app.include_router(api_router, prefix=\"\u002Fv1\")\n       app.add_middleware(RequestIDMiddleware)\n       return app\n   ```\n3. **Write typed endpoints.** Request model in, response model out, dependencies declared:\n   ```python\n   @router.post(\"\u002Fusers\", response_model=UserOut, status_code=201)\n   def create_user(payload: UserCreate, db: Session = Depends(get_db)):\n       ...\n   ```\n   - Keep handlers thin: validate → authorize → call service → return. No SQL in route functions.\n4. **Manage DB sessions.** A `get_db` dependency that yields a session and closes it in `finally` — one session per request, committed or rolled back by the service layer, never shared across requests.\n5. **Secure and observe.** JWT\u002FOAuth2 via `fastapi.security`, rate limiting at the proxy, structured logging with request IDs, and `\u002Fhealth` plus `\u002Fready` endpoints.\n   - Use `HTTPBearer`\u002F`OAuth2PasswordBearer` schemes so the OpenAPI docs show an Authorize button.\n6. **Test properly.** `TestClient` (or async `httpx.AsyncClient` with ASGI transport) for endpoint tests; override dependencies (`app.dependency_overrides`) to inject test doubles for DB\u002Fauth.\n7. **Handle file uploads safely.** `UploadFile` with size limits, content-type validation, and streaming to storage — never buffer multi-GB uploads in memory.\n8. **Deploy.** Serve with uvicorn workers (or gunicorn + uvicorn workers) behind nginx\u002Ftraefik; set worker count ≈ 2×CPU cores for sync endpoints, fewer for pure-async; configure timeouts and graceful shutdown.\n\n## Common pitfalls\n\n- **Blocking the event loop** — calling sync DB drivers or `time.sleep` in `async def` endpoints; profile under load to catch it.\n- **Returning ORM models directly** — lazy loading triggers N+1 queries during serialization; always map to Pydantic response models.\n- **Leaking DB sessions** — a `get_db` without `try\u002Ffinally` close exhausts the connection pool under traffic.\n- **Putting heavy work in BackgroundTasks** — they share the worker process; a slow task starves request handling. Use a queue.\n- **No request size limits** — huge JSON bodies can OOM workers; set limits at the server\u002Fproxy and validate payload sizes.\n- **Docs exposed in production** — `\u002Fdocs` and `\u002Fopenapi.json` are great in dev; restrict or disable them on public deployments if they reveal internals.\n- **Mutable default arguments in dependencies** — classic Python gotcha, amplified because dependencies run per request.\n- **CORS misconfiguration** — `allow_origins=[\"*\"]` with credentials; be explicit about origins in production.\n- **Ignoring `response_model_exclude_unset`** — PATCH endpoints overwriting fields with defaults; use `exclude_unset` for partial updates.\n- **No timeout on outgoing calls** — `httpx` without timeouts hanging workers; set timeouts on every external call.\n- **Sync `TestClient` hiding async bugs** — portal-based TestClient can mask event-loop issues; test async paths with a real ASGI transport too.\n- **Over-eager `response_model` nesting** — deeply nested response models with N+1-prone computed fields; profile serialization on list endpoints.\n- **Forgetting `dependencies=[...]` on routers** — auth applied per-endpoint instead of once on the router; include shared deps at `include_router` time.\n","## Overview\n\nFastAPI is a modern Python web framework built on Starlette and Pydantic, where type annotations double as request validation, serialization, and automatic OpenAPI documentation. Declare a Pydantic model and you get parsing, validation errors, and interactive docs for free. Its native async support makes it a strong default for I\u002FO-bound Python APIs. This skill covers designing FastAPI services well: dependency injection, background work, database patterns, and production deployment.\n\n## When to use\n\n- Building a typed, documented REST API in Python.\n- Designing dependency injection (DB sessions, auth, settings) the FastAPI way.\n- Mixing async endpoints with sync libraries (SQLAlchemy, boto3) safely.\n- Generating OpenAPI clients or serving interactive docs.\n- Deploying FastAPI behind a production ASGI server.\n- Adding WebSockets or SSE to a Python API.\n- Structuring a large FastAPI codebase across teams.\n\n## Core concepts\n\n- **Types are the contract.** Annotations on path params, query params, and Pydantic request\u002Fresponse models produce validation and docs automatically. Use `response_model` to strip internal fields — never return ORM objects directly.\n- **Dependency injection with `Depends`.** Dependencies are reusable, composable functions: `get_db()`, `get_current_user()`, settings. They can yield (setup\u002Fteardown), be cached per-request, and nested. This is the framework's extension mechanism — prefer it over globals and middleware for request-scoped needs.\n- **Async done right.** `async def` endpoints run on the event loop; call async libraries with `await`. Blocking sync code (most ORMs' sync APIs, `requests`, heavy CPU work) inside `async def` endpoints stalls every request — run it in a threadpool via `anyio.to_thread` or use `def` endpoints and let FastAPI thread them.\n- **Pydantic v2.** Models validate on assignment optionally, serialize fast, and support strict types, custom validators, and `computed_field`. Keep validation logic in models, not in route handlers.\n- **Routers and versioning.** `APIRouter` with prefixes and tags organizes large APIs; version via URL prefix (`\u002Fv1`) from the start if the API is public.\n- **BackgroundTasks vs workers.** `BackgroundTasks` run after the response is sent — fine for quick post-response work (sending an email). Anything slow, retryable, or critical belongs in a real queue (Celery, arq, Dramatiq).\n- **Lifespan events.** The modern `lifespan` context manager (replacing `on_event`) handles startup\u002Fshutdown: connect pools, load models, then yield; cleanup after. One place for resource lifecycle.\n- **Middleware vs dependencies.** Middleware sees every request (good for logging, CORS, request IDs); dependencies are opt-in per endpoint (good for auth, DB). Don't implement auth as middleware when only some routes need it.\n- **Response classes.** `JSONResponse` default; `StreamingResponse` for large\u002Fstreaming payloads; `FileResponse` for downloads — pick deliberately, and set media types explicitly.\n- **OpenAPI customization.** Operation IDs, tags, and descriptions shape generated clients; callbacks and webhooks document async flows; keep the schema clean because it becomes your public contract.\n\n## Practical workflow\n\n1. **Scaffold the project.** Separate API, domain, and infrastructure:\n   ```\n   app\u002F\n     main.py        # app factory, router mounting, middleware\n     api\u002Fv1\u002F        # routers\n     schemas\u002F       # Pydantic models (request\u002Fresponse)\n     services\u002F      # business logic\n     core\u002F          # settings, security, dependencies\n   ```\n2. **Define the app factory.** Build the app in a `create_app()` function so tests can construct isolated instances; configure CORS, trusted hosts, and exception handlers there.\n   ```python\n   def create_app() -> FastAPI:\n       app = FastAPI(title=\"Shop API\", lifespan=lifespan)\n       app.include_router(api_router, prefix=\"\u002Fv1\")\n       app.add_middleware(RequestIDMiddleware)\n       return app\n   ```\n3. **Write typed endpoints.** Request model in, response model out, dependencies declared:\n   ```python\n   @router.post(\"\u002Fusers\", response_model=UserOut, status_code=201)\n   def create_user(payload: UserCreate, db: Session = Depends(get_db)):\n       ...\n   ```\n   - Keep handlers thin: validate → authorize → call service → return. No SQL in route functions.\n4. **Manage DB sessions.** A `get_db` dependency that yields a session and closes it in `finally` — one session per request, committed or rolled back by the service layer, never shared across requests.\n5. **Secure and observe.** JWT\u002FOAuth2 via `fastapi.security`, rate limiting at the proxy, structured logging with request IDs, and `\u002Fhealth` plus `\u002Fready` endpoints.\n   - Use `HTTPBearer`\u002F`OAuth2PasswordBearer` schemes so the OpenAPI docs show an Authorize button.\n6. **Test properly.** `TestClient` (or async `httpx.AsyncClient` with ASGI transport) for endpoint tests; override dependencies (`app.dependency_overrides`) to inject test doubles for DB\u002Fauth.\n7. **Handle file uploads safely.** `UploadFile` with size limits, content-type validation, and streaming to storage — never buffer multi-GB uploads in memory.\n8. **Deploy.** Serve with uvicorn workers (or gunicorn + uvicorn workers) behind nginx\u002Ftraefik; set worker count ≈ 2×CPU cores for sync endpoints, fewer for pure-async; configure timeouts and graceful shutdown.\n\n## Common pitfalls\n\n- **Blocking the event loop** — calling sync DB drivers or `time.sleep` in `async def` endpoints; profile under load to catch it.\n- **Returning ORM models directly** — lazy loading triggers N+1 queries during serialization; always map to Pydantic response models.\n- **Leaking DB sessions** — a `get_db` without `try\u002Ffinally` close exhausts the connection pool under traffic.\n- **Putting heavy work in BackgroundTasks** — they share the worker process; a slow task starves request handling. Use a queue.\n- **No request size limits** — huge JSON bodies can OOM workers; set limits at the server\u002Fproxy and validate payload sizes.\n- **Docs exposed in production** — `\u002Fdocs` and `\u002Fopenapi.json` are great in dev; restrict or disable them on public deployments if they reveal internals.\n- **Mutable default arguments in dependencies** — classic Python gotcha, amplified because dependencies run per request.\n- **CORS misconfiguration** — `allow_origins=[\"*\"]` with credentials; be explicit about origins in production.\n- **Ignoring `response_model_exclude_unset`** — PATCH endpoints overwriting fields with defaults; use `exclude_unset` for partial updates.\n- **No timeout on outgoing calls** — `httpx` without timeouts hanging workers; set timeouts on every external call.\n- **Sync `TestClient` hiding async bugs** — portal-based TestClient can mask event-loop issues; test async paths with a real ASGI transport too.\n- **Over-eager `response_model` nesting** — deeply nested response models with N+1-prone computed fields; profile serialization on list endpoints.\n- **Forgetting `dependencies=[...]` on routers** — auth applied per-endpoint instead of once on the router; include shared deps at `include_router` time.\n",{"name":5,"category":24,"description":7},"development","main","af388a77c2fe5e0b4fd879cca4300a0ffa9a6579","skills\u002Fams-fastapi-pro",1,"https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis","https:\u002F\u002Fgithub.com\u002FTanNhatCMS","https:\u002F\u002Fmrkiet.name.vn","2026-11-07 14:23:08",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add TanNhatCMS\u002Fjarvis --skill fastapi-pro",{"tool":39,"command":40},"bunx","bunx skills add TanNhatCMS\u002Fjarvis --skill fastapi-pro",{"tool":42,"command":43},"pnpm","pnpm dlx skills add TanNhatCMS\u002Fjarvis --skill fastapi-pro","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fams-fastapi-pro\u002FSKILL.md",true,[],[48,55,63,70,77,84],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7EWYJR0J8DARY7E59Z6Y9MV","web-scrape","Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open\u002Ffetch fails on JS-heavy pages, or when you need clean markdown\u002Fstructured extraction from a site. Requires FIRECRAWL_API_KEY.","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fweb-scrape\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":59,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7EWYBN5P6F2AJG3FR24T9BP","design-taste-frontend","tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML\u002FCSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, \"AI-made\", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Ftaste-design\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Ftaste-design\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7EWY8FQFNQ2GB7NZZWGSSDX","test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-tdd\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7EWY5SHBFRH1HDHVWM9K7TV","systematic-debugging","Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-debugging\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7EWY3NM0Z0JAKS7HDZ24K66","requesting-code-review","Use when completing tasks, implementing major features, or before merging to verify work meets requirements","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-code-review\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7EWY0WRMWX4M9ZFY0WKC593","brainstorming","You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-brainstorming\u002FSKILL.md",[],[]]