python
Guidelines when creating, reading, updating, or deleting Python code
Security Assessment
About python
The Python skill provides structured guidelines for creating, reading, updating, and maintaining Python code in a consistent and professional manner. It addresses common issues in Python development, such as improper imports, unclear number formatting, misuse of function parameters, and unnecessary content in special files like `__init__.py`. By following these guidelines, developers can produce more readable, maintainable, and error-resistant Python code, reducing technical debt and improving team collaboration.
This skill emphasizes best practices in several key areas. Imports should always be declared at the top of the file, avoiding local imports unless absolutely necessary. Large numeric literals should use underscores for readability, and functions should enforce keyword arguments for clarity, especially when they have multiple parameters. Special Python files like `__init__.py` should remain empty unless explicitly required, and default parameter values should be used sparingly. Overall, the skill ensures that Python code adheres to clear conventions that promote quality and maintainability.
Target users include Python developers, code reviewers, and development teams looking to standardize coding practices across projects. It is particularly useful for teams aiming to maintain large codebases, reduce errors, and improve readability. The skill can also support onboarding new developers by providing a clear set of coding rules and expectations, ensuring consistent style and behavior across all Python modules.
FAQ
Where should imports be placed in a Python file?
Imports should always be at the top of the file. Local imports should be avoided unless absolutely necessary.
How should large numbers be formatted?
Large numbers should use underscores for clarity. For example, use `1_000` instead of `1000`.
Should `__init__.py` files contain code or declarations like `__all__`?
No, `__init__.py` files should remain empty unless absolutely necessary or explicitly requested.
How should functions with multiple parameters be defined?
Functions with more than one parameter should enforce keyword arguments using `*`. For example, `def foo(*, a, b, c): ...`.
When can default parameter values be used?
Default parameter values should only be set if there is an extremely sane and necessary default.
Install python
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
joeyagreco/dotfiles