python-style
Apply Python best practices when reviewing or writing code, including PEP 8, type annotations, docstrings, and common anti-patterns to avoid.
When & Why to Use This Skill
This Claude skill automates the enforcement of Python best practices, ensuring high-quality code through PEP 8 compliance, comprehensive type annotations, and standardized docstrings. It helps developers identify common anti-patterns—such as mutable default arguments and improper exception handling—streamlining the code review process for cleaner, more maintainable, and professional software development.
Use Cases
- Automated Pull Request Reviews: Use the skill to automatically scan incoming code changes for PEP 8 compliance and documentation standards before human review.
- Legacy Code Refactoring: Identify and fix common Python anti-patterns and missing type hints in older codebases to improve readability and type safety.
- Developer Onboarding and Mentorship: Provide real-time, consistent feedback to junior developers on Pythonic idioms and industry-standard coding styles.
- Type Safety Audits: Systematically check public APIs and functions for missing PEP 484 type annotations to reduce runtime bugs and improve IDE intellisense.
| name | python-style |
|---|---|
| description | Apply Python best practices when reviewing or writing code, including PEP 8, type annotations, docstrings, and common anti-patterns to avoid. |
Python Style Skill
Apply Python best practices when reviewing or writing code.
Style Guidelines
- Follow PEP 8 for formatting
- Use type annotations for all public functions (PEP 484)
- Write docstrings for public APIs (PEP 257)
- Prefer f-strings over .format() or % formatting
Common Issues to Flag
- Missing type annotations on public functions
- Mutable default arguments (def foo(items=[]))
- Bare except clauses (except: instead of except Exception:)
- Using assert for validation (stripped in optimized mode)
References
- PEP 8: https://peps.python.org/pep-0008/
- PEP 484: https://peps.python.org/pep-0484/
- PEP 257: https://peps.python.org/pep-0257/