用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill fastapi命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
| name | fastapi |
| description | | Use when this capability is needed. |
Full Reference: See advanced.md for WebSocket integration including connection management, authentication, room management, Pydantic message protocols, heartbeat, Redis pub/sub scaling, and background tasks.
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:fastapifor comprehensive documentation.
from fastapi import FastAPI, HTTPException, Depends
from pydantic import BaseModel, EmailStr
app = FastAPI(title="My API")
class UserCreate(BaseModel):
name: str
email: EmailStr
class User(UserCreate):
id: int
class Config:
from_attributes = True
@app.get("/users", response_model=list[User])
async def get_users(skip: int = 0, limit: int = 100):
return await db.users.find_many(skip=skip, limit=limit)
@app.get("/users/{user_id}", response_model=User)
async def get_user(user_id: int):
user = await db.users.find(user_id)
if not user:
raise HTTPException(status_code=404, detail="User not found")
return user
@app.post("/users", response_model=User, status_code=201)
async def create_user(user: UserCreate):
return await db.users.create(user.model_dump())
async def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
async def get_current_user(token: str = Depends(oauth2_scheme)):
user = await verify_token(token)
if not user:
raise HTTPException(status_code=401, detail="Invalid token")
return user
@app.get("/me", response_model=User)
async def get_me(user: User = Depends(get_current_user)):
return user
/docs| Anti-Pattern | Why It's Bad | Solution |
|---|---|---|
def instead of async def | Blocks event loop | Use async def for I/O operations |
Missing response_model | No output validation | Always specify response_model |
| Sync database calls | Blocks workers | Use async drivers (asyncpg, motor) |
| Global state without locks | Race conditions | Use asyncio.Lock or Depends() |
| Raising exceptions without HTTPException | Generic 500 errors | Use HTTPException with status codes |
| No input validation | Security vulnerabilities | Use Pydantic models with validators |
| Problem | Diagnosis | Fix |
|---|---|---|
| "RuntimeError: no running event loop" | Calling async from sync code | Use await or asyncio.run() |
| Validation errors not clear | Missing field descriptions | Add Field(description=...) |
| Slow response times | Sync database calls | Switch to async SQLAlchemy |
| CORS errors in browser | Missing middleware | Add CORSMiddleware |
| Dependency not injected | Wrong import or syntax | Check Depends() syntax |
from fastapi.middleware.cors import CORSMiddleware
from slowapi import Limiter
app = FastAPI(
title="My API",
docs_url="/docs" if os.getenv("ENV") != "production" else None,
)
limiter = Limiter(key_func=get_remote_address)
app.state.limiter = limiter
app.add_middleware(
CORSMiddleware,
allow_origins=os.getenv("ALLOWED_ORIGINS", "").split(","),
allow_credentials=True,
allow_methods=["GET", "POST", "PUT", "DELETE", "PATCH"],
allow_headers=["*"],
)
@app.get("/health")
async def health():
return {"status": "healthy"}
@app.get("/ready")
async def readiness(db: Session = Depends(get_db)):
try:
db.execute("SELECT 1")
return {"status": "ready", "database": "connected"}
except Exception:
return JSONResponse(status_code=503, content={"status": "not ready"})
from contextlib import asynccontextmanager
@asynccontextmanager
async def lifespan(app: FastAPI):
await database.connect()
yield
await database.disconnect()
app = FastAPI(lifespan=lifespan)
| Metric | Alert Threshold |
|---|---|
| Request latency p99 | > 500ms |
| Error rate (5xx) | > 1% |
| Memory usage | > 80% |
| Worker utilization | > 90% |
Source: claude-dev-suite/claude-dev-suite — distributed by TomeVault.
基于 SOC 职业分类