From harness-claude
Intercepts and controls object property access using ES6 Proxy for validation, logging, reactivity, and lazy initialization.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:js-proxy-patternThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Intercept and control object property access with ES6 Proxy
Intercept and control object property access with ES6 Proxy
get, set, deleteProperty, etc.).const proxy = new Proxy(target, handler).set traps, always call Reflect.set(target, prop, value) to apply the change and return its boolean result.get traps, use Reflect.get(target, prop, receiver) to preserve prototype chain behavior.Reflect methods in traps — they mirror the Proxy trap API and ensure correct semantics.const validator = {
set(target, prop, value) {
if (prop === 'age') {
if (typeof value !== 'number' || value < 0) {
throw new TypeError('Age must be a non-negative number');
}
}
return Reflect.set(target, prop, value);
},
};
const person = new Proxy({}, validator);
person.age = 30; // OK
person.age = -1; // Throws TypeError
ES6 Proxy gives you a meta-programming hook at the object level. Traps intercept fundamental operations: get, set, has, deleteProperty, apply (for functions), and construct (for classes).
Trade-offs:
proxy !== target) — equality checks must use the targetJSON.stringify(proxy) serializes the underlying target, which may surprise callersWhen NOT to use:
Object.freeze() is simpler and has no runtime overhead per accessRelated patterns:
https://patterns.dev/javascript/proxy-pattern
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeImplements virtual, protection, logging, and caching proxy patterns to control access to objects. Provides TypeScript examples for caching repositories and authorization proxies.
Controls access to an object for lazy initialization, access control, logging, caching, or remote access without changing its interface. Based on the Gang of Four Proxy pattern.
Generates PHP 8.4 Proxy pattern implementations for lazy loading, caching, access control, and logging. Includes subject interfaces, proxies, and unit tests in domain-driven project paths.