python-expert-best-practices-code-review

Reviews Python code against eight opinionated best-practice rules for error handling and clarity.

Updated Aug 28, 2026
One-click install
npx skills add https://github.com/Yash-Awasthi/adapfit --skill python-expert-best-practices-code-review-yash-awasthi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-expert-best-practices-code-review
Source: https://github.com/Yash-Awasthi/adapfit/tree/main/.agents/skills/python-expert-best-practices-code-review
Command: npx skills add https://github.com/Yash-Awasthi/adapfit --skill python-expert-best-practices-code-review-yash-awasthi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Python codebases often hide subtle bugs like mutable default arguments, masked missing dictionary keys, and generic exception handlers that surface far from their root cause. This Skill provides a prioritized, opinionated rule set for writing, reviewing, and refactoring production-grade Python code. ## Core Features & Use Cases - Prioritized Rule Set: Eight rules ranked by impact, from CRITICAL error-handling patterns (fail-fast dictionary access, no mutable defaults, NotImplemented in operators) to LOW-priority style guidance. - Detailed Rule References: Each rule file includes incorrect and correct code examples, implementation requirements, and guidance on when the pattern applies. - Use Case: When reviewing a pull request that uses payload.get("user_id") for a required field, apply the dict-required-keys rule to recommend direct indexing so missing keys fail fast with KeyError instead of causing delayed None errors downstream. ## Quick Start Review my Python module for error handling issues and common bugs using the Python best practices rules.

Frequently Asked Questions about python-expert-best-practices-code-review

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review Python code for common bugs and error handling issues?▼

Apply a prioritized rule set covering the most damaging patterns first: mutable default arguments, masked required dictionary keys, and generic except clauses. Each rule includes incorrect and correct code examples so reviewers can identify violations and suggest concrete fixes.

Why should I use d[key] instead of dict.get() in Python?▼

Use d[key] when the key is required so missing keys fail fast with KeyError at the source. Using dict.get() masks missing keys as None, causing errors to appear far from the root cause. Reserve dict.get(key, default) for genuinely optional keys with meaningful defaults.

Why are mutable default arguments dangerous in Python functions?▼

Mutable defaults like [] or {} are evaluated once at function definition time and shared across all calls, so mutations persist between invocations. Use None as the default and create a new mutable object inside the function body instead.

When should Python operators return NotImplemented instead of raising TypeError?▼

Return NotImplemented in __add__ and similar dunder methods when the operand type is unsupported, allowing Python to try reverse operations like __radd__. In-place operators like __iadd__ must always return self and can accept broader types than their binary counterparts.

What are the limitations of rule-based Python code review guidelines?▼

Opinionated rules cover common high-impact patterns but cannot catch domain-specific logic errors or architectural issues. They work best as a review checklist alongside testing and type checking, not as a replacement for them.