python-best-practices

Applies 75 prioritized Python engineering rules when writing, reviewing, or refactoring Python code.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Python codebases accumulate subtle defects — mutable default arguments, naive datetimes, ambiguous mutation contracts, and type-safety drift — that slip past casual review. This Skill gives an AI agent a structured, impact-prioritized rulebook derived from real PR review patterns so code generation and review follow consistent, defensible engineering standards. ## Core Features & Use Cases - 75 rules across 8 categories: Data Modeling, Error Handling, Type Safety, API Design, Code Simplification, Performance, Naming, and Imports & Structure, each tagged with an impact level from CRITICAL to LOW. - Incorrect/Correct code pairs with counter-signals: every rule shows a bad pattern, the fix, and an explicit "when NOT to apply" paragraph so rules are applied with judgment rather than as blanket refactors. - Version-aware guidance: rules assume Python 3.11+ and call out version-specific features (e.g., warnings.deprecated on 3.13+, assert_never on 3.11+) plus Pydantic-specific applicability tags. - Use Case: While reviewing a new FastAPI service module, the agent flags a shared mutable default argument (CRITICAL), suggests a discriminated union instead of an optional-field bag, and cites the exact rule file for each finding. ## Quick Start Ask the agent to review your Python module or write a new data model using the python-best-practices guidelines and report findings by impact level.

Frequently Asked Questions about python-best-practices

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

FAQPage Schema
How do I review Python code for common bugs with an AI agent?▼

Load this skill and ask the agent to review the module; it checks 75 rules prioritized by impact, from CRITICAL issues like mutable default arguments down to naming style. Each finding cites a rule file with incorrect and correct examples.

What Python version does this style guide target?▼

The rules assume Python 3.11 or newer as the baseline. Rules depending on newer features are marked inline, such as warnings.deprecated for 3.13+ and assert_never for 3.11+, with typing_extensions noted as a backport.

Does it cover Pydantic models and dataclasses?▼

Yes. Several rules are tagged applicability:pydantic, covering discriminated unions with Field(discriminator=...), Field(default_factory=...), and module-level TypeAdapter definitions. Dataclass-specific guidance includes KW_ONLY and default_factory usage.

Should I apply these rules to existing stable code?▼

No. The skill explicitly states a rule match is a signal, not a verdict, and warns against blanket sweeps across stable code. Apply CRITICAL and HIGH rules when found, but reserve MEDIUM and below for new code or code already being edited.

Does it handle asyncio and concurrency patterns?▼

No, asyncio and concurrency guidance is intentionally excluded and lives in a companion python-async-best-practices skill. This skill covers synchronous code structure, typing, error handling, and API design.