composition-over-inheritance
✓Use when tempted to use class inheritance. Use when creating class hierarchies. Use when subclass needs only some parent behavior.
Installation
SKILL.md
Inheritance creates tight coupling and rigid hierarchies. Composition creates flexible, reusable components that can be mixed and matched.
Default to composition. Use inheritance only for true type hierarchies.
| Diamond problem | Duck needs Flying AND Swimming | | Tight coupling | Child knows parent internals | | Rigid hierarchy | Can't change parent without breaking children | | Forced inheritance | Gets methods it doesn't need | | Fragile base class | Parent changes break all children |
Use when tempted to use class inheritance. Use when creating class hierarchies. Use when subclass needs only some parent behavior. Source: yanko-belov/code-craft.
Facts (cite-ready)
Stable fields and commands for AI/search citations.
- Install command
npx skills add https://github.com/yanko-belov/code-craft --skill composition-over-inheritance- Source
- yanko-belov/code-craft
- Category
- </>Dev Tools
- Verified
- ✓
- First Seen
- 2026-02-01
- Updated
- 2026-02-18
Quick answers
What is composition-over-inheritance?
Use when tempted to use class inheritance. Use when creating class hierarchies. Use when subclass needs only some parent behavior. Source: yanko-belov/code-craft.
How do I install composition-over-inheritance?
Open your terminal or command line tool (Terminal, iTerm, Windows Terminal, etc.) Copy and run this command: npx skills add https://github.com/yanko-belov/code-craft --skill composition-over-inheritance Once installed, the skill will be automatically configured in your AI coding environment and ready to use in Claude Code or Cursor
Where is the source repository?
https://github.com/yanko-belov/code-craft
Details
- Category
- </>Dev Tools
- Source
- skills.sh
- First Seen
- 2026-02-01