From python-development
Guides applying Python design patterns (KISS, SRP, composition over inheritance) when designing new services, refactoring large functions, or evaluating PRs for coupling and abstraction issues.
How this skill is triggered — by the user, by Claude, or both
Slash command
/python-development:python-design-patternsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Write maintainable Python code using fundamental design principles. These patterns help you build systems that are easy to understand, test, and modify.
Write maintainable Python code using fundamental design principles. These patterns help you build systems that are easy to understand, test, and modify.
Choose the simplest solution that works. Complexity must be justified by concrete requirements.
Each unit should have one reason to change. Separate concerns into focused components.
Build behavior by combining objects, not extending classes.
Wait until you have three instances before abstracting. Duplication is often better than premature abstraction.
# Simple beats clever
# Instead of a factory/registry pattern:
FORMATTERS = {"json": JsonFormatter, "csv": CsvFormatter}
def get_formatter(name: str) -> Formatter:
return FORMATTERS[name]()
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
A class is growing and seems to have multiple responsibilities, but splitting it feels wrong. Apply the "reason to change" test: list every change that could require editing this class. If the list has items from different domains (e.g., HTTP parsing AND business rules AND formatting), split it. If all changes stem from the same domain concern, the class may be appropriately sized.
Injecting all dependencies through the constructor is producing constructors with 7+ parameters. This is a sign of too many responsibilities in one class, not a problem with dependency injection. Split the class into smaller units first, then each constructor naturally becomes smaller.
Composition is producing deeply nested wrapper objects that are hard to trace. Keep the composition shallow (2-3 levels). If wrapping is the only mechanism, consider whether a Protocol-based approach or simple function composition would be cleaner than a chain of decorator objects.
The rule of three says not to abstract yet, but the duplication is causing bugs when one copy is updated but not the other. Duplication that diverges in dangerous ways should be abstracted sooner. The rule of three is a heuristic, not a law. If the copies are already diverging incorrectly, extract immediately and add a test that exercises the shared behavior.
A service layer is importing from the API layer, breaking the dependency direction. This is a layering violation. The service layer must not import from handlers. Introduce a shared types/models layer that both can import from, keeping the dependency arrow pointing downward (API → Service → Repository).
npx claudepluginhub phamquocan24/agents --plugin python-development24plugins reuse this skill
First indexed Jun 3, 2026
Showing the 6 earliest of 24 plugins
Guides applying Python design patterns (KISS, SRP, composition over inheritance) when designing new services, refactoring large functions, or evaluating PRs for coupling and abstraction issues.
Implementation reference for the 22 GoF design patterns in idiomatic modern Python (3.10+), with Pythonic forms (dataclasses, singledispatch, match) and class-based fallbacks. Use when refactoring or reviewing Python with pattern-shaped problems like class explosion, type-switching conditionals, or tight coupling.
Enforces SOLID architecture for Python 3.12+ projects: modular modules/[feature]/ structure, files under 100 lines, Protocol-based interfaces, and strict layer separation. Activates when writing or refactoring Python code.