# Cheneeheng Agent Skills Scaffold Python Service

> Scaffold a Python Service

- Skill: `tomevault-io/cheneeheng-agent-skills-scaffold-python-service` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/cheneeheng-agent-skills-scaffold-python-service`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/cheneeheng-agent-skills-scaffold-python-service/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/cheneeheng-agent-skills-scaffold-python-service

---


# Scaffold a Python Service

Organize by concern, not by file type. Each layer has one job.

```
project/
├── backend/
│   ├── app/
│   │   ├── api/           # Thin route handlers — validate input, call service, return output
│   │   ├── core/          # Config, dependencies, exceptions, middleware
│   │   ├── models/        # Pydantic request/response + domain models
│   │   ├── services/      # Business logic — no HTTP, no SQL
│   │   └── db/            # Database queries — SQL only, no business logic
│   └── tests/
│       ├── unit/
│       ├── integration/
│       └── system/
├── migrations/            # Database migrations (Alembic)
├── pyproject.toml
└── .gitignore
```

## Hard Layer Rules

- Route handlers contain no business logic — they call services
- Services contain no SQL — they call the database layer
- Database layer contains no business logic — it executes SQL
- One mutation path per aggregate — if multiple services could write the same table, define a single state manager

## Initial Config

- `pyproject.toml` with uv, ruff, mypy, pytest config — see `ceh-python-service:python-service-environment`.
- Web service deps: `fastapi`, `uvicorn[standard]`, `pydantic-settings`, `asyncpg`, `alembic`, `structlog`.

## .gitignore

```
.venv/
.env
.env.*
!.env.example
__pycache__/
*.pyc
*.egg-info/
.coverage
.pytest_cache/
.mypy_cache/
.ruff_cache/
dist/
build/
*.db
.DS_Store
```

---
> Source: [cheneeheng/agent-skills](https://github.com/cheneeheng/agent-skills) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-06-15 -->

