From harness-claude
Implements Composite pattern in JavaScript to compose objects into tree structures like file systems, UI components, or org charts, treating leaves and composites uniformly.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Compose objects into tree structures and treat individual objects and composites uniformly
Implements GOF Composite pattern in TypeScript for tree structures like file systems, org charts, ASTs, enabling uniform treatment of leaves and composites with recursive operations.
Generates Composite pattern for PHP 8.4 with interface, leaf, composite classes, and unit tests. For tree structures like menus, file systems, org charts.
Provides React composition patterns for refactoring boolean prop-heavy components, building compound components, context providers, and scalable APIs.
Share bugs, ideas, or general feedback.
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