/acc:create-compositefrom acc
Generates Composite pattern code for PHP 8.4, creating tree structures with uniform treatment of individual and composite objects, including unit tests.
Ships in acc. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Creates Composite pattern infrastructure for treating individual objects and compositions uniformly.
| Scenario | Example |
|---|---|
| Tree structures | Menus, file systems, organization charts |
| Part-whole hierarchies | UI components, product categories |
| Recursive operations | Calculate totals, render trees |
| Uniform treatment | Same interface for leaf and composite |
Path: src/Domain/{BoundedContext}/
{Name}Interface.php — Operations contractPath: src/Domain/{BoundedContext}/
{Name}Leaf.php — Individual objectPath: src/Domain/{BoundedContext}/
{Name}Composite.php — Container for children{ClassName}Test.php — Component behavior verification| Component | Path |
|---|---|
| Component Interface | src/Domain/{BoundedContext}/ |
| Leaf | src/Domain/{BoundedContext}/ |
| Composite | src/Domain/{BoundedContext}/ |
| Unit Tests | tests/Unit/Domain/{BoundedContext}/ |
| Component | Pattern | Example |
|---|---|---|
| Component Interface | {Name}Interface | MenuItemInterface |
| Leaf | {Name} | MenuItem |
| Composite | {Name}Composite | MenuComposite |
| Test | {ClassName}Test | MenuCompositeTest |
interface {Name}Interface
{
public function {operation}(): {returnType};
}
final readonly class {Name} implements {Name}Interface
{
public function {operation}(): {returnType}
{
return {leafBehavior};
}
}
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;
}
}
$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();
| Composite | Purpose |
|---|---|
| MenuComposite | Nested menu structures |
| PermissionComposite | Permission hierarchies |
| PriceRuleComposite | Combined pricing rules |
| FileSystemComposite | Files and directories |
| OrganizationComposite | Company structure |
| Anti-pattern | Problem | Solution |
|---|---|---|
| Type Checking | instanceof checks everywhere | Use polymorphism |
| Leaf Operations in Composite | add/remove on leafs | Throw exception or use separate interfaces |
| Deep Hierarchies | Performance issues | Limit depth or use flyweight |
| Missing Parent Reference | Can't navigate up | Store parent in composite |
| Circular References | Infinite loops | Validate before adding |
For complete PHP templates and examples, see:
references/templates.md — Component interface, leaf, composite templatesreferences/examples.md — Menu, permission, price rule composites with unit testsWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub dykyi-roman/awesome-claude-code --plugin acc283 skills in this plugin
/access-control-knowledgeAccess Control knowledge base. Provides ACL, RBAC, ABAC, ReBAC models, multi-tenancy patterns, and PHP implementations (Symfony Voters, Laravel Gates) for security audits and generation./adr-knowledgeAction-Domain-Responder pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for ADR (web-specific MVC alternative) audits./adr-templateGenerates Architecture Decision Records (ADR) for PHP projects. Creates structured decision documentation with context, decision, and consequences.Other plugins' skills for the same job