registry/skills/modern-python-development/SKILL.md
This skill should be used when the user asks to "write Python code", "create a Python module", "set up a Python project", "review Python code", "refactor Python", "add type hints", "fix Python style", or when generating any Python source code. Provides modern Python 3.12+ best practices covering syntax, type hints, error handling, project structure, and idiomatic patterns. Does not cover any specific library or framework.
npx skillsauth add provectus/awos-recruitment modern-python-developmentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Pure Python best practices for writing clean, idiomatic, and type-safe code. All guidance targets Python 3.12+ and covers only the standard language and stdlib — no third-party libraries or frameworks.
| Element | Convention | Example |
|------------------|-------------------|-------------------------------|
| Module | snake_case | data_loader.py |
| Package | lowercase | utils/, core/ |
| Class | PascalCase | UserAccount |
| Function/Method | snake_case | get_user_by_id() |
| Variable | snake_case | retry_count |
| Constant | UPPER_SNAKE | MAX_RETRIES |
| Type alias | PascalCase | type UserId = int |
| Private | _leading | _internal_cache |
| Name-mangled | __double | __secret (rarely needed) |
| Dunder | __name__ | Reserved for Python protocols |
Prefix boolean variables and functions with is_, has_, can_, or should_.
| Legacy | Modern (3.12+) |
|-------------------------------------|-----------------------------------|
| Union[X, Y] | X \| Y |
| Optional[X] | X \| None |
| TypeAlias = ... | type Alias = ... |
| List[str], Dict[str, int] | list[str], dict[str, int] |
| Tuple[int, ...] | tuple[int, ...] |
| if/elif/elif chains on a value | match/case |
| os.path.join() | pathlib.Path |
| "{}".format(x) | f"{x}" |
Use match/case for value dispatch, destructuring, and type narrowing — not as a simple switch replacement. See references/modern-syntax.md for detailed patterns.
match command:
case {"action": "move", "direction": str(d)}:
handle_move(d)
case {"action": "quit"}:
handle_quit()
case _:
handle_unknown(command)
type statement (3.12+)type Vector = list[float]
type Result[T] = T | Error
type Handler[**P] = Callable[P, Awaitable[None]]
Apply type hints to all function signatures, class attributes, and module-level variables. Omit return type only for __init__.
def calculate_total(items: list[float], *, tax_rate: float = 0.0) -> float:
...
Key rules:
list[str], dict[str, int], tuple[int, ...], set[str]X | None instead of Optional[X]type statement for aliases, not bare assignmentProtocol over ABC when only structural typing is needed@override decorator (3.12+) when overriding base class methodsSelf for methods returning the instance typeFor comprehensive typing patterns including generics, Protocol, TypeGuard, TypeVar, and ParamSpec, consult references/type-hints.md.
Define domain errors as a hierarchy inheriting from a project-level base:
class AppError(Exception):
"""Base for all application errors."""
class ValidationError(AppError):
"""Invalid input data."""
class NotFoundError(AppError):
"""Requested resource does not exist."""
except:.raise NewError(...) from original.ExceptionGroup and except* for concurrent error aggregation.with statement) for resource cleanup — avoid manual try/finally.try:
async with TaskGroup() as tg:
tg.create_task(validate_name(data))
tg.create_task(validate_email(data))
except* ValidationError as eg:
errors = eg.exceptions
Prefer dataclasses for data containers. Use __slots__ for memory-critical paths.
from dataclasses import dataclass, field
@dataclass(frozen=True, slots=True)
class Coordinate:
x: float
y: float
label: str = ""
tags: list[str] = field(default_factory=list)
frozen=True for value objects and immutable data.slots=True (3.10+) to reduce memory and prevent attribute typos.kw_only=True when the class has more than 3 fields.field(default_factory=...) for mutable defaults.Follow the src layout for any project intended to be packaged or tested:
project-name/
├── pyproject.toml
├── src/
│ └── package_name/
│ ├── __init__.py
│ ├── core/
│ ├── models/
│ └── utils/
├── tests/
│ ├── conftest.py
│ ├── unit/
│ └── integration/
└── scripts/
Key conventions:
pyproject.toml.src/ layout prevents accidental imports from the working directory.__init__.py files minimal — define the public API, not implementation.users/ over services/).For complete project structure guidance including pyproject.toml conventions, module organization, and entry points, consult references/project-structure.md.
pathlib.Path for all file system operations.enum.Enum / enum.StrEnum for fixed sets of values.contextlib.contextmanager for simple resource management.functools.cache / functools.lru_cache for memoization.itertools for iterator composition.collections.abc for abstract container checks.total = sum(item.price for item in cart) # generator — no intermediate list
if (match := pattern.search(line)) is not None:
process(match.group(1))
__all__ for public API__all__ = ["UserService", "create_user", "UserError"]
For comprehensive patterns including Protocols, ABCs, descriptors, context managers, enums, and more, consult references/patterns.md.
For detailed guidance beyond this overview, consult:
references/modern-syntax.md — Structural pattern matching, type statement, exception groups, @override, f-string detailsreferences/type-hints.md — Generics, Protocol, TypeGuard, TypeVar, ParamSpec, Self, Overloadreferences/patterns.md — Idiomatic patterns: Protocols, enums, context managers, generators, pathlib, ABCreferences/project-structure.md — pyproject.toml conventions, src layout, module organization, entry points, __init__.py patternsdevelopment
Insurance underwriting domain knowledge for building automated submission processing systems. Covers submission-to-bind lifecycle, document extraction patterns, compliance gates (sanctions, licensing, clearance), human-in-the-loop design for regulated financial services, confidence calibration for extracted fields, operating mode progression (manual to automated), and evidence traceability requirements. Use when designing or implementing underwriting pipelines, extraction agents, compliance workflows, HITL review systems, or decision package assembly for insurance or MGA operations.
development
This skill should be used when the user asks to "write TypeScript code", "create a TypeScript module", "define TypeScript types", "add type annotations", "use generics", "handle errors in TypeScript", "set up tsconfig", "organize TypeScript project", or when writing any TypeScript code that is not tied to a specific library or framework. Covers type system, strict mode, naming conventions, error handling, async patterns, and project structure.
development
Use when working with Terraform or OpenTofu - creating modules, writing tests (native test framework, Terratest), setting up CI/CD pipelines, reviewing configurations, choosing between testing approaches, debugging state issues, implementing security scanning (trivy, checkov), or making infrastructure-as-code architecture decisions. Enforces Provectus opinionated conventions (exact version pinning, etc.) on top of community best practices.
development
This skill should be used when the user asks to "write Swift code", "create a Swift type", "set up a Swift package", "review Swift code", "refactor Swift", "use async/await in Swift", "fix Swift style", or when generating any Swift source code regardless of target platform. Provides modern Swift 6+ best practices covering type system, optionals, concurrency, error handling, protocols, generics, and idiomatic patterns. Does not cover any specific platform or framework.