applying-composition-over-inheritancelisted
Install: claude install-skill msewell/agent-stuff
# Applying Composition Over Inheritance
## Quick start
1. Identify the variation axis: data variant, algorithm, cross-cutting behavior, or framework constraint.
2. Default to composition unless inheritance is explicitly justified by substitutability and stability.
3. If the variant set is closed and data-shaped, prefer an ADT/sealed type over open inheritance.
4. Produce a concrete migration plan with tests, rollout order, and review checkpoints.
## Reference routing (progressive disclosure)
Read only the file needed for the current task:
- **Foundations and mechanism choice** → [references/01-foundations-and-decision-making.md](references/01-foundations-and-decision-making.md)
- **ADTs, composition patterns, frontend composition** → [references/02-adts-patterns-and-frontend-composition.md](references/02-adts-patterns-and-frontend-composition.md)
- **Step-by-step migration and code review checks** → [references/03-refactoring-and-review-checklist.md](references/03-refactoring-and-review-checklist.md)
- **CI metrics, custom static checks, team adoption** → [references/04-metrics-and-adoption.md](references/04-metrics-and-adoption.md)
## Default workflow
1. **Assess the current model**
- List base classes, subclass count, hierarchy depth, and known pain points.
- Mark each variation as one of: data variant, behavior strategy, or infrastructure concern.
2. **Choose mechanism (default-first)**
- Choose **composition** for behavior variation, runtime swapping, or