From harness-claude
Implements the Composite design pattern to compose objects into tree structures, allowing uniform treatment of leaves and composites. Useful for file systems, UI trees, menus.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:js-composite-patternThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Compose objects into tree structures and treat individual objects and composites uniformly
Compose objects into tree structures and treat individual objects and composites uniformly
class File {
constructor(name, size) {
this.name = name;
this.size = size;
}
getSize() {
return this.size;
}
}
class Folder {
constructor(name) {
this.name = name;
this.children = [];
}
add(child) {
this.children.push(child);
return this;
}
getSize() {
return this.children.reduce((sum, child) => sum + child.getSize(), 0);
}
}
const root = new Folder('src')
.add(new File('index.js', 120))
.add(new Folder('utils').add(new File('helpers.js', 80)));
root.getSize(); // 200
The Composite pattern lets you build tree structures where clients do not need to distinguish between leaves and branches. Every node in the tree responds to the same interface, so operations naturally recurse.
Trade-offs:
add() on a File)When NOT to use:
https://patterns.dev/javascript/composite-pattern
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeImplements the GoF Composite pattern to compose objects into tree structures and treat individual and composite objects uniformly. Useful for file systems, menus, ASTs, and recursive permissions.
Applies the Composite design pattern to compose objects into tree structures, enabling uniform treatment of leaf and container nodes for part-whole hierarchies.
Generates Composite pattern for PHP 8.4 with interface, leaf, composite classes, and unit tests. For tree structures like menus, file systems, org charts.