python-patterns

Python development principles and decision-making. Framework selection, async patterns, type hints, project structure. Teaches thinking, not copying.

Author

Install

Hot:4

Download and extract to your skills directory

Copy command and send to OpenClaw for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=sickn33-skills-python-patterns&locale=en&source=copy

Python Patterns - A Mindset Guide for Python Development Decisions

Skills Overview


Python Patterns is a skill focused on Python development decision-making thinking. It helps developers make informed choices in areas such as framework selection, asynchronous programming, type annotations, and project architecture—learning how to think rather than blindly applying fixed patterns.

Applicable Scenarios

1. Python Framework Selection Decision-Making


When you’re faced with a new Python project and you’re unsure whether to use Django, FastAPI, or Flask, this skill provides a clear decision tree and comparison analysis. It helps you choose the most suitable framework based on the project type (APIs, microservices, full-stack applications, background tasks) and your team’s background, rather than following the default option blindly.

2. Asynchronous Programming Architecture Design


When designing high-concurrency systems or handling a large number of I/O operations, the skill guides you in judging when to use asynchronous programming, how to choose suitable async libraries (httpx, asyncpg, aioredis, etc.), and how to avoid common pitfalls of mixing synchronous and asynchronous code. It covers Django 5.0+ asynchronous support and FastAPI asynchronous best practices.

3. Project Architecture and Best Practices


From type annotation strategies to project directory structure, from dependency injection to error handling, the skill offers comprehensive architectural principles. It includes practical experience such as Pydantic data validation, selecting background task solutions (Celery vs ARQ vs RQ), testing strategies, and optimizing N+1 queries.

Core Features

1. Intelligent Framework Selection Assistant


Based on your project requirements, team technology stack, and business scenarios, it provides personalized recommendations for Django, FastAPI, and Flask. It includes built-in decision trees covering various typical scenarios such as API-first, full-stack CMS, simple scripts, and AI/ML services, while considering technical factors like async support, admin backends, and ORM selection.

2. Asynchronous vs Synchronous Decision Engine


Using the golden rule—“I/O-bound goes async; CPU-bound goes sync”—it helps you quickly determine the programming paradigm. It provides a complete guide to the async library ecosystem (HTTP clients, databases, caching, file I/O) and specific recommendations on when to use async def vs def in FastAPI.

3. Project Architecture Best Practices Library


It covers project structure templates ranging from small scripts to large applications, including two architecture patterns: organizing by layer (routes/services/models) and organizing by functional modules. It provides hands-on guidance on best practices at the code level, including quick type-annotation references, Pydantic validation patterns, dependency injection design, exception handling strategies, and more.

Common Questions

Should I choose Django or FastAPI for Python?


This depends on your project type. If it’s a pure API service, a microservices architecture, or deploying an AI model, FastAPI is the better choice (native async, Pydantic integration, stronger performance). If you need a complete admin backend, CMS features, or a traditional full-stack web application, Django’s “batteries-included” advantage is stronger. For learning projects or simple scripts, Flask’s lightweight and flexibility may be more suitable.

When should I use asynchronous programming in Python?


When you’re dealing with a large number of I/O operations (database queries, HTTP requests, file reads/writes) and need high concurrency, asynchronous programming can significantly improve performance. Typical scenarios include real-time communication, calls between microservices, high-concurrency APIs, WebSocket connections, and more. However, if you’re doing CPU-bound computation (data analysis, image processing), synchronous code with more processes is often more appropriate. You should also consider how familiar your team is with async and whether your existing libraries support asynchronous usage.

Is it necessary to write Python type annotations?


For public APIs, function parameters, and return types, it’s strongly recommended to write type annotations. They not only enable IDE autocompletion and type checking, but also serve as code documentation. For internal implementations, local variables, and one-off scripts, you can rely on type inference without over-annotating. When using Pydantic for data validation, type annotations are essential—it provides runtime validation and the ability to automatically generate JSON Schema.