원클릭으로
python-expert
Deep expertise in Python - FastAPI/Django, async patterns, Pydantic v2, SQLAlchemy 2.0
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Deep expertise in Python - FastAPI/Django, async patterns, Pydantic v2, SQLAlchemy 2.0
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
When the user wants help with paid advertising campaigns on Google Ads, Meta (Facebook/Instagram), LinkedIn, Twitter/X, or other ad platforms. Also use when the user mentions 'PPC,' 'paid media,' 'ROAS,' 'CPA,' 'ad campaign,' 'retargeting,' 'audience targeting,' 'Google Ads,' 'Facebook ads,' 'LinkedIn ads,' 'ad budget,' 'cost per click,' 'ad spend,' or 'should I run ads.' Use this for campaign strategy, audience targeting, bidding, and optimization. For bulk ad creative generation and iteration, see ad-creative. For landing page optimization, see cro.
Persistent engineering knowledge vault with semantic search. Save decisions, patterns, debug solutions, and insights as Zettelkasten notes in Obsidian with automatic embedding indexing for semantic retrieval. Use this skill whenever the user says "/memo", "запомни это", "сохрани в базу", "save this", "remember this", "добавь в базу знаний", "log this pattern", or any variation of wanting to persist knowledge. Also trigger for "/memo find", "/memo search", "что я решал по X", "find in vault", "search vault", "найди в базе" to search notes — both keyword and semantic. Trigger for "/memo dedup", "/memo stats", "/memo project", "/memo reindex". This is the bridge between Claude Code sessions and long-term engineering memory across all projects.
Use when starting any new task to select the right GSD mode (fast/quick/plan-phase) and the right model tier (Haiku/Sonnet/Opus) for subagents — prevents 5-10× cost overpay on routine work
Pack the whole repo (or a remote one) into one AI-friendly file via Repomix. Use for architectural reviews, cross-repo handoff, full-codebase audits — not for single-file lookups. Triggers on "pack repo", "feed codebase to AI", "снапшот", "analyze remote repo".
花叔Design(Huashu-Design)——用HTML做高保真原型、交互Demo、幻灯片、动画、设计变体探索+设计方向顾问+专家评审的一体化设计能力。HTML是工具不是媒介,根据任务embody不同专家(UX设计师/动画师/幻灯片设计师/原型师),避免web design tropes。触发词:做原型、设计Demo、交互原型、HTML演示、动画Demo、设计变体、hi-fi设计、UI mockup、prototype、设计探索、做个HTML页面、做个可视化、app原型、iOS原型、移动应用mockup、导出MP4、导出GIF、60fps视频、设计风格、设计方向、设计哲学、配色方案、视觉风格、推荐风格、选个风格、做个好看的、评审、好不好看、review this design、带解说的动画、解说视频、概念解释视频、长视频科普、配音动画、voiceover、narration、TTS+动画、5分钟讲清楚什么是XX。**主干能力**:Junior Designer工作流(先给假设+reasoning+placeholder再迭代)、反AI slop清单、React+Babel最佳实践、Tweaks变体切换、Speaker Notes演示、Starter Components(幻灯片外壳/变体画布/动画引擎/设备边框/解说Stage)、App原型专属守则(默认从Wikimedia/Met/Unsplash取真图、每台iPhone包AppPhone状态管理器可交互、交付前跑Playwright点击测试)、Playwright验证、HTML动画→MP4/GIF视频导出(25fps基础 + 60fps插帧 + palette优化GIF + 6首场景化BGM + 自动fade)、**带解说的长动画pipeline**(豆包TTS生人声+实测时长生timeline.json+NarrationStage驱动画面+ducking混音→交付HTML实播+发布MP4双形态;铁律:整片是一个连续的运动叙事,禁PowerPoint切换)。**需求模糊时的Fallback**:设计方向顾问模式——从5流派×20种设计哲学(Pentagram信息建筑/Field.io运动诗学/Kenya Hara东方极简/Sagmeister实验先锋等)推荐3个差异化方向,展示24个预制showcase(8场景×3风格),并行生成3个视觉Demo让用户选
Use BEFORE coding any new feature, MVP, pricing/billing change, launch, or pivot. Acts as a product validation gate for solo founders — validates target user, JTBD, pain intensity, current alternative, success metric, distribution channel, structural advantage vs competitors, unit economics with SaaS-graveyard gate, cheapest experiment, and top risk. RIGID — do not proceed to technical planning until product context is documented in `.planning/product/<slug>.md` or risk is explicitly accepted. Triggers on "build", "ship", "add feature", "MVP", "launch", "pivot", "pricing", "billing", before /plan, /tdd, /gsd-plan-phase, /gsd-discuss-phase, or when user describes a feature without naming a measurable success metric.
| name | Python Expert |
| description | Deep expertise in Python - FastAPI/Django, async patterns, Pydantic v2, SQLAlchemy 2.0 |
This skill provides deep Python expertise including FastAPI/Django patterns, async handling, Pydantic v2 validation, SQLAlchemy 2.0, and security best practices.
from pydantic import BaseModel, Field, ConfigDict, EmailStr, field_validator
# ✅ Pydantic v2 syntax
class UserCreate(BaseModel):
email: EmailStr
name: str = Field(min_length=2, max_length=100)
age: int | None = Field(default=None, ge=0, le=150)
class UserResponse(BaseModel):
id: int
email: str
name: str
model_config = ConfigDict(from_attributes=True)
# ❌ Pydantic v1 syntax (DON'T USE!)
class UserOld(BaseModel):
class Config: # Wrong! Use model_config
orm_mode = True # Wrong! Use from_attributes
from pydantic import field_validator, model_validator
class OrderCreate(BaseModel):
items: list[OrderItem]
discount_code: str | None = None
@field_validator('items')
@classmethod
def validate_items(cls, v: list[OrderItem]) -> list[OrderItem]:
if not v:
raise ValueError('Order must have at least one item')
return v
@model_validator(mode='after')
def validate_order(self) -> 'OrderCreate':
if self.discount_code and len(self.items) < 3:
raise ValueError('Discount requires at least 3 items')
return self
# ✅ Correct - async for I/O
async def get_user(db: AsyncSession, user_id: int) -> User | None:
result = await db.execute(select(User).where(User.id == user_id))
return result.scalar_one_or_none()
# ✅ Parallel operations
async def get_dashboard_data(db: AsyncSession, user_id: int):
user, posts, notifications = await asyncio.gather(
get_user(db, user_id),
get_user_posts(db, user_id),
get_notifications(db, user_id),
)
return {"user": user, "posts": posts, "notifications": notifications}
# ❌ Sequential when could be parallel
async def get_dashboard_data_slow(db: AsyncSession, user_id: int):
user = await get_user(db, user_id)
posts = await get_user_posts(db, user_id) # Doesn't depend on user
notifications = await get_notifications(db, user_id)
return {"user": user, "posts": posts, "notifications": notifications}
from fastapi import BackgroundTasks
async def send_email(email: str, message: str):
# Simulate sending
await asyncio.sleep(1)
print(f"Email sent to {email}")
@router.post("/users")
async def create_user(
data: UserCreate,
background_tasks: BackgroundTasks,
db: DB,
) -> UserResponse:
user = await user_service.create(db, data)
background_tasks.add_task(send_email, user.email, "Welcome!")
return UserResponse.model_validate(user)
from sqlalchemy import String, ForeignKey
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
from datetime import datetime
class Base(DeclarativeBase):
pass
class User(Base):
__tablename__ = "users"
id: Mapped[int] = mapped_column(primary_key=True)
email: Mapped[str] = mapped_column(String(255), unique=True, index=True)
name: Mapped[str] = mapped_column(String(100))
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow)
posts: Mapped[list["Post"]] = relationship(back_populates="author")
from sqlalchemy import select
from sqlalchemy.orm import selectinload, joinedload
# ❌ N+1 problem
async def get_users_with_posts_bad(db: AsyncSession):
result = await db.execute(select(User))
users = result.scalars().all()
for user in users:
# Each access triggers a query!
print(user.posts)
# ✅ Eager loading with selectinload
async def get_users_with_posts(db: AsyncSession) -> list[User]:
result = await db.execute(
select(User).options(selectinload(User.posts))
)
return result.scalars().all()
# ✅ joinedload for single-object relationships
async def get_posts_with_authors(db: AsyncSession) -> list[Post]:
result = await db.execute(
select(Post).options(joinedload(Post.author))
)
return result.unique().scalars().all()
class UserRepository:
async def get_by_id(self, db: AsyncSession, user_id: int) -> User | None:
result = await db.execute(select(User).where(User.id == user_id))
return result.scalar_one_or_none()
async def get_by_email(self, db: AsyncSession, email: str) -> User | None:
result = await db.execute(select(User).where(User.email == email))
return result.scalar_one_or_none()
async def create(self, db: AsyncSession, data: UserCreate) -> User:
user = User(**data.model_dump())
db.add(user)
await db.commit()
await db.refresh(user)
return user
async def update(self, db: AsyncSession, user: User, data: UserUpdate) -> User:
for key, value in data.model_dump(exclude_unset=True).items():
setattr(user, key, value)
await db.commit()
await db.refresh(user)
return user
from fastapi import Depends
from typing import Annotated
async def get_db() -> AsyncGenerator[AsyncSession, None]:
async with async_session_maker() as session:
yield session
async def get_current_user(
token: Annotated[str, Depends(oauth2_scheme)],
db: Annotated[AsyncSession, Depends(get_db)],
) -> User:
payload = decode_token(token)
if not payload:
raise HTTPException(status_code=401, detail="Invalid token")
user = await user_repository.get_by_id(db, payload["sub"])
if not user:
raise HTTPException(status_code=401, detail="User not found")
return user
# Type aliases
DB = Annotated[AsyncSession, Depends(get_db)]
CurrentUser = Annotated[User, Depends(get_current_user)]
# Clean usage
@router.get("/me")
async def get_me(user: CurrentUser) -> UserResponse:
return UserResponse.model_validate(user)
@router.get("/users")
async def list_users(db: DB, user: CurrentUser) -> list[UserResponse]:
users = await user_repository.get_all(db)
return [UserResponse.model_validate(u) for u in users]
# ✅ Always use Pydantic
@router.post("/users")
async def create_user(data: UserCreate) -> UserResponse: # Validated automatically
...
# ✅ Path parameter validation
@router.get("/users/{user_id}")
async def get_user(user_id: int = Path(gt=0)) -> UserResponse:
...
# ✅ SQLAlchemy ORM (parameterized)
result = await db.execute(select(User).where(User.email == user_input))
# ✅ Raw query with parameters
result = await db.execute(
text("SELECT * FROM users WHERE email = :email"),
{"email": user_input}
)
# ❌ NEVER use f-strings in queries
result = await db.execute(text(f"SELECT * FROM users WHERE email = '{user_input}'"))
from passlib.context import CryptContext
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def hash_password(password: str) -> str:
return pwd_context.hash(password)
def verify_password(plain: str, hashed: str) -> bool:
return pwd_context.verify(plain, hashed)
from slowapi import Limiter
from slowapi.util import get_remote_address
limiter = Limiter(key_func=get_remote_address)
@router.post("/auth/login")
@limiter.limit("5/minute")
async def login(request: Request, data: LoginRequest) -> TokenResponse:
...
import pytest
from httpx import AsyncClient, ASGITransport
@pytest.fixture
async def db_session():
engine = create_async_engine("sqlite+aiosqlite:///:memory:")
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
async with AsyncSession(engine) as session:
yield session
@pytest.fixture
async def client(db_session):
app.dependency_overrides[get_db] = lambda: db_session
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as ac:
yield ac
app.dependency_overrides.clear()
@pytest.mark.asyncio
async def test_create_user(client: AsyncClient):
response = await client.post("/api/users", json={"email": "test@example.com", "name": "Test"})
assert response.status_code == 201
# Development
uv run uvicorn src.main:app --reload
# Testing
uv run pytest
uv run pytest -v --cov=src
# Code Quality
uv run ruff check .
uv run ruff check . --fix
uv run ruff format .
uv run mypy src/
# Dependencies
uv add package
uv add --dev pytest
uv sync