用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ag2ai/resource-hub --skill add-api-endpoint命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
REST and WebSocket endpoint patterns, error handling, and Pydantic schema conventions for the backend
Architecture, directory layout, communication protocol, and conventions for the full-stack multi-agent application
Step-by-step guide to add a new agent to the multi-agent team
正在显示 SKILL.md
基于 SOC 职业分类
| name | add-api-endpoint |
| description | Step-by-step guide to add a new REST or WebSocket endpoint to the backend |
| license | Apache-2.0 |
backend/app/schemas.pyclass SummarizeRequest(BaseModel):
"""Request to summarize a conversation."""
conversation_id: str
class SummarizeResponse(BaseModel):
"""Summary of a conversation."""
summary: str
message_count: int
backend/app/main.pyfrom .schemas import SummarizeRequest, SummarizeResponse
@app.post("/api/summarize", response_model=SummarizeResponse)
async def summarize(req: SummarizeRequest) -> SummarizeResponse:
# Call the agent team or implement logic
responses = await run_team(f"Summarize conversation {req.conversation_id}")
return SummarizeResponse(
summary=responses[-1]["content"] if responses else "",
message_count=len(responses),
)
backend/tests/test_api.py@pytest.mark.asyncio
async def test_summarize(client: AsyncClient) -> None:
resp = await client.post("/api/summarize", json={"conversation_id": "abc"})
assert resp.status_code == 200
body = resp.json()
assert "summary" in body
const resp = await fetch("/api/summarize", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ conversation_id: id }),
});
const data = await resp.json();
The Vite proxy forwards /api requests to the backend automatically.
backend/app/main.py@app.websocket("/ws/stream")
async def stream_ws(websocket: WebSocket) -> None:
await websocket.accept()
try:
while True:
data = await websocket.receive_text()
payload = json.loads(data)
# Process and stream responses
await websocket.send_text(
AgentMessage(agent="system", content="...", type="status").model_dump_json()
)
except WebSocketDisconnect:
pass
const ws = new WebSocket(`${protocol}//${window.location.host}/ws/stream`);
ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
// Handle message
};
The Vite proxy handles /ws paths — add the new path to vite.config.ts if using a different prefix.
schemas.pymain.py with response_model (REST) or structured JSON (WS)tests/test_api.py/api/ or /ws/ prefix (proxied by Vite)