python-expert-best-practices-code-review
Python best practices for writing production-grade code. This skill should be used when writing, reviewing, or refactoring Python code. Triggers on tasks involving Python development, error handling patterns, dictionary operations, and code quality improvements.
Install
npx skills add https://github.com/wispbit-ai/skills --skill python-expert-best-practices-code-reviewSKILL.md
Python 3.14+ Expert Best Practices
Simple, pragmatic, opinionated. Only what matters for writing production-grade python code.
When to Apply
Reference these guidelines when:
- Writing Python functions, classes, or modules
- Reviewing Python code for error handling issues
- Refactoring existing Python codebases
- Implementing data validation and API boundaries
- Optimizing error detection and debugging patterns
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Error Handling | CRITICAL | dict-, operators- |
| 2 | Common Bugs | CRITICAL-HIGH | no-mutable-, no-generic- |
| 3 | Code Clarity | HIGH-MEDIUM | listcomp-, no-inline- |
| 4 | Code Style | LOW | avoid-, unnecessary- |
Quick Reference
dict-required-keys- Used[key]for required dictionary keys to fail fast with KeyErrorno-mutable-defaults- No mutable defaults in function/method parametersoperators-return-notimplemented- Return NotImplemented for unsupported operand types and design + vs += intentionallyno-generic-except- Avoid generic except clauses to prevent hiding unexpected errorslistcomp-no-side-effects- List comprehensions must produce a value you use (no side-effect listcomps)no-inline-imports- Place all import statements at the top of the fileavoid-explanatory-comments- Avoid unnecessary comments for self-documenting codeunnecessary-else-blocks- Avoid unnecessary else blocks after return/break/continue statements
How to Use
Read individual rule files for detailed explanations and code examples:
rules/dict-required-keys.md
rules/no-mutable-defaults.md
rules/operators-return-notimplemented.md
rules/no-generic-except.md
rules/listcomp-no-side-effects.md
rules/no-inline-imports.md
rules/avoid-explanatory-comments.md
rules/unnecessary-else-blocks.md
Each rule file contains:
- Brief explanation of why it matters
- When to use and when not to use the pattern
- Implementation requirements
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
Related skills
improve-codebase-architecturemattpocock1MScan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.codebase-designmattpocock691KShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.web-design-guidelinesvercel-labs676KReview UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".code-reviewmattpocock631KReview the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/spec asked for?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to \"review since X\".