dykyi-roman/awesome-claude-code/create-composite

Trust tier 2
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Generates Composite pattern for PHP 8.4. Creates tree structures with uniform treatment of individual and composite objects. Includes unit tests.

Install

npx vskill@latest install dykyi-roman/awesome-claude-code/create-composite

SKILL.md

Composite Pattern Generator

Creates Composite pattern infrastructure for treating individual objects and compositions uniformly.

When to Use

ScenarioExample
Tree structuresMenus, file systems, organization charts
Part-whole hierarchiesUI components, product categories
Recursive operationsCalculate totals, render trees
Uniform treatmentSame interface for leaf and composite

Component Characteristics

Component Interface
  • Defines operations for all objects
  • Shared by leaf and composite
  • Enables uniform treatment
Leaf
  • Represents individual object
  • No children
  • Implements component operations
Composite
  • Contains children (leaf or composite)
  • Delegates operations to children
  • Implements component operations

Generation Process

Step 1: Generate Component Interface

Path: src/Domain/{BoundedContext}/

  1. {Name}Interface.php — Operations contract
Step 2: Generate Leaf

Path: src/Domain/{BoundedContext}/

  1. {Name}Leaf.php — Individual object
Step 3: Generate Composite

Path: src/Domain/{BoundedContext}/

  1. {Name}Composite.php — Container for children
Step 4: Generate Tests
  1. {ClassName}Test.php — Component behavior verification

File Placement

ComponentPath
Component Interfacesrc/Domain/{BoundedContext}/
Leafsrc/Domain/{BoundedContext}/
Compositesrc/Domain/{BoundedContext}/
Unit Teststests/Unit/Domain/{BoundedContext}/

Naming Conventions

ComponentPatternExample
Component Interface{Name}InterfaceMenuItemInterface
Leaf{Name}MenuItem
Composite{Name}CompositeMenuComposite
Test{ClassName}TestMenuCompositeTest

Quick Template Reference

Component Interface
php
interface {Name}Interface
{
public function {operation}(): {returnType};
}
Leaf
php
final readonly class {Name} implements {Name}Interface
{
public function {operation}(): {returnType}
{
return {leafBehavior};
}
}
Composite
php
final class {Name}Composite implements {Name}Interface
{
private array $children = [];
public function add({Name}Interface $child): void
{
$this->children[] = $child;
}
public function {operation}(): {returnType}
{
$result = {initialValue};
foreach ($this->children as $child) {
$result {combineOperation} $child->{operation}();
}
return $result;
}
}

Usage Example

php
$menu = new MenuComposite('Products');
$menu->add(new MenuItem('Laptops'));
$submenu = new MenuComposite('Accessories');
$submenu->add(new MenuItem('Mouse'));
$submenu->add(new MenuItem('Keyboard'));
$menu->add($submenu);
// Uniform treatment
$menu->render();

Common Composites

CompositePurpose
MenuCompositeNested menu structures
PermissionCompositePermission hierarchies
PriceRuleCompositeCombined pricing rules
FileSystemCompositeFiles and directories
OrganizationCompositeCompany structure

Anti-patterns to Avoid

Anti-patternProblemSolution
Type Checkinginstanceof checks everywhereUse polymorphism
Leaf Operations in Compositeadd/remove on leafsThrow exception or use separate interfaces
Deep HierarchiesPerformance issuesLimit depth or use flyweight
Missing Parent ReferenceCan't navigate upStore parent in composite
Circular ReferencesInfinite loopsValidate before adding

References

For complete PHP templates and examples, see:

  • references/templates.md — Component interface, leaf, composite templates
  • references/examples.md — Menu, permission, price rule composites with unit tests

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
96
Repository forks
25
7-day trend score
23

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 7 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/dykyi-roman/awesome-claude-code/create-composite/badge)](https://verified-skill.com/skills/dykyi-roman/awesome-claude-code/create-composite)

Something wrong with this skill or its page? Tell us.