ワンクリックで
add-endpoint
Step-by-step checklist for adding a new API endpoint to a FastAPI + asyncpg app. Covers schema, query, route, and verification.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Step-by-step checklist for adding a new API endpoint to a FastAPI + asyncpg app. Covers schema, query, route, and verification.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Create a new database migration for PostgreSQL. Covers file naming, SQL patterns, running, and updating dependent code.
Baseline code quality enforcer — naming conventions, import hygiene, type safety, and style rules for a FastAPI + asyncpg + PostgreSQL Python backend.
Database schema reference for the hello-world app's PostgreSQL instance. Use when writing queries, creating migrations, or debugging data issues.
Docker patterns for this project — DooD (Docker-outside-of-Docker), compose conventions, container lifecycle, and dev-box workflow.
Project file tree and layout conventions. Use when navigating the codebase, finding where files belong, or understanding the project layout.
Test-driven development workflow for FastAPI + asyncpg apps. Write tests first, then implement, then refactor.
| name | add-endpoint |
| description | Step-by-step checklist for adding a new API endpoint to a FastAPI + asyncpg app. Covers schema, query, route, and verification. |
| user-invokable | true |
| argument-hint | GET|POST|PUT|DELETE /path |
Checklist for adding $ARGUMENTS to the app.
Define the response shape in your schemas module (or main.py for small apps):
from pydantic import BaseModel, ConfigDict
class MyResponse(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
name: str
created_at: datetime
Write the SQL query in a dedicated query module (or inline for small apps):
async def fetch_my_data(pool: asyncpg.Pool, param: int) -> list[asyncpg.Record]:
return await pool.fetch(
"SELECT id, name, created_at FROM my_table WHERE category = $1 ORDER BY created_at DESC",
param
)
Rules:
$N parameterized placeholders (NEVER string interpolation)fetch_* for reads, insert_* / update_* / delete_* for writesasyncpg.Record objects — let Pydantic handle serialization@app.get("/api/my-endpoint", response_model=list[MyResponse])
async def get_my_data(category: int):
rows = await fetch_my_data(pool, category)
return [dict(r) for r in rows]
Rules:
response_model=/items/{id}), query params for filtering (/items?status=active)@pytest.mark.asyncio
async def test_get_my_data_returns_list():
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
resp = await client.get("/api/my-endpoint?category=1")
assert resp.status_code == 200
assert isinstance(resp.json(), list)
@pytest.mark.asyncio
async def test_get_my_data_validates_params():
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
resp = await client.get("/api/my-endpoint?category=invalid")
assert resp.status_code == 422
If the endpoint requires a new table, use the /add-migration skill first.
# Check it compiles
python -m py_compile main.py
# Run tests
python -m pytest tests/ -v
# Smoke test (with services running)
docker compose up -d
curl -s http://localhost:8000/api/my-endpoint?category=1 | jq .
# Check OpenAPI docs
# Visit http://localhost:8000/docs