# Composition over Inheritance Prefer building complex behavior by combining simpler, independent components rather than through class hierarchies. One of the most impactful design principles in software, and one of the most violated. ## The problem with inheritance Inheritance creates tight coupling between parent and child. Changes to the parent ripple down. Deep hierarchies become brittle and hard to understand. The "is-a" relationship forces you to predict classification upfront, which is almost always wrong in evolving systems. ## How composition works Instead of inheriting behavior, a component holds references to other components that provide the behavior it needs. "Has-a" instead of "is-a." Each component is independent, replaceable, and testable. ## In AI skills and agents AI skills compose naturally. A newsletter skill chains: content-scout (finds material) -> ghostwriter (writes) -> style-police (checks voice) -> publisher (publishes). Four independent skills, each doing one thing, combined into a workflow. No skill "inherits" from another. Agents compose similarly but through collaboration: delegation, review, and handoff rather than just chaining. A panel is composition in action; five independent agents evaluate the same content from different angles. See [[AI Skill Composability]] and [[Software Design Patterns for AI Skills and Agents]]. ## References - Gang of Four, "Design Patterns" (1994): "Favor object composition over class inheritance" ## Related - [[SOLID Principles]] - [[Loose Coupling]] - [[AI Skill Composability]] - [[Atomicity]] - [[Barrel Pattern]]