Skill: design-patterns-pragmatic
Activation Contract
Use this skill when asked whether to use a design pattern, how to apply a pattern, or how to compare pattern-based alternatives. Examples include Strategy, Factory, Builder, Adapter, Decorator, Template Method, Observer, Command, Repository, and Specification.
Do not use this skill to add patterns for decoration, replace simple code without a change pressure, or perform full architecture design unrelated to a specific pattern choice.
Responsibility
This skill teaches pragmatic pattern selection and application. It does not call other skills, force GoF terminology, or choose complexity without tradeoff justification.
Required Context
- Current problem and change pressure.
- Existing code shape or intended collaboration.
- Language and framework constraints.
- Expected variants, extension points, or integration boundaries.
Context Budget
- Keep this
SKILL.md focused on selection workflow.
- Use
references/pattern-selection.md for the pattern decision table.
Hard Rules
- Start from the design force, not the pattern name.
- Prefer no pattern when simple code is clearer.
- Introduce indirection only when it reduces real change cost.
- Name the cost: extra types, navigation, testing surface, and cognitive load.
- Check the candidate pattern's contraindications (
references/pattern-forces.md) before recommending it.
- Patterns belong to the consolidation phase of a design, not the prototyping phase: recommend one when variation is proven, not anticipated.
- For Java, consider lambdas, records, sealed classes, and composition before classic boilerplate-heavy patterns.
Decision Gates
| Condition |
Action |
| Behavior varies behind one operation |
Consider Strategy. |
| External API shape does not match local model |
Consider Adapter. |
| Object construction is complex with meaningful optional parts |
Consider Builder. |
| Creation logic must vary by family/type |
Consider Factory. |
| Feature wraps another object transparently |
Consider Decorator. |
| Algorithm skeleton is stable but steps vary |
Consider Template Method, but check inheritance cost. |
| Simple branch is enough |
Do not introduce a pattern yet. |
Execution Steps
- State the design force and expected variation.
- Compare simple code vs candidate pattern.
- Choose the smallest pattern shape that solves the force.
- Explain tradeoffs and rejected alternatives.
- Provide a minimal sketch when useful.
Output Contract
Return:
- Pattern verdict:
no_pattern, pattern_candidate, or pattern_recommended.
- Design force.
- Chosen pattern or simpler alternative.
- Tradeoffs.
- Minimal implementation sketch or next step.
References
references/pattern-selection.md — Pattern selection and tradeoff table.
references/pattern-forces.md — Redesign causes → candidate patterns, per-pattern contraindications, and pattern relations/combinations.
Assets
1---2name: design-patterns-pragmatic3description: Trigger: design patterns, GoF patterns, Java patterns, strategy, adapter, factory, builder, decorator, observer. Choose patterns only when they solve real design forces.4license: MIT5---67# Skill: design-patterns-pragmatic89## Activation Contract1011Use this skill when asked whether to use a design pattern, how to apply a pattern, or how to compare pattern-based alternatives. Examples include Strategy, Factory, Builder, Adapter, Decorator, Template Method, Observer, Command, Repository, and Specification.1213Do **not** use this skill to add patterns for decoration, replace simple code without a change pressure, or perform full architecture design unrelated to a specific pattern choice.1415## Responsibility1617This skill teaches pragmatic pattern selection and application. It does not call other skills, force GoF terminology, or choose complexity without tradeoff justification.1819## Required Context2021- Current problem and change pressure.22- Existing code shape or intended collaboration.23- Language and framework constraints.24- Expected variants, extension points, or integration boundaries.2526## Context Budget2728- Keep this `SKILL.md` focused on selection workflow.29- Use `references/pattern-selection.md` for the pattern decision table.3031## Hard Rules3233- Start from the design force, not the pattern name.34- Prefer no pattern when simple code is clearer.35- Introduce indirection only when it reduces real change cost.36- Name the cost: extra types, navigation, testing surface, and cognitive load.37- Check the candidate pattern's contraindications (`references/pattern-forces.md`) before recommending it.38- Patterns belong to the consolidation phase of a design, not the prototyping phase: recommend one when variation is proven, not anticipated.39- For Java, consider lambdas, records, sealed classes, and composition before classic boilerplate-heavy patterns.4041## Decision Gates4243| Condition | Action |44|---|---|45| Behavior varies behind one operation | Consider Strategy. |46| External API shape does not match local model | Consider Adapter. |47| Object construction is complex with meaningful optional parts | Consider Builder. |48| Creation logic must vary by family/type | Consider Factory. |49| Feature wraps another object transparently | Consider Decorator. |50| Algorithm skeleton is stable but steps vary | Consider Template Method, but check inheritance cost. |51| Simple branch is enough | Do not introduce a pattern yet. |5253## Execution Steps54551. State the design force and expected variation.562. Compare simple code vs candidate pattern.573. Choose the smallest pattern shape that solves the force.584. Explain tradeoffs and rejected alternatives.595. Provide a minimal sketch when useful.6061## Output Contract6263Return:6465- Pattern verdict: `no_pattern`, `pattern_candidate`, or `pattern_recommended`.66- Design force.67- Chosen pattern or simpler alternative.68- Tradeoffs.69- Minimal implementation sketch or next step.7071## References7273- `references/pattern-selection.md` — Pattern selection and tradeoff table.74- `references/pattern-forces.md` — Redesign causes → candidate patterns, per-pattern contraindications, and pattern relations/combinations.7576## Assets7778- None.