From harness-claude
Intercept and control JavaScript object property access with ES6 Proxy for validation, logging, transformation, reactivity, and access control without modifying the target.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Intercept and control object property access with ES6 Proxy
Implements GoF Proxy pattern in TypeScript for caching, authorization/protection, virtual, and logging proxies to control object access without modifying originals.
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.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
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