home / skills / dasien / claudemultiagenttemplate / design-patterns
This skill helps you apply design patterns like factory, observer, and strategy to design flexible, maintainable Python code.
npx playbooks add skill dasien/claudemultiagenttemplate --skill design-patternsReview the files below or copy the command above to add this skill to your agents.
---
name: "Design Pattern Application"
description: "Apply Gang of Four and architectural patterns appropriately to solve common software design problems"
category: "architecture"
required_tools: ["Read", "Write"]
---
## Purpose
Recognize when to apply established design patterns to create flexible, maintainable, and reusable code structures.
## When to Use
- Designing class structures
- Solving recurring design problems
- Refactoring complex code
- Planning extensible architectures
## Key Capabilities
1. **Pattern Recognition** - Identify when patterns apply
2. **Pattern Implementation** - Correctly implement chosen patterns
3. **Trade-off Analysis** - Understand pattern costs and benefits
## Common Patterns
- **Creational**: Factory, Builder, Singleton
- **Structural**: Adapter, Decorator, Facade
- **Behavioral**: Observer, Strategy, Command
## Example - Strategy Pattern
```python
# Problem: Multiple payment methods with different processing logic
class PaymentStrategy:
def process(self, amount): pass
class CreditCardPayment(PaymentStrategy):
def process(self, amount):
# Credit card processing logic
print(f"Processing ${amount} via credit card")
class PayPalPayment(PaymentStrategy):
def process(self, amount):
# PayPal processing logic
print(f"Processing ${amount} via PayPal")
class Order:
def __init__(self, payment_strategy: PaymentStrategy):
self.payment = payment_strategy
def checkout(self, amount):
self.payment.process(amount)
# Usage
order1 = Order(CreditCardPayment())
order1.checkout(100)
order2 = Order(PayPalPayment())
order2.checkout(50)
```
## Best Practices
- ✅ Use patterns to solve actual problems, not for their own sake
- ✅ Understand the problem before applying a pattern
- ✅ Keep it simple - don't over-engineer
- ❌ Avoid: Using patterns you don't fully understand
- ❌ Avoid: Forcing patterns where they don't fit
---This skill applies Gang of Four and architectural design patterns to solve common software design problems in multi-agent Python systems. It helps choose, implement, and evaluate patterns that improve flexibility, maintainability, and reuse. The guidance focuses on pragmatic pattern use in agent templates, task queues, and automated workflows.
The skill inspects code-level responsibilities and interactions to recognize candidate patterns (creational, structural, behavioral) and recommends concrete implementations. It provides short examples, trade-off analysis, and refactoring steps tailored to multi-agent templates and task management flows. It also suggests when a simpler approach is preferable to avoid over-engineering.
How do I choose between composition and inheritance?
Prefer composition when behavior should be changeable at runtime or when you want looser coupling; use inheritance when there is a clear is-a relationship and stable abstractions.
When is Singleton acceptable?
Use Singleton sparingly for truly global, shared resources (logging, config) but prefer dependency injection to keep code testable and reduce hidden state.
Can patterns increase complexity?
Yes. Patterns trade simplicity for structure. Always weigh added abstraction against maintainability gains and prefer minimal necessary structure.