python-patterns

Guide Python 3.12+ codebases through modern typing, Pydantic v2, and async patterns.

11|1|Updated Feb 9, 2026
One-click install
npx skills add https://github.com/mindcockpit-ai/cognitive-core --skill python-patterns-mindcockpit-ai
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-patterns
Source: https://github.com/mindcockpit-ai/cognitive-core/tree/main/.claude/skills/python-patterns
Command: npx skills add https://github.com/mindcockpit-ai/cognitive-core --skill python-patterns-mindcockpit-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides concise, practical guidance to eliminate legacy typing, incorrect Pydantic v1 patterns, unsafe async usage, and other common anti-patterns that lower code quality and increase maintenance burden.

Core Features & Use Cases

  • Modern typing and generics: Clear recommendations for PEP 695 style type aliases, built-in generics, and nullable union usage to improve type safety and readability.
  • Pydantic v2 best practices: Guidance on using model_config, field validators, and discriminated unions to migrate from v1 patterns and avoid common pitfalls.
  • Async, dataclasses, and testing: Patterns for async context managers, TaskGroup usage, immutable/dataclass value objects, and pytest techniques to build robust async code and reliable tests.
  • Use Case: Ideal for engineers migrating a codebase to Python 3.12+, auditing repositories for typing and Pydantic anti-patterns, or establishing team-wide idioms.

Quick Start

Ask the assistant to review a Python file and provide fixes and explanations for modern 3.12+ typing, Pydantic v2 usage, async patterns, dataclass practices, and common anti-patterns.

Frequently Asked Questions about python-patterns

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

FAQPage Schema
How do I migrate Pydantic v1 models to v2 using the new model_config and validators?▼

Migrate Pydantic v1 models to v2 by replacing inner Config classes with model_config, applying field validators, and utilizing discriminated unions to avoid common pitfalls and ensure correct validation.

What's the best way to apply PEP 695 type hints and generics in Python 3.12?▼

Apply PEP 695 type hints in Python 3.12 by using the new style type aliases, built-in generics, and nullable union usage to improve type safety and readability.

How do I use async context managers and TaskGroup for robust asynchronous programming?▼

Build robust asynchronous programming by implementing async context managers and utilizing TaskGroup usage to manage concurrent tasks safely and avoid unsafe async usage.

Can I use structural pattern matching and dataclasses to create immutable value objects in Python?▼

Yes, you can use structural pattern matching alongside immutable dataclass value objects to improve code correctness and maintainability in Python 3.12+.

Why does my codebase have anti-patterns after upgrading to Python 3.12, and how do I fix them?▼

Legacy typing and unsafe async usage create anti-patterns after upgrading to Python 3.12; fix them by applying modern idiomatic patterns, type hints, and testable exception handling.

Do I need pytest techniques specifically for testing async code and testable exception handling?▼

Yes, utilizing specific pytest techniques is required to build reliable tests for async code and establish testable exception handling in modern Python workflows.