Design Patterns
Agents should invoke this skill when choosing patterns, designing...
Install
npx skills add waybarrios/opencode-power-pack --skill design-patterns -g -a claude-code -y- Repository
- waybarrios/opencode-power-pack549
- Category
- Design
- Updated
- 8d ago
- License
- MIT (modified; see UPSTREAMS.json)
- Context cost
- Mediumabout 2,093 tokens
- Runs scripts
- No, instructions only
What it does
Agents should invoke this skill when choosing patterns, designing traits/interfaces/components, deciding abstraction boundaries, evaluating dependency injection/callbacks, or comparing implementation approaches in Rust, TypeScript/React, or Django/Python.
Design Patterns
Pattern recommendations tailored to common tech stacks. Every pattern recommendation includes when to use it, when to avoid it, and the trade-offs.
Quick Start
Choose a Pattern
- Identify the problem: What design challenge are you solving?
- Consider the context: What language? What scale? How often will this change?
- Evaluate options: 2-3 candidate patterns with trade-offs
- Recommend: The best fit for this specific context (not the "best pattern in general")
The golden rule: Patterns are tools, not goals. Use the simplest pattern that solves the problem. If no pattern fits, a plain function or struct is fine.
Rust Patterns
Newtype Pattern
Wrap a primitive to add type safety and domain meaning.
struct UserId(u64);
struct OrderId(u64);
// Now the compiler prevents mixing up UserId and OrderId
fn get_order(user: UserId, order: OrderId) -> Order { ... }
When to use: When two values have the same underlying type but different meanings. When to skip: One-off uses where a type alias suffices.
Builder Pattern
Construct complex objects step by step.
let config = ServerConfig::builder()
.host("localhost")
.port(8080)
.max_connections(100)
.build()?;
When to use: Structs with many optional fields, complex construction logic.
When to skip: Structs with 1-3 required fields, just use new().
Typestate Pattern
Encode state transitions in the type system so invalid states are unrepresentable.
struct Connection<S: State> { /* ... */ state: PhantomData<S> }
struct Disconnected;
struct Connected;
struct Authenticated;


