From harness-claude
Explains the JavaScript prototype pattern for sharing methods across instances via the prototype chain. Includes trade-offs, ES6 class syntax, and antipatterns.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:js-prototype-patternThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Share properties and methods across instances via the prototype chain
Share properties and methods across instances via the prototype chain
.prototype object — not inside the constructor function.this inside the constructor.Object.create(proto) for explicit prototype assignment without a constructor.function Dog(name) {
this.name = name;
}
Dog.prototype.bark = function () {
return `${this.name} says woof!`;
};
const d1 = new Dog('Rex');
const d2 = new Dog('Spot');
// Both share the same bark function in memory
console.log(d1.bark === d2.bark); // true
class syntax — it uses the prototype chain under the hood but is more readable.hasOwnProperty() or Object.hasOwn() to distinguish own vs inherited properties.Every JavaScript object has an internal [[Prototype]] link. When you access a property, the engine walks the chain: own properties first, then the prototype, then the prototype's prototype, until null. This is the prototype chain.
Trade-offs:
class syntax is clearer than manual .prototype manipulationWhen NOT to use:
#field) insteadhttps://patterns.dev/javascript/prototype-pattern
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeProvides instructions for implementing the Prototype design pattern (cloning objects) in Python, JavaScript, and Java. Useful when object creation is expensive or runtime type is unknown.
Guides using ES6 classes and constructor functions for object creation in JavaScript, including private fields, memoization, and prototype-based inheritance.
Covers 33+ essential JavaScript concepts including primitive types, type coercion, equality operators, scope, and closures with code examples and explanations.