python-patterns_skill

This skill helps you write readable, type-safe Python code by applying idioms, PEP 8 standards, and robust patterns for maintainable apps.
  • JavaScript

46.5k

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill affaan-m/everything-claude-code --skill python-patterns

  • SKILL.md16.3 KB

Overview

This skill documents Pythonic idioms, PEP 8 standards, type hints, and pragmatic best practices for building robust, efficient, and maintainable Python applications. It focuses on readable, explicit code, modern typing, error handling, concurrency patterns, and sensible project layout. Use it as a checklist during coding, reviews, and refactors to keep code consistent and production-ready.

How this skill works

The skill inspects common development patterns and recommends replacements for anti-patterns with concrete code examples. It highlights readability, explicit behavior, EAFP error handling, type annotations (including Protocols and TypeVar), context managers, generators, data classes, decorators, and concurrency choices. It also prescribes package layout, import conventions, and tooling commands to automate style and quality checks.

When to use it

  • Writing new Python modules or services
  • Performing code reviews or pair programming
  • Refactoring legacy code to modern Python idioms
  • Designing package structure and public API exports
  • Choosing concurrency model for I/O vs CPU-bound work

Best practices

  • Prefer clear, descriptive names and small functions; readability over clever one-liners
  • Favor explicit configuration and avoid hidden side effects; follow PEP 8 import order
  • Use modern type hints and Protocols to document intent and enable static checking
  • Apply EAFP: catch specific exceptions and chain errors to preserve tracebacks
  • Use context managers for resource safety and dataclasses for simple value objects
  • Pick concurrency model by task type: threads for I/O, processes for CPU, async for many concurrent I/O tasks

Example use cases

  • Add type hints and Protocols to a public API to improve editor tooling and mypy checks
  • Refactor a memory-heavy class to use __slots__ and generators to reduce peak memory
  • Replace complex list comprehensions with generator functions for clarity and performance
  • Implement custom context managers for transactions or timing to centralize resource logic
  • Set up black, isort, ruff, mypy and pytest in CI to enforce style, types, and tests

FAQ

Choose async when you must manage thousands of concurrent I/O operations with low per-task overhead; use threads for simpler I/O concurrency and when using blocking libraries.

Are dataclasses always better than named tuples?

Use dataclasses for mutable records, validation, and default factories; prefer NamedTuple for small immutable value types with positional semantics.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
python-patterns skill by affaan-m/everything-claude-code | VeilStrat