Agent skill
backend-api
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.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/backend-api-jawad-chaudhary-hackathone-2-todo-sp
SKILL.md
FastAPI Backend API Development
Core Pattern
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"}
Error Handling
- Use
HTTPExceptionwith proper status codes (401, 403, 404, 500) - Provide user-friendly error messages
- Always use async for I/O operations
Testing
from fastapi.testclient import TestClient
client = TestClient(app)
response = client.post("/api/user123/endpoint", json={"field": "value"})
assert response.status_code == 200
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?