/engineering:python-modern-standardsfrom engineering
Defines a Python project baseline: uv, ruff, mypy, Pydantic v2, structlog, async rules, pytest, and security, plus PyInstaller/Nuitka packaging.
Ships in engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.
references/api-container-sidecar-engineering.md.docker-development.references/python-desktop-distribution.md and use scripts/desktop_suite_packager.py.| Category | Artifact | Format | Example |
|---|---|---|---|
| Correctness | Test plan | Markdown doc per skill-composition-standards/references/test-plan-template.md covering pytest layout, type checks, and coverage targets | docs/python/test-plan.md |
| Release evidence | Desktop distribution evidence | Manifest, generated build files, artifact inventory, hashes, smoke results, and signing status | release/desktop-suite-evidence.json |
references/ directory for deep detail after reading the core workflow below.references/api-container-sidecar-engineering.md when Python participates in APIs, workers, queues, sidecars, or Dockerized service delivery.references/python-desktop-distribution.md when Python must ship without a separately installed interpreter.The house style for Python in our PHP + Android + iOS SaaS stack. Every Python file in our projects must follow this skill. Other Python skills (saas-integration, data-analytics, document-generation, ml-predictive, data-pipelines) assume you have read this first.
Skill-specific references:
references/project-layout.mdreferences/tooling-uv-ruff.mdreferences/python-version-and-environment-policy.mdreferences/typing-mypy-pyright.mdreferences/pydantic-v2-patterns.mdreferences/logging-structlog.mdreferences/async-vs-sync.mdreferences/error-handling.mdreferences/testing-pytest.mdreferences/security-baseline.mdreferences/anti-patterns.mdreferences/api-container-sidecar-engineering.mdreferences/python-desktop-distribution.mdscripts/desktop_suite_packager.pysrc/ layout with pyproject.toml. No setup.py. No flat layout.os.environ[...].except: — ever. Use a custom exception hierarchy.New services pin 3.13 in .python-version (as of 2026-09-24: 3.13 and 3.14 are bugfix branches; 3.11 and 3.12 are security-only; 3.10 reaches EOL in 2026-10). Do not target <3.11 — pandas 3.0 requires 3.11+, and we rely on match, exception groups, and PEP 695 type parameter syntax (3.12+).
requires-python is a floor, never a ceiling:
[project]
requires-python = ">=3.13" # oldest version CI tests; no upper cap
For version choice, EOL handling, PEP 668 system-Python rules, and per-platform interpreter provisioning, load references/python-version-and-environment-policy.md.
service-name/
|-- pyproject.toml
|-- uv.lock
|-- README.md
|-- .env.example
|-- .gitignore
|-- src/
| `-- service_name/
| |-- __init__.py
| |-- main.py # entrypoint (FastAPI app, worker bootstrap)
| |-- config.py # pydantic-settings Settings
| |-- logging_config.py # structlog setup
| |-- exceptions.py # custom exception hierarchy
| |-- api/ # FastAPI routers (if sidecar)
| |-- workers/ # worker tasks (if queue consumer)
| |-- domain/ # pure business logic, no I/O
| |-- adapters/ # DB, HTTP, file system — anything with I/O
| |-- schemas/ # Pydantic models
| `-- utils/
|-- tests/
| |-- unit/
| |-- integration/
| `-- conftest.py
`-- scripts/ # one-off CLI scripts
See references/project-layout.md for the full pyproject.toml template, monorepo considerations, and when to split a service into multiple packages.
Use uv (Astral). Fast, drop-in replacement for pip + pip-tools + virtualenv. Commit the lockfile.
uv init # bootstrap a project
uv add fastapi # add a dependency
uv add --dev pytest ruff # add to [dependency-groups].dev (PEP 735)
uv sync # install exact versions from lockfile
uv run pytest # run a command in the venv
uv lock --upgrade # upgrade lockfile
Never mix uv with pip, poetry, or pipenv in the same project. See references/tooling-uv-ruff.md.
Treat executable distribution as a release pipeline, not a GUI conversion step. For a suite of tools, prefer a PyInstaller one-folder multipackage build with a generated launcher, shared collection directory, portable ZIP, and platform installer. Keep the product and application list in a committed manifest; generate the spec, launcher, installer, CI workflow, and verification script from it.
Load references/python-desktop-distribution.md, then run:
python -X utf8 scripts/desktop_suite_packager.py init --project-root <project> --product-name "Example Suite" --publisher "Example Ltd" --app "editor=editor.py" --app "converter=converter.py"
python -X utf8 scripts/desktop_suite_packager.py generate --config <project>/packaging/desktop-suite.toml
python -X utf8 scripts/desktop_suite_packager.py doctor --config <project>/packaging/desktop-suite.toml
The script path above is relative to this skill directory. Commit generated project files so CI does not depend on the skills engine being installed on the runner.
Ruff is the only formatter/linter. It replaces black, isort, flake8, pyupgrade, bugbear, and more.
# pyproject.toml
[tool.ruff]
line-length = 100
target-version = "py312"
[tool.ruff.lint]
select = [
"E", "F", "W", # pycodestyle + pyflakes
"I", # isort
"UP", # pyupgrade
"B", # bugbear
"S", # bandit (security)
"C4", # comprehensions
"SIM", # simplify
"RET", # return
"PL", # pylint
"RUF", # ruff-specific
]
ignore = ["E501"] # line length handled by formatter
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101"] # allow assert in tests
Pre-commit hook runs ruff format + ruff check --fix. CI runs ruff check (no auto-fix).
Every function signature has types. No untyped def. Use mypy --strict or pyright --strict in CI. Pick one per project, not both.
# GOOD
def compute_mrr(subscriptions: list[Subscription], as_of: date) -> Decimal:
return sum((s.monthly_price for s in subscriptions if s.is_active(as_of)), Decimal(0))
# BAD
def compute_mrr(subscriptions, as_of):
...
For complex typing (generics, Protocols, TypedDict, overloads, exhaustive matching), see references/typing-mypy-pyright.md.
Use Pydantic v2 models for:
from pydantic import BaseModel, Field, EmailStr
from decimal import Decimal
class InvoiceCreate(BaseModel):
tenant_id: int = Field(..., gt=0)
customer_email: EmailStr
amount: Decimal = Field(..., gt=0, decimal_places=2)
currency: str = Field(..., pattern=r"^[A-Z]{3}$")
model_config = {"frozen": True, "extra": "forbid"}
Never pass raw dicts across module boundaries when you can use a Pydantic model. Do not use Pydantic v1 syntax (@validator, Config class, .dict()). See references/pydantic-v2-patterns.md.
Use structlog. Bind request/tenant/correlation IDs to every log line. JSON output in production, plain console in development.
import structlog
logger = structlog.get_logger()
logger.info("invoice_created", invoice_id=inv.id, tenant_id=inv.tenant_id, amount=str(inv.amount))
Never use print(). Never use f-strings inside log calls — pass structured kwargs so fields are queryable. See references/logging-structlog.md.
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
database_url: str
redis_url: str = "redis://localhost:6379/0"
php_app_base_url: str
internal_shared_secret: str = Field(..., min_length=32)
environment: str = Field(default="development", pattern=r"^(development|staging|production)$")
settings = Settings() # fails fast on startup if anything is missing/invalid
Never call os.environ[...] outside config.py. Never hardcode secrets.
async def, everything it awaits must be async. Never call blocking I/O inside an async handler (use asyncio.to_thread if you must).async def in it. If it's async, don't call .sync() wrappers.See references/async-vs-sync.md.
Define a root app exception and subclass by category. Translate at boundaries (infra exception → domain exception → HTTP response).
class AppError(Exception):
"""Base for all application errors."""
class ValidationError(AppError): ...
class NotFoundError(AppError): ...
class AuthorizationError(AppError): ...
class ExternalServiceError(AppError): ...
class ConfigurationError(AppError): ...
Never except: or except Exception: without re-raising. Log with context, then raise. See references/error-handling.md.
tests/unit/ and tests/integration/ mirroring src/ layout.conftest.py for shared fixtures; one per package level.pytest.mark.parametrize for table-driven tests.pytest -m 'not integration' for fast local loops.See references/testing-pytest.md.
cursor.execute(sql, params)). No f"SELECT ... {user_input}".pip-audit or safety in CI, weekly schedule.ruff with S rules (bandit); semgrep optional for deeper checks.eval, exec, pickle.load from untrusted sources. Never shell=True with user input.references/security-baseline.md for the full checklist, and cross-reference with vibe-security-skill for web-app concerns when the Python service exposes HTTP.def f(x=[])) — use None and initialize inside.from x import * — explicit imports only.async def handlers — will deadlock the event loop.time.sleep in workers — use asyncio.sleep or scheduler delays.except Exception: pass — silences bugs. Always log and re-raise or handle specifically.BaseException — catches KeyboardInterrupt, SystemExit. Don't.os.system() / shell=True with user data — command injection.datetime.now() without tz — use datetime.now(UTC).Decimal vs float confusion for money — always Decimal for currency, never float.See references/anti-patterns.md.
ruff format --check .
ruff check .
mypy --strict src/
pytest --cov=src --cov-fail-under=80
pip-audit
When the task requires it, load:
references/python-saas-integration.md — how Python plugs into PHP + mobile SaaS.python-data-analytics — pandas, KPI computation, financial math.python-document-generation — Excel, Word, PDF output.python-ml-predictive — forecasting, classification, anomaly detection.python-data-pipelines — ETL, OCR, image processing, API syncs.references/python-desktop-distribution.md — executable suites, installers, signing, CI, and clean-machine release checks.| Condition | Action |
|---|---|
| Work is I/O-bound and dependencies support async | Use one coherent async boundary |
| Value crosses an external boundary | Validate it with an explicit typed model |
| Tooling conflicts with repository policy | Preserve policy and document the exception |
Read and search are required. Editing, dependency changes, and execution require authorisation; network access is optional.
Fallback: without execution, provide exact formatter, type-checker, security, and test commands; do not claim compatibility.
| Artefact | Required? | Purpose |
|---|---|---|
| Python version, project layout, dependency policy, and code scope | yes | Apply compatible standards |
references/anti-patterns.md (opens in a new tab)references/api-container-sidecar-engineering.md (opens in a new tab)references/async-vs-sync.md (opens in a new tab)references/error-handling.md (opens in a new tab)references/logging-structlog.md (opens in a new tab)references/project-layout.md (opens in a new tab)references/pydantic-v2-patterns.md (opens in a new tab)references/python-desktop-distribution.md (opens in a new tab)references/python-saas-integration.md (opens in a new tab)references/python-saas-integration/references/background-workers.md (opens in a new tab)references/python-saas-integration/references/deployment-debian.md (opens in a new tab)references/python-saas-integration/references/failure-modes.md (opens in a new tab)references/python-saas-integration/references/fastapi-sidecar.md (opens in a new tab)references/python-saas-integration/references/file-handoff.md (opens in a new tab)references/python-saas-integration/references/observability.md (opens in a new tab)references/python-saas-integration/references/php-python-contract.md (opens in a new tab)references/python-saas-integration/references/tenant-isolation.md (opens in a new tab)references/python-version-and-environment-policy.md (opens in a new tab)references/security-baseline.md (opens in a new tab)references/testing-pytest.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
169 skills in this plugin
/accounting-engineUse when designing or implementing double-entry accounting policy and an embedded ledger engine for invoices, payments, stock, balanced postings, mapped accounts, idempotency, reversals, period locks, audit trails, and financial statements./accounting-finance-controllerUse when coordinating accounting and finance implementation reviews, doctrine routing, control evidence, remediation priorities, and release decisions across a software system./advanced-testing-strategyUse when designing or reviewing test strategy for production systems, APIs, mobile apps, SaaS platforms, ERP workflows, and AI-enabled systems. Covers unit, integration, contract, end-to-end, regression, release-gate, and risk-based testing decisions./ai-agent-commercial-operationsUse when pricing, billing, refunding, recognizing revenue, or packaging commercial terms for agentic AI services, or when defining agent SLAs, customer commitments, SLA dashboards, breach credits, and service evidence./ai-agent-compliance-controlsUse when mapping AI agent operations to SOC 2, ISO 27001, HIPAA, audit logs, control testing, attestations, and compliance evidence, including drill-cadence evidence, approval-completeness (PI1.1) gap checks, and signed agent-memory erasure proofs./ai-agent-governance-and-limitsUse when defining agent budgets, step limits, reversibility, blast-radius controls, kill switches, and governance policy for agentic AI systems.npx claudepluginhub peterbamuhigire/chwezi-dev-engine --plugin engineeringOther plugins' skills for the same job