composition

Replace deep inheritance hierarchies with modular composition and dependency injection.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/erichugy/agentic.skills --skill composition-erichugy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: composition
Source: https://github.com/erichugy/agentic.skills/tree/main/composition
Command: npx skills add https://github.com/erichugy/agentic.skills --skill composition-erichugy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Replaces brittle, tightly coupled inheritance hierarchies with modular, testable composition to reduce cascading changes, simplify reasoning, and limit accidental API surface inheritance across codebases.

Core Features & Use Cases

  • Function composition: Combine small pure functions into pipelines for validation, transformation, and persistence instead of inheriting shared behavior.
  • Object/module composition: Assemble capabilities via has-a relationships, adapters, and explicit contracts rather than deep is-a hierarchies.
  • Dependency injection & parameterization: Pass capabilities and rules in to make workflows configurable and easier to test, avoiding overridden hook methods.
  • Use Cases: Refactoring legacy class hierarchies, designing React components with hooks, building domain-specific client modules, and creating migration plans from registries to modular plugins.

Quick Start

Outline a migration plan to replace a three-level inheritance hierarchy with composed modules, listing the small functions, module contracts, adapters, and injection points needed.

Frequently Asked Questions about composition

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor deep inheritance hierarchies into modular composition?

Reduce coupling in software designs by replacing deep inheritance hierarchies with modular composition. Apply to object-oriented and modular systems including React components, service classes, domain modules, and client-specific adapters when behavior can be assembled from parts. Enforce explicit module contracts, dependency injection, function composition, parameterization, and migration checklists to minimize shared mutable state and brittle base-class changes.

What's the best way to use composition over inheritance in React components?

Refactoring legacy class hierarchies, designing React components with hooks, building domain-specific client modules, and creating migration plans from registries to modular plugins.

Why does inheritance cause tight coupling and how does composition fix it?

Replaces brittle, tightly coupled inheritance hierarchies with modular, testable composition to reduce cascading changes, simplify reasoning, and limit accidental API surface inheritance across codebases.

How do I apply dependency injection to make service classes more testable?

Dependency injection & parameterization: Pass capabilities and rules in to make workflows configurable and easier to test, avoiding overridden hook methods.

Can I use function composition to replace shared behavior in legacy class systems?

Function composition: Combine small pure functions into pipelines for validation, transformation, and persistence instead of inheriting shared behavior.

When should I not use composition for module design?

Outline a migration plan to replace a three-level inheritance hierarchy with composed modules, listing the small functions, module contracts, adapters, and injection points needed.