Python Project
Scaffold production-grade Python repositories with conservative defaults inspired by services/vpngw.
Use This Skill For
- Creating a new Python project from scratch.
- Standardizing an existing Python repo layout and tooling.
- Adding or improving:
- CLI applications
- systemd services/timers
- API services and UI apps
- IaC and automation integration
- security and networking controls
- AI/ML pipelines and model-serving structure
Defaults (vpngw-aligned)
pyproject.toml with PEP 621 metadata.
setuptools + setuptools-scm for build/versioning.
src/ package layout.
ruff for linting/formatting checks.
pytest for tests.
Typer + Rich for CLI UX.
Pydantic for config/schema validation.
Makefile with .DEFAULT_GOAL := all and aggregate all target (for example all: check build).
- Optional packaged systemd assets in
src/<package>/systemd/.
Workflow
- Gather missing essentials only:
- Project name (distribution) and import package name.
- Python version range (default:
>=3.11,<3.14).
- Workload profile(s):
cli, systemd, api, ui, iac, automation, security, networking, ai-ml.
- Runtime target (local VM, container, Kubernetes, hybrid).
- Start from
references/base-layout.md and assets/pyproject.toml.template.
- Load only relevant profile references:
references/cli-systemd.md
references/api-ui.md
references/iac-automation-security-networking.md
references/ai-ml.md
- Generate scaffolding and output in this order:
- Directory tree
- Full file contents (one file at a time)
- Exact bootstrap/lint/test/build/run commands
- Security + operations checklist
- Keep placeholders (
TODO) for environment-specific values and never invent secrets.
Output Contract
Always include:
pyproject.toml
.gitignore
README.md
src/<package>/__init__.py
src/<package>/__main__.py
tests/
Add these when selected:
cli: src/<package>/cli.py and [project.scripts].
systemd: src/<package>/systemd/*.service and optional *.timer, plus package-data configuration.
api: src/<package>/api.py (ASGI app) and production run guidance.
ui: src/<package>/ui.py and auth/network boundary notes.
iac: infra/terraform/ (or point to $terraform skill for full scaffolding).
automation: Makefile, .github/workflows/ci.yml, .pre-commit-config.yaml.
Makefile must set .DEFAULT_GOAL := all.
Makefile must include an all target that aggregates primary checks/build.
ai-ml: src/<package>/ml/ split for train/eval/infer pipelines.
Non-Negotiable Guardrails
- No secret material in repo, samples, logs, tests, or docs.
- Ignore runtime, build, cache, credential, and local config artifacts.
- Prefer bounded dependency ranges (
>=x,<y) and avoid unconstrained pins unless required.
- Keep commands idempotent where practical.
- Use typed boundaries for external inputs (Pydantic models/dataclasses).
- Return explicit non-zero exit codes for CLI failures.
- Avoid shelling out when a Python API exists; if shell is required, set explicit timeouts and sanitize args.
- Keep networking code timeout-safe and retry-safe.
Versioning and Release Pattern
Default to setuptools-scm with SemVer tags:
- Tag format:
<project>-vMAJOR.MINOR.PATCH
- Generated runtime version file:
src/<package>/_version.py
- Do not manually edit the version in
pyproject.toml when SCM versioning is enabled.
For containerized/Helm-delivered apps, keep version layers related but independent:
- App version (source of functional behavior):
- Image version (source of deployed artifact):
- publish immutable tags (
sha-<shortsha>, and release tags like X.Y.Z + X.Y.Z-g<shortsha>).
- prefer production deploys pinned by digest.
- Helm chart versioning:
Chart.yaml.version tracks chart packaging changes.
Chart.yaml.appVersion tracks the default app/image SemVer.
- do not force chart
version to equal app SemVer.
Templates and References
assets/pyproject.toml.template: baseline vpngw-style project metadata and tooling.
assets/cli.py.template: Typer-based CLI starter.
assets/api.py.template: FastAPI starter with health endpoint.
assets/systemd.service.template: hardened service unit baseline.
assets/github-actions-ci.yml.template: minimal CI for lint/test/build.
Use detailed references only when needed:
references/base-layout.md
references/cli-systemd.md
references/api-ui.md
references/iac-automation-security-networking.md
references/ai-ml.md
1---2name: python-project3description: Scaffold and harden Python projects using vpngw-aligned defaults (pyproject/setuptools-scm, src layout, Ruff, pytest, Typer, Pydantic) plus best practices for CLI tools, systemd services, APIs/UI apps, IaC/automation, security/networking, and AI/ML workflows.4---56# Python Project78Scaffold production-grade Python repositories with conservative defaults inspired by `services/vpngw`.910## Use This Skill For1112- Creating a new Python project from scratch.13- Standardizing an existing Python repo layout and tooling.14- Adding or improving:15 - CLI applications16 - systemd services/timers17 - API services and UI apps18 - IaC and automation integration19 - security and networking controls20 - AI/ML pipelines and model-serving structure2122## Defaults (vpngw-aligned)2324- `pyproject.toml` with PEP 621 metadata.25- `setuptools` + `setuptools-scm` for build/versioning.26- `src/` package layout.27- `ruff` for linting/formatting checks.28- `pytest` for tests.29- `Typer` + `Rich` for CLI UX.30- `Pydantic` for config/schema validation.31- `Makefile` with `.DEFAULT_GOAL := all` and aggregate `all` target (for example `all: check build`).32- Optional packaged systemd assets in `src/<package>/systemd/`.3334## Workflow35361. Gather missing essentials only:37 - Project name (distribution) and import package name.38 - Python version range (default: `>=3.11,<3.14`).39 - Workload profile(s): `cli`, `systemd`, `api`, `ui`, `iac`, `automation`, `security`, `networking`, `ai-ml`.40 - Runtime target (local VM, container, Kubernetes, hybrid).412. Start from `references/base-layout.md` and `assets/pyproject.toml.template`.423. Load only relevant profile references:43 - `references/cli-systemd.md`44 - `references/api-ui.md`45 - `references/iac-automation-security-networking.md`46 - `references/ai-ml.md`474. Generate scaffolding and output in this order:48 - Directory tree49 - Full file contents (one file at a time)50 - Exact bootstrap/lint/test/build/run commands51 - Security + operations checklist525. Keep placeholders (`TODO`) for environment-specific values and never invent secrets.5354## Output Contract5556Always include:5758- `pyproject.toml`59- `.gitignore`60- `README.md`61- `src/<package>/__init__.py`62- `src/<package>/__main__.py`63- `tests/`6465Add these when selected:6667- `cli`: `src/<package>/cli.py` and `[project.scripts]`.68- `systemd`: `src/<package>/systemd/*.service` and optional `*.timer`, plus package-data configuration.69- `api`: `src/<package>/api.py` (ASGI app) and production run guidance.70- `ui`: `src/<package>/ui.py` and auth/network boundary notes.71- `iac`: `infra/terraform/` (or point to `$terraform` skill for full scaffolding).72- `automation`: `Makefile`, `.github/workflows/ci.yml`, `.pre-commit-config.yaml`.73 - `Makefile` must set `.DEFAULT_GOAL := all`.74 - `Makefile` must include an `all` target that aggregates primary checks/build.75- `ai-ml`: `src/<package>/ml/` split for train/eval/infer pipelines.7677## Non-Negotiable Guardrails7879- No secret material in repo, samples, logs, tests, or docs.80- Ignore runtime, build, cache, credential, and local config artifacts.81- Prefer bounded dependency ranges (`>=x,<y`) and avoid unconstrained pins unless required.82- Keep commands idempotent where practical.83- Use typed boundaries for external inputs (Pydantic models/dataclasses).84- Return explicit non-zero exit codes for CLI failures.85- Avoid shelling out when a Python API exists; if shell is required, set explicit timeouts and sanitize args.86- Keep networking code timeout-safe and retry-safe.8788## Versioning and Release Pattern8990Default to `setuptools-scm` with SemVer tags:9192- Tag format: `<project>-vMAJOR.MINOR.PATCH`93- Generated runtime version file: `src/<package>/_version.py`94- Do not manually edit the version in `pyproject.toml` when SCM versioning is enabled.9596For containerized/Helm-delivered apps, keep version layers related but independent:9798- App version (source of functional behavior):99 - SemVer from tags.100- Image version (source of deployed artifact):101 - publish immutable tags (`sha-<shortsha>`, and release tags like `X.Y.Z` + `X.Y.Z-g<shortsha>`).102 - prefer production deploys pinned by digest.103- Helm chart versioning:104 - `Chart.yaml.version` tracks chart packaging changes.105 - `Chart.yaml.appVersion` tracks the default app/image SemVer.106 - do not force chart `version` to equal app SemVer.107108## Templates and References109110- `assets/pyproject.toml.template`: baseline vpngw-style project metadata and tooling.111- `assets/cli.py.template`: Typer-based CLI starter.112- `assets/api.py.template`: FastAPI starter with health endpoint.113- `assets/systemd.service.template`: hardened service unit baseline.114- `assets/github-actions-ci.yml.template`: minimal CI for lint/test/build.115116Use detailed references only when needed:117118- `references/base-layout.md`119- `references/cli-systemd.md`120- `references/api-ui.md`121- `references/iac-automation-security-networking.md`122- `references/ai-ml.md`