python-best-practices
/python-best-practices
Python 3.13+ conventions for typed application and library boundaries. Use when writing or reviewing Python contracts, packages, validation, or async resource ownership.
- Author
- Casper-Studios ↗
- Repository
- casper-marketplace ↗
- Licence
- MPL-2.0
- Last repository change
- 05.09.2026
Assessment and security
- Files in this package
- 19
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 1
No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.
MPL-2.0, otwarta.
What it does and when to use it
Python 3.13+ conventions for typed application and library boundaries. Use when writing or reviewing Python contracts, packages, validation, or async resource ownership.
Original author description
Python 3.13+ conventions for typed application and library boundaries. Use when writing or reviewing Python contracts, packages, validation, or async resource ownership.
How it works
- Effective Strategies for Python
SKILL.md preview
--- name: python-best-practices description: Python 3.13+ conventions for typed application and library boundaries. Use when writing or reviewing Python contracts, packages, validation, or async resource ownership. license: MPL-2.0 metadata: author: 'Basti Ortiz <ortiz@bastidood.dev>' source: 'https://github.com/BastiDood/skills' --- # Python Best Practices This skill applies modern Python mechanisms without adding annotation or packaging ceremony. It favors inference, precise structural contracts, explicit runtime validation, side-effect-free imports, and context-managed resource ownership. ## Effective Strategies for Python Read the linked guidance that governs the current task before writing or reviewing Python. 1. Make type contracts precise without annotation ceremony. - Let the checker infer obvious implementation results; add [annotations](./references/inference-and-annotations.md) only when inference cannot express the contract. - Depend on the smallest required behavior with [protocols](./references/protocols.md), not a vendor's concrete client. - In Python 3.13+, express caller-relevant relationships with [PEP 695 generics](./references/pep-695-generics.md), avoiding module-level `TypeVar` declarations and needless generics. - Make a new finite-state member a type-checking failure with [exhaustive handling](./references/finite-state-exhaustiveness.md). - Narrow [optional values](./references/optional-narrowing.md) before use so the owning layer—not a cast or fabricated fallback—decides whether absence is preserved or rejected. 2. Validate untrusted data and make invalid states explicit. - Parse serialized input once at the controlled [boundary](./references/boundary-validation.md) so untrusted mappings do not spread inward. - Do not turn missing required data into a plausible value; [preserve absence or fail](./references/no-fabricated-defaults.md) at the owning boundary. - Keep required runtime checks active under optimization; [do not use assertions](./references/no-runtime-asserts.md) for validation. - Catch only expected exceptions at the operation that raises them through [narrow exception handling](./references/exception-handling.md). 3. Keep packages explicit, inert, and independently distributable. - Keep imports inert and consumer-facing names deliberate with [explicit public exports](./references/public-exports.md). - Prevent checkout-dependent imports by following the [Python naming and `src` layout](./references/naming-and-src-layout.md). - Publish intentional inline types with [`py.typed`, reserving third-party stubs](./references/py-typed-and-stubs.md) for dependencies that lack complete inline types instead of adding markers merely to silence diagnostics. - Give every independently buildable distribution its own declared [metadata](./references/project-metadata.md) and direct dependencies. - Make packaging errors visible by [not mutating import paths](./references/no-import-path-mutation.md). 4. Keep asynchronous resource and traversal ownership visible. - Make async cleanup inseparable from acquisition with [async context managers](./references/async-context-managers.md). - Preserve page boundaries and consumer control over remote traversal through [async pagination](./references/async-pagination.md).
Files in this package (19)
- LICENSE.txt 16 KB
- SKILL.md 3 KB
- agents/openai.yaml 1 KB
- references/async-context-managers.md 1 KB
- references/async-pagination.md 1 KB
- references/boundary-validation.md 1 KB
- references/exception-handling.md 1 KB
- references/finite-state-exhaustiveness.md 1 KB
- references/inference-and-annotations.md 1 KB
- references/naming-and-src-layout.md 1 KB
- references/no-fabricated-defaults.md 1 KB
- references/no-import-path-mutation.md 1 KB
- references/no-runtime-asserts.md 1 KB
- references/optional-narrowing.md 1 KB
- references/pep-695-generics.md 1 KB
- references/project-metadata.md 1 KB
- references/protocols.md 1 KB
- references/public-exports.md 1 KB
- references/py-typed-and-stubs.md 1 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · Casper-Studios/casper-marketplace | 90 | MPL-2.0 |
| jefflester/claude-skills-supercharged | 100 | MIT |
| NoesisVision/nasde-toolkit | 100 | MIT |
| thinx-pro/pythonic-skills | 100 | MIT |
| alleneubank/claude-code | 100 | Apache-2.0 |
| jkitchin/skillz | 95 | MIT |
| bastidood/skills | 90 | MPL-2.0 |
| HoangNguyen0403/agent-skills-standard | 90 | MIT |
| the-aios/aios | 90 | LGPL |
Database snapshot: 13.11.2026 · package version 6bdbf6c284ee (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 90typescript-best-practices
TypeScript conventions for precise contracts and valid program states. Use when writing or reviewing TypeScript types, state models, optional values, or untrusted boundaries. - 95python-style
Python coding and testing conventions for MLflow. Use when writing, modifying, or reviewing Python source files and tests in this repository. - 95python-style
Applies Python coding conventions when writing, reviewing, or refactoring code. Covers .py files, docstrings, type annotations, naming, formatting, error handling, imports, file ordering, and ataraxis library preferences. Use when writing new Python code, modifying existing… - 100zod-best-practices
Zod v4 conventions for owned wire contracts and explicit validation outcomes. Use when defining or reviewing Zod schemas or parsing untrusted data with Zod. - 100python
Python language conventions, modern idioms, and toolchain. Invoke whenever task involves any interaction with Python code — writing, reviewing, refactoring, debugging, or understanding Python projects. - 90react-best-practices
React component conventions for explicit state ownership and data flow. Use when creating or reviewing React components, hooks, effects, or forms.