본문으로 건너뛰기
cccskills
무료GitHub에 공개

python-api-endpoint-creator

Creates FastAPI endpoints with layered architecture (Router → Service → Repository). Use when creating new API endpoints, CRUD operations, or scaffolding a new domain module in a FastAPI project.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md3.0 KB
  • code-patterns.md7.1 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Python API Endpoint Creator

Creates complete FastAPI endpoints following strict layered architecture patterns.

When to Use

  • Creating a new REST API endpoint from scratch
  • Adding CRUD operations for a new domain entity
  • Setting up the full stack: Router → Service → Repository → Tests
  • Scaffolding a new domain module

Process

  1. Pydantic Schemas — Create/Update/Response in schemas.py
  2. SQLAlchemy Model — with SoftDeleteMixin in models.py
  3. Repository — async CRUD with soft delete in repository.py
  4. Service — business logic, HTTPException for errors in service.py
  5. Dependencies — get_db, get_service in dependencies.py
  6. Router — thin endpoints, Depends() for everything in router.py
  7. Tests — httpx AsyncClient tests in tests/

See code-patterns.md for complete templates for each file.

Architecture

Router (APIRouter)  →  Service  →  Repository  →  Database
      ↓                  ↓            ↓
  Depends()        Business logic  SQLAlchemy
  Pydantic schemas HTTPException   AsyncSession
  Status codes     Validation      Soft delete

Hard Rules

  • POST for all mutations — GET for reads, POST for create/update/delete
  • Query params for IDs — ?id=xxx, never path params /{id}
  • Routers are thin — just delegation, no business logic
  • Services raise HTTPException — for expected errors (404, 409, 422)
  • Repositories handle soft delete — filter deleted_at.is_(None) in all queries
  • async def for all endpoints — unless CPU-bound

Gotchas

  • Forgetting response_model makes your API leak internal fields. Always set response_model=YourSchema on endpoints. Without it, FastAPI serializes the raw return value, which may include hashed_password, deleted_at, or other internal fields from your SQLAlchemy model.

  • Depends() creates a new instance per request — not a singleton. If your service holds state, it will be lost between requests. Services should be stateless. If you need shared state, use app state or a cache.

  • await db.commit() in the dependency, not in the repository. The get_db dependency handles commit/rollback. If you also commit inside the repository, you get double-commit bugs or premature commits before all operations complete.

  • 422 errors from Pydantic are opaque by default. Override the RequestValidationError handler to return field-level errors. The default just says "validation error" with no useful detail for the frontend.

  • Missing status_code=201 on create endpoints. FastAPI defaults to 200. Explicitly set status_code=status.HTTP_201_CREATED on POST create routes and status_code=status.HTTP_204_NO_CONTENT on delete routes.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Creates RPC-style endpoint following layered architecture (Controller → Manager → Repository). Use when creating new API endpoints or CRUD operations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1082026년 6월 18일 업데이트

Write blog posts, guides, tutorials, and long-form content. Sounds like a real person, not AI. Use when the user wants polished written content.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1082026년 6월 18일 업데이트

Design RPC-style APIs with layered architecture (Controller → Manager → Repository). Use when creating new API endpoints, designing API contracts, or reviewing API patterns.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1082026년 6월 18일 업데이트

Run a structured brainstorm session for startup ideas. Takes a theme or problem and generates ideas with quick gut-checks. Use when the user wants to explore a space or generate new ideas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1082026년 6월 18일 업데이트

Run real browser QA with Playwright. Use when testing a frontend feature, verifying UI before PR, smoke testing after deploy, or investigating reported visual bugs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1082026년 6월 18일 업데이트

CI/CD pipeline patterns for GitHub Actions, PR automation, and deployment workflows. Use when setting up CI, fixing broken pipelines, automating PR checks, or configuring deployment.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1082026년 6월 18일 업데이트

c0x12c의 스킬 모두 보기

이 스킬의 문제 신고