python-anti-patterns

Reviews Python code against a checklist of common anti-patterns and fixes.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/scoots31/engineering-playbook --skill python-anti-patterns-scoots31
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-anti-patterns
Source: https://github.com/scoots31/engineering-playbook/tree/main/references/python-anti-patterns
Command: npx skills add https://github.com/scoots31/engineering-playbook --skill python-anti-patterns-scoots31

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Python codebases often accumulate subtle anti-patterns—bare exception handlers, blocking calls in async code, hard-coded secrets, mixed I/O and business logic—that cause production bugs and maintenance pain. This Skill provides a structured checklist to catch these issues during code review, before merge, or while debugging. ## Core Features & Use Cases - Categorized Anti-Pattern Reference: Covers infrastructure, architecture, error handling, resource management, type safety, and testing anti-patterns, each with a bad example and a corrected version. - Quick Review Checklist: A 14-point verification list to run before finalizing any Python implementation. - Fix Summary Table: Maps each anti-pattern directly to its recommended remediation, such as centralized retry decorators, Pydantic validation, and context managers. - Use Case: Before merging a pull request, run through the checklist to confirm there are no bare except blocks, no unclosed resources, and that all public functions carry type hints. ## Quick Start Review my Python code for common anti-patterns and list any issues with recommended fixes.

Frequently Asked Questions about python-anti-patterns

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

FAQPage Schema
How do I review Python code for common anti-patterns?

Use a categorized checklist covering infrastructure, architecture, error handling, resources, type safety, and testing. Check for bare except blocks, hard-coded config, blocking calls in async functions, and missing type hints before finalizing code.

What are the most common Python error handling mistakes?

The most common mistakes are bare `except Exception: pass` blocks that silently swallow bugs, and batch loops that abort on the first failure. Catch specific exceptions, log them, and return a result object capturing both successes and failures.

Why does my async Python code run slowly?

Blocking calls like `time.sleep()` or synchronous `requests.get()` inside async functions freeze the entire event loop. Replace them with `asyncio.sleep()` and async-native clients such as `httpx.AsyncClient`.

Should I expose ORM models directly in API responses?

No. Returning SQLAlchemy models from API endpoints leaks internal schema details and couples your API to the database. Use DTOs or response models, such as Pydantic classes with `from_orm`, to decouple the layers.

When should I avoid over-mocking in Python tests?

Avoid mocking every dependency, since tests then verify mocks rather than real behavior. Mock only external services, and use integration tests for critical paths alongside unit tests covering error and edge cases.