Skip to content
affaan-m avatar

Python Patterns

Idiomatic Python patterns covering type hints, error handling, context managers, and comprehensions for maintainable code.

CCM score
64 of 100
skills.sh installs
15.6K
GitHub stars
312.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers readability, explicit configuration, and EAFP-style exception handling as core principles for writing and reviewing Python
  • Includes type hint guidance for Python 3.9+ built-in generics, type aliases, TypeVar, and Protocol-based duck typing
  • Enforces specific exception handling over bare except, with exception chaining via from and custom exception hierarchies
  • Designed for writing, refactoring, and reviewing Python code where idiomatic structure, typing, or PEP 8 is in question

Install

$ npx -y skills add affaan-m/ecc --skill python-patterns -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Python Development Patterns

Idiomatic Python patterns and best practices for building robust, efficient, and maintainable applications.

When to Activate

  • Writing new Python code
  • Reviewing Python code
  • Refactoring existing Python code
  • Designing Python packages/modules

Core Principles

1. Readability Counts

Python prioritizes readability. Code should be obvious and easy to understand.

# Good: Clear and readable
def get_active_users(users: list[User]) -> list[User]:
    """Return only active users from the provided list."""
    return [user for user in users if user.is_active]


# Bad: Clever but confusing
def get_active_users(u):
    return [x for x in u if x.a]

2. Explicit is Better Than Implicit

Avoid magic; be clear about what your code does.

# Good: Explicit configuration
import logging

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)

# Bad: Hidden side effects
import some_module
some_module.setup()  # What does this do?

3. EAFP - Easier to Ask Forgiveness Than Permission

Python prefers exception handling over checking conditions.

Details

Repository
github.com/affaan-m/ecc
Categories
Python, Code Review & Quality
First seen
Jul 14, 2026

Questions

What does the python-patterns skill do for Python developers?

The python-patterns skill brings Pythonic idioms, PEP 8 standards, type hints, and best practices to Python code, covering readability, EAFP exception handling, context managers, comprehensions and generators, and data classes. It is meant for writing, reviewing, and refactoring Python code and for designing Python packages and modules.

Where does python-patterns rank among Python skills?

On the Python category page, python-patterns ranks in the top 10 Python skills. Other skills in the category include python-performance-optimization, python-design-patterns, async-python-patterns, python-code-style, and uv-package-manager.

How do I install the python-patterns skill?

Run npx -y skills add affaan-m/ecc --skill python-patterns -y in your project to install it. Once installed, the agent can apply these Python patterns when you write or review code, especially when idiomatic structure, typing, or PEP 8 is in question.

More from affaan-m/ecc

All 257

Similar to Python Patterns

More Python