proxy-pattern

Implements JavaScript Proxy handlers to intercept property access, assignment, and validation.

1|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/TierOne-Studio/spa-velocity --skill proxy-pattern-tierone-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: proxy-pattern
Source: https://github.com/TierOne-Studio/spa-velocity/tree/main/.ruler/skills/proxy-pattern
Command: npx skills add https://github.com/TierOne-Studio/spa-velocity --skill proxy-pattern-tierone-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding validation, logging, or debugging behavior to object property access in JavaScript normally requires invasive changes to the object itself. This Skill shows how to intercept get and set operations with the built-in Proxy API without modifying the target object. ## Core Features & Use Cases - Property Interception: Create a Proxy with a handler object defining get and set traps to control interactions with any target object. - Validation in set Traps: Reject invalid assignments, such as non-numeric ages or empty names, before they reach the target object. - Reflect-Based Handlers: Use Reflect.get and Reflect.set inside traps for cleaner, spec-aligned property access. - Use Case: Wrap a configuration object in a Proxy during testing so every property read is logged and every write is type-checked, catching invalid assignments early. ## Quick Start Ask the AI to wrap a JavaScript object in a Proxy that logs property reads and validates writes using get and set traps with Reflect.

Frequently Asked Questions about proxy-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use the JavaScript Proxy API to intercept property access?

Create a new Proxy with the target object and a handler defining get and set traps. The get trap runs on property reads and the set trap runs on writes, letting you log, validate, or transform values before they reach the target.

How to add validation to object properties in JavaScript?

Use a Proxy set trap to check values before assignment, such as rejecting non-numeric ages or names shorter than two characters. Return true for valid writes and skip the assignment or throw for invalid ones.

What is the difference between Proxy traps and Object.defineProperty?

Proxy intercepts all operations through a handler object and works on any property, including ones added later. Object.defineProperty defines getters and setters per property with less indirection, which suits simple validation on known keys.

Why use Reflect inside Proxy handlers?

Reflect.get and Reflect.set mirror the handler trap signatures and forward operations to the target with correct receiver binding. This avoids subtle bugs from direct bracket access, especially with inherited properties or accessor descriptors.

When should I avoid using JavaScript Proxy?

Avoid Proxy in performance-critical hot paths because every property access incurs trap overhead. Also skip it when simple getters, setters, or plain functions achieve the same validation with less indirection.