python-patterns

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

By sickn33 · 1,240 installs

npx skills add sickn33/agentic-awesome-skills --skill python-patterns

Source repository · Upstream listing

Python Patterns Python development principles and decision making for 2025. Learn to THINK, not memorize patterns. When to Use Use this skill when making Python architecture decisions, choosing frameworks, designing async patterns, or structuring Python projects. ⚠️ How to Use This Skill This skill teaches decision making principles , not fixed code to copy. ASK user for framework preference when unclear Choose async vs sync based on CONTEXT Don't default to same framework every time 1. Framework Selection (2025) Decision Tree Comparison Principles Factor FastAPI Django Flask Best for APIs, microservices Full stack, CMS Simple, learning Async Native Django 5.0+ Via extensions Admin Manual Built in Via extensions ORM Choose your own Django ORM Choose your own Learning curve Low Medium Low Selection Questions to Ask: 1. Is this API only or full stack? 2. Need admin interface? 3. Team familiar with async? 4. Existing infrastructure? 2. Async vs Sync Decision When to Use Async The Golden Rule Async Library Selection Need Async Library HTTP client httpx PostgreSQL asyncpg Redis aioredis / redis py async File I/O aiofiles Database ORM SQLAlchemy 2.0 async, Tortoise 3. Type Hints Strategy When to Type Common Type Patterns Pydantic for Validation 4. Project Structure Principles Structure Selection FastAPI Structure Principles 5. Django Principles (2025) Django Async (Django 5.0+) Django Best Practices 6. FastAPI Principles async def vs def in FastAPI Dependency Injection Pydantic v2 Integration 7. Background Tasks Selection Guide Solution Best For BackgroundTasks Simple, in process tasks Celery Distributed, complex workflows ARQ Async, Redis based RQ Simple Redis queue Dramatiq Actor based, simpler than Celery When to Use Each 8. Error Handling Principles Exception Strategy Error Response Philosophy 9. Testing Principles Testing Strategy Type Purpose Tools Unit Business logic pytest Integration API endpoints pytest + httpx/TestClient E2E Full workflows pytest + DB Async Testing Fixtures Strategy 10. Decision Checklist Before implementing: [ ] Asked user about framework preference? [ ] Chosen framework for THIS context? (not just default) [ ] Decided async vs sync? [ ] Planned type hint strategy? [ ] Defined project structure? [ ] Planned error handling? [ ] Considered background tasks? 11. Anti Patterns to Avoid ❌ DON'T: Default to Django for simple APIs (FastAPI may be better) Use sync libraries in async code Skip type hints for public APIs Put business logic in routes/views Ignore N+1 queries Mix async and sync carelessly ✅ DO: Choose framework based on context Ask about async requirements Use Pydantic for validation Separate concerns (routes → services → repos) Test critical paths Remember : Python patterns are about decision making for YOUR specific context. Don't copy code—think about what serves your application best. Limitations Use this skill only when the task clearly matches the scope described above. Do not treat the output as a substitute for environment specific validation, testing, or expert review. Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.