用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ag2ai/resource-hub --skill api-conventions命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | api-conventions |
| description | REST and WebSocket endpoint patterns, error handling, and Pydantic schema conventions for the backend |
| license | Apache-2.0 |
All REST endpoints go in backend/app/main.py under the /api prefix.
from .schemas import MyRequest, MyResponse
@app.post("/api/my-endpoint", response_model=MyResponse)
async def my_endpoint(req: MyRequest) -> MyResponse:
# Business logic here
return MyResponse(...)
Rules:
response_model — never return raw dictsschemas.py, not inline/api/from pydantic import BaseModel
class MyResponse(BaseModel):
"""Docstring explains what this response represents."""
field_name: str
optional_field: str | None = None
items: list[str] = []
Rules:
model_dump(), model_dump_json(), model_validate()The WebSocket handler in main.py follows this pattern:
@app.websocket("/ws/my-feature")
async def my_ws(websocket: WebSocket) -> None:
await websocket.accept()
try:
while True:
data = await websocket.receive_text()
payload = json.loads(data)
# Process and send responses
await websocket.send_text(response.model_dump_json())
except WebSocketDisconnect:
pass
Rules:
try/except WebSocketDisconnectmodel_dump_json(), not hand-built strings{"type": "done"} message to signal completion to the frontend{"type": "error"} for recoverable errors instead of closing the connectionHTTPException for business errorsrun_team(), send as {"type": "error"} to the clientCORS is configured in main.py for http://localhost:5173 (Vite dev server). For production, replace with the actual frontend origin.