python
Guidelines when creating, reading, updating, or deleting Python code
When & Why to Use This Skill
This Claude skill establishes a standardized set of Python coding guidelines to ensure high-quality, readable, and maintainable code. It automates the enforcement of best practices such as proper import placement, clear numeric formatting, minimal __init__.py usage, and the use of keyword-only arguments for improved function clarity and API safety.
Use Cases
- Code Quality Enforcement: Automatically apply formatting rules to Python snippets to ensure consistent style and readability across a project.
- Function Signature Optimization: Enforce the use of keyword-only arguments in complex functions to prevent positional argument errors and improve code explicitness.
- Clean Package Architecture: Maintain a lean project structure by preventing unnecessary logic from being added to __init__.py files during package creation.
- Automated Refactoring: Use these guidelines to clean up legacy Python scripts, specifically targeting import organization and numeric literal formatting.
| name | python |
|---|---|
| description | Guidelines when creating, reading, updating, or deleting Python code |
Makefile Formatting
Instructions
imports
Imports should always be at the top of the file. NEVER have local imports unless it is 100% necessary.
formatting
For big numbers, use _ to make numbers more clear
BAD: foo = 1000
GOOD: foo = 1_000
init.py files
Do not add anything inside of __init__.py files unless it is absolutely necessary or you are explicitly asked to.
function parameters
Functions with more than 1 parameter should use * to enforce keyword arguments.
BAD: def foo(a, b, c): ...
GOOD: def foo(*, a, b, c): ...