
Python Expert
Give your coding agent a prioritized Python correctness, typing, performance, and style playbook when you write or review backend scripts and services.
Overview
Python Expert is an agent skill most often used in Build (also Ship review) that applies eight prioritized Python rules for correctness, typing, performance, and style when agents write or review code.
Install
npx skills add https://github.com/shubhamsaboo/awesome-llm-apps --skill python-expertWhat is this skill?
- Eight prioritized rules across Correctness (CRITICAL), Type Safety (HIGH), Performance (HIGH), and Style (MEDIUM)
- Critical coverage of mutable default arguments and proper error-handling patterns with incorrect vs correct examples
- Type hints and dataclasses guidance for safer agent-generated Python
- Performance patterns: list comprehensions and context managers
- PEP 8 and docstring conventions for maintainable solo projects
- 8 prioritized guidelines across 4 impact tiers (2 CRITICAL correctness, 4 HIGH, 2 MEDIUM style)
Adoption & trust: 3.6k installs on skills.sh; 114k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Agent-generated Python often hides shared mutable defaults, weak error handling, and missing types until production breaks.
Who is it for?
Solo builders generating or refactoring Python APIs, CLIs, and automation with Claude Code, Cursor, or Codex.
Skip if: Teams that only need language-agnostic PR reports without Python-specific gotchas, or projects that are not Python.
When should I use this skill?
Writing or reviewing Python code where agents need ranked rules for bugs, types, performance, and PEP 8.
What do I get? / Deliverables
Your agent follows a CRITICAL→MEDIUM rule stack so new Python modules are safer, faster to read, and easier to maintain before you merge or deploy.
- Python code or patches aligned to the eight-rule priority stack
- Inline review notes mapped to Correctness, Type Safety, Performance, and Style
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Python implementation is the canonical home for backend and automation code where these rules apply first. Backend subphase is where mutable-default gotchas, type hints, and context managers matter most for solo API and CLI builds.
Where it fits
Scaffold a FastAPI endpoint and enforce hints plus safe default-argument patterns before shipping.
Write a Python SDK wrapper for a webhook with context managers for HTTP sessions.
Re-read agent output for CRITICAL correctness rules before merging a solo side-project PR.
Patch a production script that exhibited shared-list default bugs traced to earlier agent codegen.
How it compares
Reference skill playbook for Python craft, not a pull-request diff reviewer like a dedicated code-reviewer skill.
Common Questions / FAQ
Who is python-expert for?
Solo and indie developers who want their agent to default to sound Python patterns while building backends, CLIs, and agent-side scripts.
When should I use python-expert?
During Build when implementing Python services, when fixing agent-written bugs, and during Ship review before merge when you want type-safety and correctness checks—not only PEP 8 nits.
Is python-expert safe to install?
It is documentation-only procedural knowledge with no shell or network requirements; review the Security Audits panel on this Prism page before trusting any third-party skill package.
SKILL.md
READMESKILL.md - Python Expert
# Python Expert Guidelines **A comprehensive guide for AI agents writing and reviewing Python code**, organized by priority and impact. --- ## Table of Contents ### Correctness — **CRITICAL** 1. [Avoid Mutable Default Arguments](#avoid-mutable-default-arguments) 2. [Proper Error Handling](#proper-error-handling) ### Type Safety — **HIGH** 3. [Use Type Hints](#use-type-hints) 4. [Use Dataclasses](#use-dataclasses) ### Performance — **HIGH** 5. [Use List Comprehensions](#use-list-comprehensions) 6. [Use Context Managers](#use-context-managers) ### Style — **MEDIUM** 7. [Follow PEP 8 Style Guide](#follow-pep-8-style-guide) 8. [Write Docstrings](#write-docstrings) --- ## Correctness ### Avoid Mutable Default Arguments **Impact: CRITICAL** | **Category: correctness** | **Tags:** bugs, defaults, mutable, gotcha Mutable default arguments (like lists or dicts) are shared across all calls to the function. #### Why This Matters Because the default value is evaluated only once at function definition time, subsequent calls will persist changes made to the default object, leading to extremely subtle and frustrating bugs. #### ❌ Incorrect ```python def add_item(item, items=[]): # BUG: [] is shared! items.append(item) return items print(add_item("a")) # ['a'] print(add_item("b")) # ['a', 'b'] - Unexpected! ``` #### ✅ Correct ```python def add_item(item: str, items: list[str] | None = None) -> list[str]: """Add an item to a list, creating a new list if none provided. Args: item: The item to add items: Optional existing list to add to Returns: The list with the new item added """ if items is None: items = [] items.append(item) return items ``` --- ### Proper Error Handling **Impact: CRITICAL** | **Category: correctness** | **Tags:** errors, exceptions, reliability Always handle errors explicitly. Don't use bare except clauses or ignore errors silently. #### ❌ Incorrect ```python try: result = risky_operation() except: pass # Silent failure! ``` #### ✅ Correct ```python try: config = json.loads(config_file.read()) except json.JSONDecodeError as e: logger.error(f"Invalid JSON in config file: {e}") config = get_default_config() except FileNotFoundError: logger.warning("Config file not found, using defaults") config = get_default_config() ``` --- ## Type Safety ### Use Type Hints **Impact: HIGH** | **Category: type-safety** | **Tags:** types, mypy, annotations, documentation Type hints enable static analysis, improve IDE support, and serve as documentation. #### Why This Matters Python's dynamic nature can lead to runtime errors that are hard to catch. Type hints allow tools like `mypy` to verify code correctness before execution. #### ❌ Incorrect ```python def get_user(id): return users.get(id) ``` #### ✅ Correct ```python from typing import Optional, Dict, Any def get_user(user_id: int) -> Optional[Dict[str, Any]]: """Fetch user by ID. Args: user_id: The unique identifier for the user Returns: User dictionary if found, None otherwise """ return users.get(user_id) ``` --- ### Use Dataclasses **Impact: HIGH** | **Category: type-safety** | **Tags:** dataclasses, classes, data, boilerplate Use the `@dataclass` decorator for classes that primarily store data. #### Why This Matters Dataclasses automatically generate `__init__`, `__repr__`, and `__eq__` methods, reducing boilerplate and ensuring consistent behavior for data containers. #### ❌ Incorrect ```python class User: def __init__(self, id, name, email): self.id = id self.name = name self.email = email def __repr__(self): return f"User(id={self.id}, name={self.name}, email={self.email})" def __eq__(self, other): return self.id == other.id and self.name == other.name ``` #### ✅ Correct ```python from dataclasses import data