py-scaffold
Skill3 starsChanged 9 months agoMITView on GitHub
Use when starting a new Python/FastAPI backend, API, or microservice with SQLAlchemy, Alembic, and clean architecture
In this repository36 other files it gives its agents.
- adrSkill
- analyticsSkill
- api-contractSkill
- api-designSkill
- ci-pipelineSkill
- claude-mdSkill
- code-qualitySkill
- data-modelSkill
- db-migrateSkill
- debugSkill
- deploySkill
- dep-updateSkill
- disk-cleanupSkill
- docker-buildSkill
- eng-leadSkill
- event-drivenSkill
- fullstack-healthcheckSkill
- go-featureSkill
- go-integration-testSkill
- go-refactorSkill
- go-scaffoldSkill
- incident-responseSkill
- interactive-clarifySkill
- observabilitySkill
- onboardingSkill
- product-specSkill
- py-featureSkill
- py-integration-testSkill
- py-migrateSkill
- py-refactorSkill
- react-featureSkill
- react-refactorSkill
- react-scaffoldSkill
- review-codeSkill
- securitySkill
- system-designSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Core principle: Start fully typed. mypy strict from the first file.
- Very specific: line 202
REQUIRED: Update CLAUDE.md with stack, commands, directories, and conventions (claude-md)
- Very specific: line 204
Use docker-build for production Dockerfile
- Very specific: line 205
Use ci-pipeline for GitHub Actions
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Project Scaffold
Overview
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.
Directory Structure
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.mdBootstrap Files
main.py (App Factory)
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 apppyproject.toml
[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"]Makefile
.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)"docker-compose.yml
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:Initial Health Check (TDD)
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"}CLAUDE.md Template
# 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.Chains
- REQUIRED: Update CLAUDE.md with stack, commands, directories, and conventions (
claude-md) - Pairs with
react-scaffoldfor full-stack - Use
docker-buildfor production Dockerfile - Use
ci-pipelinefor GitHub Actions
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

