python-patterns

Applies Pythonic idioms, type hints, and PEP 8 standards when writing or reviewing Python code.

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/ibytechaos/claude --skill python-patterns-ibytechaos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-patterns
Source: https://github.com/ibytechaos/claude/tree/main/plugins/everything-claude-code/skills/python-patterns
Command: npx skills add https://github.com/ibytechaos/claude --skill python-patterns-ibytechaos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Python codebases often accumulate unidiomatic patterns, missing type annotations, inconsistent error handling, and performance anti-patterns that make code harder to maintain and review. ## Core Features & Use Cases - Idiomatic Code Guidance: Enforces EAFP error handling, context managers, comprehensions, generators, and dataclasses over verbose or error-prone alternatives. - Type Hints & Tooling: Covers modern type annotations, Protocol-based duck typing, and pyproject.toml configuration for black, ruff, mypy, and pytest. - Concurrency & Performance Patterns: Provides threading, multiprocessing, and async/await templates plus memory optimizations like slots and generators. - Use Case: When refactoring a legacy Python module, activate this Skill to rewrite bare except blocks into specific exception hierarchies, add type hints to function signatures, and replace string concatenation loops with join operations. ## Quick Start Review my Python module and refactor it to follow Pythonic patterns with proper type hints and error handling.

Frequently Asked Questions about python-patterns

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

FAQPage Schema
How do I write more Pythonic code?

Follow core idioms like EAFP exception handling, context managers for resources, list comprehensions for simple transformations, and generators for large datasets. Prioritize readability and explicitness over clever one-liners.

How to add type hints to Python functions?

Annotate function parameters and return values using built-in generics like list[str] and dict[str, int] on Python 3.9+, or the typing module on earlier versions. Use TypeVar for generics and Protocol for duck-typed interfaces.

Should I use threading, multiprocessing, or asyncio in Python?

Use threading for I/O-bound tasks, multiprocessing for CPU-bound work that needs to bypass the GIL, and async/await for high-concurrency network I/O. concurrent.futures provides a unified executor interface for threads and processes.

What are common Python anti-patterns to avoid?

Avoid mutable default arguments, bare except clauses, comparing to None with ==, checking types with type() instead of isinstance, and wildcard imports. Each hides bugs or breaks encapsulation.

When should I use dataclasses vs NamedTuple in Python?

Use dataclasses for mutable data containers needing validation via __post_init__ or default factories. Use NamedTuple for immutable, lightweight records where tuple unpacking and hashing matter.