Individual skill
implementation-design-patterns-python
Implementation guide for the 22 Gang of Four design patterns in idiomatic modern Python (3.10+), distilled from refactoring.guru. Use when writing, refactoring, or reviewing Python with a pattern-shaped problem — class-explosion from inheritance, conditionals switching on type, tight coupling to concrete classes, tree-shaped models, runtime algorithm selection, undo/redo, state-dependent behavior, or hiding subsystem complexity. Each entry leads with the Pythonic form (functions, dataclasses, Protocol, singledispatch, match, generators, copy/replace) and falls back to the class-based GoF structure only when identity, state, or dispatch require it. Includes intent, applicability (when to use AND when NOT to), a runnable example, steps, pros/cons, and relations. Trigger even when no pattern is named — cues like "too many constructor params," "giant if/elif," "swap behavior at runtime," "need undo," or "walk a tree" are pattern-shaped. Covers all 5 Creational, 7 Structural, and 10 Behavioral GoF patterns.
skills/.experimental/implementation-design-patterns-python/SKILL.md
Source commit cf93c57cac89d6fc3e4194686000411567f5caf3
What was checked
- Matches the observed repository HEAD
- Yes
- Scanner rules are current
- No
- Repository scan complete
- No
- Skill scan complete
- No
- Observed behavior
- Not checked yet
- Last checked
- Nov 5, 2026
These are observations at the recorded commit, not a guarantee of safety. Review the source before running it.
Install this skill
Choose an agent in your Stack or copy a command below. Commands fetch the pinned commit and copy only this skill directory. Existing destinations are refused. Copying a command does not install anything.
An install command is unavailable: current rules, complete repository and skill scans, an eligible behavior level and a permitted license are required.
Repository context
- Repository stars (not skill ratings)
- 222
- Repository last updated
- Aug 15, 2026
- License
- MIT
Observed agent integration: codex
Files and excerpt
File metadata and permitted, redacted excerpts come from the recorded scan. Source links are pinned to that commit.
Browse files
AGENTS.mddoc · 10,679 bytesSKILL.mdcore · 12,137 bytesSKILL.mdcore · 12,137 bytesSKILL.mdcore · 12,137 bytesgotchas.mddoc · 4,118 bytesmetadata.jsonasset · 2,066 bytesreferences/_sections.mddoc · 2,575 bytesreferences/behavioral-chain-of-responsibility.mddoc · 5,030 bytesreferences/behavioral-command.mddoc · 4,801 bytesreferences/behavioral-iterator.mddoc · 4,377 bytesreferences/behavioral-mediator.mddoc · 4,702 bytesreferences/behavioral-memento.mddoc · 5,117 bytesreferences/behavioral-observer.mddoc · 4,690 bytesreferences/behavioral-state.mddoc · 4,709 bytesreferences/behavioral-strategy.mddoc · 4,532 bytesreferences/behavioral-template-method.mddoc · 5,125 bytesreferences/behavioral-visitor.mddoc · 5,115 bytesreferences/creational-abstract-factory.mddoc · 5,439 bytesreferences/creational-builder.mddoc · 5,345 bytesreferences/creational-factory-method.mddoc · 5,678 bytesreferences/creational-prototype.mddoc · 5,386 bytesreferences/creational-singleton.mddoc · 4,903 bytesreferences/structural-adapter.mddoc · 4,875 bytesreferences/structural-bridge.mddoc · 5,192 bytesreferences/structural-composite.mddoc · 4,713 bytesreferences/structural-decorator.mddoc · 5,309 bytesreferences/structural-facade.mddoc · 4,572 bytesreferences/structural-flyweight.mddoc · 4,899 bytesreferences/structural-proxy.mddoc · 5,272 bytes
Read excerpt
# Python Design Patterns Best Practices (Refactoring Guru)
Implementation reference for the 22 Gang of Four design patterns in **idiomatic modern Python (3.10+)**, distilled from refactoring.guru. Each of the **22 pattern files across 3 categories** captures intent, problem, solution, applicability (when to use AND when NOT to), a runnable Python example with output, implementation steps, pros/cons, and relations to sibling patterns.
This is the **Pythonic-first** companion to the TypeScript design-patterns skill. Most GoF patterns shrink to a language feature in Python — a function, a generator, a dataclass, `functools.singledispatch`, a `match` statement. Every entry leads with that idiomatic form and keeps the class-based GoF structure only where identity, stored state, runtime registration, or polymorphic dispatch genuinely earn it.
The patterns are a *vocabulary for structural decisions*, not a prescription. Reach for one only when its applicability criteria match — every entry includes a **When NOT to Use** section to guard against over-engineering, which is the more common failure with this catalog in Python.
## When to Apply
- A constructor has grown to 10+ parameters (telescoping-constructor smell) or subclasses exist only to bake in parameter combinations
- A method branches on `kind`/`type`/`mode`/`status` to pick an algorithm or behavior — a `match` or `if/elif` ladder that grows with each variant
- Integrating an incompatible third-party API, library, or legacy class whose method names don't match your code
- Modeling a tree-shaped domain (file systems, ASTs, UI trees, org charts) where leaves and branches must be treated uniformly