一键导入
py-scaffold
Use when starting a new Python/FastAPI backend, API, or microservice with SQLAlchemy, Alembic, and clean architecture
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when starting a new Python/FastAPI backend, API, or microservice with SQLAlchemy, Alembic, and clean architecture
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when the user wants to free disk space, investigate disk usage, clean caches, remove unused artifacts, or when disk capacity is high. Also use when asked to "clean up", "free space", "disk full", or "what's using disk space". Always uses AskUserQuestion for every deletion decision.
Use at the start of every conversation and for every user message — orchestrates the full engineering skills suite by understanding intent, clarifying requirements interactively, and invoking the right skills
Use when refactoring Go code, cleaning up legacy codebases, optimizing performance, or enforcing clean architecture boundaries in a Go/Fiber backend
Use when refactoring Python code, cleaning up legacy codebases, optimizing performance, enforcing type safety, or improving clean architecture in a FastAPI backend
Use when refactoring React components, cleaning up legacy frontends, optimizing performance, improving component architecture, or reducing bundle size
Use when reviewing changed code before committing or after completing a feature — checks performance, architecture, type safety, and code quality against project standards
| name | py-scaffold |
| description | Use when starting a new Python/FastAPI backend, API, or microservice with SQLAlchemy, Alembic, and clean architecture |
Bootstrap a new FastAPI backend with clean architecture, SQLAlchemy 2.0 async, Alembic, uv, and strict typing from day one.
Core principle: Start fully typed. mypy strict from the first file. No Any unless justified.
project/
src/
domain/ # Entities, value objects, repository protocols
application/ # Use cases, DTOs, service protocols
infrastructure/
postgres/ # SQLAlchemy models, repository implementations
redis/ # Cache implementations
config.py # Settings with pydantic-settings
interfaces/
http/ # FastAPI routers, dependencies, middleware
dependencies.py
routes.py
main.py # App factory with lifespan
alembic/
versions/
env.py
tests/
unit/
integration/
conftest.py
alembic.ini
pyproject.toml
Makefile
Dockerfile
docker-compose.yml
CLAUDE.md
from contextlib import asynccontextmanager
from collections.abc import AsyncGenerator
from fastapi import FastAPI
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
# Startup
engine = create_async_engine(settings.database_url)
app.state.session_factory = async_sessionmaker(engine, expire_on_commit=False)
yield
# Shutdown
await engine.dispose()
def create_app() -> FastAPI:
app = FastAPI(lifespan=lifespan)
app.include_router(api_router, prefix="/api/v1")
return app
[project]
name = "project-name"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
"fastapi>=0.115",
"uvicorn[standard]>=0.34",
"sqlalchemy[asyncio]>=2.0",
"asyncpg>=0.30",
"alembic>=1.14",
"pydantic-settings>=2.0",
]
[project.optional-dependencies]
dev = [
"pytest>=8.0",
"pytest-asyncio>=0.24",
"httpx>=0.28",
"testcontainers[postgres]>=4.0",
"mypy>=1.13",
"ruff>=0.8",
]
[tool.mypy]
strict = true
plugins = ["pydantic.mypy"]
[tool.ruff]
target-version = "py312"
line-length = 100
[tool.ruff.lint]
select = ["E", "F", "I", "N", "UP", "B", "SIM", "TCH", "RUF"]
[tool.pytest.ini_options]
asyncio_mode = "auto"
markers = ["integration: requires external services"]
.PHONY: run test lint type-check migrate migrate-create
run:
uvicorn src.main:create_app --factory --reload --port 8000
test:
pytest tests/ -m "not integration"
test-integration:
pytest tests/ -m integration
test-all:
pytest tests/
lint:
ruff check . && ruff format --check .
type-check:
mypy src/
migrate:
alembic upgrade head
migrate-create:
alembic revision --autogenerate -m "$(msg)"
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: app
POSTGRES_PASSWORD: secret
POSTGRES_DB: app
ports: ["5432:5432"]
volumes: [pgdata:/var/lib/postgresql/data]
healthcheck:
test: pg_isready -U app
interval: 5s
retries: 5
redis:
image: redis:7-alpine
ports: ["6379:6379"]
volumes:
pgdata:
REQUIRED: Invoke superpowers:test-driven-development to write /health endpoint.
# Test first
async def test_health(client: AsyncClient) -> None:
resp = await client.get("/health")
assert resp.status_code == 200
assert resp.json() == {"status": "ok"}
# Project Name
## Stack
- Python 3.12+ / FastAPI
- SQLAlchemy 2.0 async + Alembic
- PostgreSQL + Redis
- uv for dependency management
## Commands
- `make run` — start with hot reload
- `make test` — unit tests
- `make test-integration` — integration tests
- `make lint` — ruff check + format
- `make type-check` — mypy strict
- `make migrate` — apply migrations
- `make migrate-create msg="description"` — new migration
## Architecture
Clean architecture: domain → application → infrastructure → interfaces
All code fully typed. mypy strict. No untyped defs.
claude-md)react-scaffold for full-stackdocker-build for production Dockerfileci-pipeline for GitHub Actions