Python Project
python-project
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.
SKILL.md
Full skill instructions
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.tomlwith PEP 621 metadata.setuptools+setuptools-scmfor build/versioning.src/package layout.rufffor linting/formatting checks.pytestfor tests.Typer+Richfor CLI UX.Pydanticfor config/schema validation.Makefilewith.DEFAULT_GOAL := alland aggregatealltarget (for exampleall: 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.mdandassets/pyproject.toml.template. - Load only relevant profile references:
references/cli-systemd.mdreferences/api-ui.mdreferences/iac-automation-security-networking.mdreferences/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.gitignoreREADME.mdsrc/<package>/__init__.pysrc/<package>/__main__.pytests/
Add these when selected:
cli:src/<package>/cli.pyand[project.scripts].systemd:src/<package>/systemd/*.serviceand optional*.timer, plus package-data configuration.api:src/<package>/api.py(ASGI app) and production run guidance.ui:src/<package>/ui.pyand auth/network boundary notes.iac:infra/terraform/(or point to$terraformskill for full scaffolding).automation:Makefile,.github/workflows/ci.yml,.pre-commit-config.yaml.Makefilemust set.DEFAULT_GOAL := all.Makefilemust include analltarget 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.tomlwhen SCM versioning is enabled.
For containerized/Helm-delivered apps, keep version layers related but independent:
- App version (source of functional behavior):
- SemVer from tags.
- Image version (source of deployed artifact):
- publish immutable tags (
sha-<shortsha>, and release tags likeX.Y.Z+X.Y.Z-g<shortsha>). - prefer production deploys pinned by digest.
- publish immutable tags (
- Helm chart versioning:
Chart.yaml.versiontracks chart packaging changes.Chart.yaml.appVersiontracks the default app/image SemVer.- do not force chart
versionto 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.mdreferences/cli-systemd.mdreferences/api-ui.mdreferences/iac-automation-security-networking.mdreferences/ai-ml.md
