Agent skill · software engineering · affaan-m
python-patterns
Python-specific design patterns and best practices including protocols, dataclasses, context managers, decorators, async/await, type hints, and package organization. Use when working with Python code to apply Pythonic patterns.
Why this skill is useful
Provides specific Python design patterns and idioms that enhance code quality and maintainability, which the AI wouldn't reliably generate on its own.
What it needs
About 4k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.
What this skill does
Python Patterns This skill provides comprehensive Python patterns extending common design principles with Python-specific idioms. Protocol (Duck Typing) Use Protocol for structural subtyping (duck typing with type hints): Benefits: Type safety without inheritance Flexible, loosely coupled code Easy testing and mocking Dataclasses as DTOs Use dataclass for data transfer objects and value objects: Features: Auto-generated init, repr, eq frozen=True for immutability field() for complex defaults Type hints for validation Context Managers Use context managers (with statement) for resource management: Class-based context manager: Generators Use generators for lazy evaluation and memory-efficient iteration: Generator expressions: Decorators Function Decorators Class Decorators Async/Await Async Functions Async Context Managers Type Hints Advanced Type Hints Union Types (Python 3.10+) Dependency Injection Constructor Injection Package Organization Project Structure Module Exports Error Handling Custom Exceptions Exception Groups (Python 3.11+) Property Decorators Functional Programming Higher-Order Functions When to Use This Skill Designing Python APIs and packages Implementing async/concurrent systems Structuring Python projects Writing Pythonic code Refactoring Python codebases Type-safe Python development
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills affaan-m/python-patterns--dc5154