About python-design-patterns
A Python design-patterns skill for developers refactoring code around concrete needs. It favors small, testable changes and delays abstractions until real duplication or multiple implementations justify them.
Key features
- 01Applies KISS and single responsibility
- 02Identifies concrete design pain
- 03Guides incremental refactoring
- 04Favors composition and pure functions
- 05Flags premature abstractions
Use cases
- 01Refactoring duplicated Python logic
- 02Reducing coupling around a changing component
- 03Improving testability through dependency passing
- 04Choosing whether an abstraction is warranted
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ jurgendn/ agent-skills --skill python-design-patternsAfter installing, type/python-design-patternsin Claude Code to confirm it loaded.
Bundled filesreferences/pattern-catalog.md
Details
From the project READMEPython Design Patterns
Design for the next real change, not for imagined future flexibility. Simpler code wins until complexity earns its keep.
For concrete before/after examples, read references/pattern-catalog.md.
Decision Principles
- KISS: choose the simplest design that satisfies current requirements.
- Single responsibility: one reason to change per function/class/module.
- Composition over inheritance: combine behavior explicitly before building fragile hierarchies.
- Rule of three: do not abstract two similar cases until a third proves the pattern is real.
- Dependency direction: business logic should not depend on framework glue.
Refactoring Workflow
- Identify the pain: duplication, coupling, long function, unclear ownership, difficult testing, or repeated bug pattern.
- Name the change the design must support.
- Find the smallest boundary that reduces the pain.
- Prefer extracting pure functions before classes.
- Add an abstraction only if it removes real duplication or isolates volatility.
- Keep tests around behavior before moving code.
Common Moves
- Extract function for a coherent transformation.
- Extract module when related functions change together.
- Introduce a protocol/interface when multiple implementations are already real.
- Pass dependencies as parameters for testability.
- Use a repository/service boundary only when persistence or business logic is actually tangled.
Avoid
- Factories, registries, and plugins before there are multiple real variants.
- Base classes with one subclass.
- Global mutable state.
- Framework models leaking into public API schemas.
- "Clean architecture" layers that only forward calls.
Output
Return:
- current design smell;
- concrete pressure causing it;
- smallest refactor;
- abstractions to avoid for now;
- test impact;
- before/after ownership boundary.
Comments
Markdown supported