Phase03/.claude/skills/backend-api/SKILL.md
Build FastAPI REST APIs with CORS, JWT auth, Pydantic validation, async endpoints, and proper error handling. Use when creating API endpoints, middleware, or backend services.
npx skillsauth add jawad-chaudhary/hackathone-2-todo-spec-driven-development backend-apiInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
from fastapi import FastAPI, HTTPException, Depends
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel, Field
import os
app = FastAPI(title="API")
# CORS from environment
app.add_middleware(
CORSMiddleware,
allow_origins=os.getenv("CORS_ORIGINS", "").split(","),
allow_credentials=os.getenv("CORS_ALLOW_CREDENTIALS") == "true",
allow_methods=["*"],
allow_headers=["*"],
)
class Request(BaseModel):
field: str = Field(..., min_length=1)
@app.post("/api/{user_id}/endpoint")
async def endpoint(user_id: str, req: Request, current_user: str = Depends(verify_jwt)):
if user_id != current_user:
raise HTTPException(status_code=403, detail="User ID mismatch")
return {"status": "ok"}
HTTPException with proper status codes (401, 403, 404, 500)from fastapi.testclient import TestClient
client = TestClient(app)
response = client.post("/api/user123/endpoint", json={"field": "value"})
assert response.status_code == 200
development
Async testing with pytest, pytest-asyncio, httpx, fixtures, coverage reports, and test-first development. Use when writing tests, test fixtures, or measuring coverage.
tools
Build AI agents with OpenAI Agents SDK, tool registration, conversation history, and stateless execution. Use when creating AI agents, registering tools, or handling conversations.
development
Integrate OpenAI ChatKit in Next.js 15 App Router with domain allowlist, authentication, and API connections. Use when building chat interfaces or ChatKit integration.
tools
Create MCP server tools with Official Python MCP SDK for AI agents. Use when building MCP tools, registering tool schemas, or creating AI-accessible functions.