Python Best Practices

February 20, 2026 ยท View on GitHub

License: MIT Skills

Modern Python 3.12+ patterns your AI agent should use. Type hints with X | Y syntax, Pydantic v2, uv package manager, match statements, pathlib, pyproject.toml, TaskGroup, and PEP 695 generics.

AI coding assistants generate from typing import List, Union, Optional, use Pydantic v1 decorators, create setup.py, and reach for os.path instead of pathlib. This plugin keeps your agent on Python 3.12+ patterns.

Install

Cursor / Claude Code / Windsurf

npx skills add ofershap/python-best-practices

Or copy skills/ into your .cursor/skills/ or .claude/skills/ directory.

What's Included

TypeNameDescription
Skillpython-best-practices15 rules for type hints, Pydantic v2, uv, pathlib, match/case, TaskGroup, and more
Rulebest-practicesAlways-on behavioral rule that enforces Python 3.12+ patterns
Command/auditScan your codebase for outdated Python patterns

What Agents Get Wrong

What the agent writesWhat Python 3.12+ uses
from typing import List, Union, Optionallist[str], X | Y, X | None
@validator, @root_validatorfield_validator, model_validator (Pydantic v2)
class Config: in Pydantic modelsmodel_config = ConfigDict(...)
os.path.join(), string pathspathlib.Path for all file operations
setup.py, requirements.txtpyproject.toml with uv
TypeVar("T") + Generic[T]def f[T](x: T) -> T (PEP 695)
asyncio.gather()TaskGroup for structured concurrency

If this helped your workflow, a star helps others find it.

Author

Made by ofershap

LinkedIn GitHub

License

MIT