gof-prototype
Installation
SKILL.md
One-line summary
Create new objects by copying an existing instance (the prototype) rather than by calling a constructor — useful when construction is expensive, when you only want to vary a few fields, or when you have a registry of canned shapes.
When to use this skill
- Object construction is expensive or has side effects that you don't want repeated.
- You have a "template" instance and want variations of it with a few fields changed.
- You need a registry of canned instances that consumers can clone and customize.
- The canonical Kotlin manifestation:
data class.copy(field = newValue)is exactly this pattern.
When NOT to use this skill
- Construction is cheap and stateless — just call the constructor.
- The "copy" must be a deep clone of a complex object graph — Prototype's contract is usually a shallow copy; deep cloning is its own problem.
- You're trying to dodge a hard construction problem by "copying" something that doesn't really exist yet — that's a smell.