Scaffold a new domain module in an existing FastAPI project that follows the Admin/Client dual-interface convention (SQLAlchemy 2.0 async + Pydantic v2 + domain packages under app/domains/). Use whenever the user wants to add a domain/feature/resource to such a project: "user 도메인 추가해줘", "post 기능 만들어줘", "admin이랑 client 라우터 같이 만들어줘", "add an orders resource to the api", "create the payment endpoints", "add a product table and its admin list endpoint". Reach for it even when the user never says "domain" or "module", whenever a request against a FastAPI/Python codebase names a new resource with its endpoints or table; hand-writing those files silently skips the shared-array router registration this skill guarantees. Do NOT use this for: the initial project bootstrap/setup from scratch (use fastapi-bootstrap), the Alembic migration for the new model (hand off to fastapi-migration), splitting a fat service into use-cases (a refactor), or non-FastAPI stacks; NestJS projects use nestjs-domain-module.
Ships in backend. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Generate one vertical slice of a domain following the dual-interface convention:
Admin and Client are split at the file level because their auth model and
response shape almost always diverge. Merging them forces if is_admin: branches
through the service layer that rot as the two interfaces drift; splitting them
keeps each interface honest and lets the OpenAPI docs separate cleanly.
{
"domainName": "user", // snake_case; used for package + module + URL path
"interfaces": ["admin", "client"], // subset — generate only what is asked
"model": { // omit entirely if the domain has no own table yet
"softDeletable": true, // inherits SoftDeletableBase vs CoreBase
"fields": [
{ "name": "email", "type": "String(255)", "unique": true, "nullable": false,
"comment": "이메일" }
]
},
"exportContracts": true // regenerate packages/contracts after adding routes (monorepo only)
}
If the caller or user omits fields, ask only for what blocks generation: the
domain name and which interfaces. Everything else has a safe default
(interfaces: ["admin","client"], no model, exportContracts = true only when
packages/contracts/ exists in the repo).
{
"createdFiles": ["app/domains/user/client_router.py", "..."],
"registeredIn": "app/router_groups.py",
"migrationNeeded": true // true iff a model was created or changed
}
When migrationNeeded is true, tell the caller to run fastapi-migration next
(name suggestion: create_<domain>, e.g. create_user). Do not generate the
migration here — Alembic autogenerate needs a live DB and a destructive-DDL
review, which is a separate safety-gated step.
pyproject.toml and the app/
package (usually apps/api, or the repo root for a standalone project). Every
path below is relative to it.app/router_groups.py must be present. If it
is not, the project was not bootstrapped with this convention — stop and point
the user at fastapi-bootstrap rather than inventing a layout.app/domains/<domain>/ already exists, do not
overwrite it. Adding a missing interface to an existing domain is fine;
clobbering existing files is not — stop and report what is already there.app/router_groups.py (see below).migrationNeeded when a model was written.app/domains/<domain>/
├── __init__.py
├── models.py # if a model was requested
├── admin_schemas.py # if "admin"
├── admin_router.py # if "admin" → /api/v1/admin/<domain>
├── admin_service.py # if "admin"
├── client_schemas.py # if "client"
├── client_router.py # if "client" → /api/v1/<domain>
├── client_service.py # if "client"
└── service.py # (선택) only when genuinely non-trivial logic is shared
tests/domains/<domain>/test_client_service.py # seed unit test
Services are plain async functions, not classes. FastAPI's dependency injection already hands the session to the router, so a service class would exist only to hold a constructor — a module of functions is the same code with less ceremony and is trivially unit-testable without a container.
<domain> is snake_case, <Domain> is PascalCase (user → User). Routes carry
no version in the path — create_app() mounts every router under the configured
/api/v1 prefix, so the folder and the router never encode the version.
models.pyfrom sqlalchemy import Index, String, text
from sqlalchemy.orm import Mapped, mapped_column
from app.db.base_class import SoftDeletableBase # or CoreBase when not soft-deletable
class User(SoftDeletableBase):
__tablename__ = "user"
email: Mapped[str] = mapped_column(String(255), comment="이메일")
# Soft delete + unique column → PARTIAL unique index, so a deleted row does not
# block re-registration with the same email. A plain unique=True would.
__table_args__ = (
Index(
"ix_user_email_active",
"email",
unique=True,
postgresql_where=text("deleted_at IS NULL"),
),
)
Rules baked in: Mapped[...] annotations on every column (this is what makes mypy
strict and Alembic autogenerate both see the real types), a Korean comment= that
lands in the database and in generated ERDs, and no Pydantic validators on the
model — validation belongs to the request schema, not the table.
After writing the model, add it to app/db/base.py's re-export list. Alembic's
env.py imports only that module, so a model missing from it is invisible to
autogenerate — and autogenerate reads "table not in metadata" as "table was
deleted", emitting a drop_table. This one line is the difference between a
correct migration and a data-loss migration.
client_schemas.pyfrom pydantic import ConfigDict, Field
from app.common.schemas import CamelModel
class ClientUserRes(CamelModel):
"""클라이언트에 노출되는 사용자 정보."""
# from_attributes lets model_validate() read a SQLAlchemy row directly.
# Without it, model_validate(orm_row) raises — the single most common
# "why is my response empty" bug in this layout.
model_config = ConfigDict(from_attributes=True)
id: int = Field(description="사용자 ID")
email: str = Field(description="이메일", examples=["[email protected]"])
CamelModel (from app/common/schemas.py) applies the camelCase alias generator,
so Python stays snake_case while the wire contract stays camelCase and the OpenAPI
doc never lies about the key names. Every field carries a Korean description;
add examples when the format is not self-evident.
admin_schemas.py mirrors this. Admin may expose internal fields (deleted_at,
audit columns) that the client schema deliberately omits — that divergence is the
entire reason the two files exist.
client_router.pyfrom typing import Annotated
from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from app.common.pagination import PaginationParams
from app.common.schemas import PaginatedResponse
from app.db.session import get_session
from app.domains.user import client_service
from app.domains.user.client_schemas import ClientUserRes
router = APIRouter(prefix="/user", tags=["사용자"])
@router.get("", summary="사용자 목록 조회")
async def list_users(
page: Annotated[PaginationParams, Depends()],
session: Annotated[AsyncSession, Depends(get_session)],
) -> PaginatedResponse[ClientUserRes]:
return await client_service.list_users(session, page)
The return annotation is the response model — FastAPI reads it directly, so a
separate response_model= argument only duplicates it (and silently wins when the
two disagree). Every endpoint needs a Korean, noun-form summary because that
string is what a frontend developer reads in the docs sidebar.
admin_router.py is the mirror with prefix="/admin/user" and the admin schemas.
client_service.pyfrom sqlalchemy import func, select
from sqlalchemy.ext.asyncio import AsyncSession
from app.common.pagination import PaginationParams
from app.common.schemas import PageMeta, PaginatedResponse
from app.domains.user.client_schemas import ClientUserRes
from app.domains.user.models import User
async def list_users(
session: AsyncSession, page: PaginationParams
) -> PaginatedResponse[ClientUserRes]:
active = User.deleted_at.is_(None) # soft-deleted rows are never client-visible
total = await session.scalar(select(func.count()).select_from(User).where(active)) or 0
rows = (
await session.scalars(
select(User).where(active).order_by(User.id.desc()).offset(page.offset).limit(page.limit)
)
).all()
return PaginatedResponse[ClientUserRes](
data=[ClientUserRes.model_validate(row) for row in rows],
pagination=PageMeta(limit=page.limit, offset=page.offset, total=total),
)
admin_service.py mirrors this and may return admin schemas including soft-deleted
rows. The two services legitimately return different shapes, so a one-line
select() appearing in both is not shared logic — leave it duplicated. Extract
into the optional service.py only when genuinely non-trivial logic is shared
(state transitions, validation rules, a reused query like get_active_user_or_404)
and import it from both.
Async lazy-loading trap. Under AsyncSession, touching a relationship that was
not eagerly loaded raises MissingGreenlet at serialization time — inside the
response model, far from the query that caused it. Whenever a response schema
includes a relationship, load it explicitly:
select(User).options(selectinload(User.posts))
tests/domains/<domain>/test_client_service.pySeed exactly one test for the client service. A fresh domain that ships zero tests forces every later tool (and every later human) to guess the project's test convention instead of reading it. This one test pins it: the shared rollback session fixture, a real row written through the session, and assertions on both the pagination meta and the mapped field.
from sqlalchemy.ext.asyncio import AsyncSession
from app.common.pagination import PaginationParams
from app.domains.user.client_service import list_users
from app.domains.user.models import User
async def test_list_users_paginates_and_maps_fields(session: AsyncSession) -> None:
session.add(User(email="[email protected]"))
await session.flush()
res = await list_users(session, PaginationParams(limit=10, offset=0))
assert res.pagination.total == 1
assert res.data[0].email == "[email protected]"
The admin service gets its own test only when its logic actually diverges — a second near-identical test buys nothing.
Add the generated routers to the shared arrays in app/router_groups.py:
from app.domains.user.admin_router import router as admin_user_router
from app.domains.user.client_router import router as client_user_router
CLIENT_ROUTERS: list[APIRouter] = [client_user_router]
ADMIN_ROUTERS: list[APIRouter] = [admin_user_router]
This is the point of the convention. create_app() mounts these arrays, and the
OpenAPI doc builder filters /docs/client and /docs/admin from the exact same
arrays — so a registered router cannot be missing from the docs, and a documented
route cannot be unmounted. There is no second registration path to drift from.
Insert into the matching array(s) and add the import. Keep each array sorted by domain name so two people adding domains in parallel get a clean merge.
uv run mypy app passes — every column is Mapped[...], every response schema
has from_attributes=True, every endpoint has a return annotation.uv run pytest tests/domains/<domain> runs the seed test green.app/db/base.py.migrationNeeded.What SKILL.md sets; muted values are Claude Code's defaults
/backend:fastapi-domain-modulefrom backend
npx claudepluginhub siu9068/ggyul-skills --plugin backend11 skills in this plugin
/api-creator-bootstrapGenerates a backend repo's `api-creator` + `test-checker` skill pair: set up, port, or bootstrap the API + test skills here. Generate a project-tailored TDD skill PAIR — `api-creator` (scaffold new APIs) and `test-checker` (audit & fill existing unit tests) — for a backend project: extract the proven gated, test-first methodology and fill in THIS project's own conventions (layers, base classes, auth, DTO/serialization, folder layout, test framework, verify commands). Both skills share one discovered recipe so they stay consistent. Use whenever the user wants to "set up api-creator here", "port the api-creator/test-checker skills to this project", "bootstrap the API + test skills for this repo", or bring one project's API + test conventions into another as reusable skills. Do NOT use this to actually build an API or audit tests in the current project (that is the generated skills' job), nor to edit an existing skill (use skill-creator / skill-ops)./axum-bootstrapScaffolds a Rust axum 0.8 + SeaORM 2.0 + PostgreSQL 16 backend from zero, standalone or apps/api monorepo. House convention: DDD-lite domains with Admin/Client route groups, fail-fast env validation, three utoipa OpenAPI docs with Swagger UI, tracing JSON logs, a Docker image, tests against a real Postgres. Phase 0 decides standalone (Cargo workspace at the repo root) or apps/api in a pnpm monorepo next to packages/contracts. Use when the user wants to start, set up or scaffold a new axum or Rust backend with this stack: "러스트 백엔드 새로 세팅해줘", "axum 프로젝트 만들어줘", "sea-orm 붙여서 rust api 서버 깔아줘", "bootstrap an axum backend", "scaffold a Rust API with SeaORM and Postgres", "set up apps/api in Rust". Do NOT use for: adding a domain to an existing axum project (use axum-domain-module), writing a SeaORM migration (use axum-migration), NestJS or FastAPI backends (nestjs-bootstrap / fastapi-bootstrap), the whole multi-app bootstrap chain (project-setup), or other Rust frameworks such as actix-web, rocket, poem or loco.Other plugins' skills for the same job