/harness-claude:gof-proxy-patternfrom harness-claude
Teaches the GoF Proxy pattern with implementations for virtual, protection, logging, and caching proxies. Includes TypeScript examples for caching and authorization proxies.
Claude never picks this skill on its own
Its frontmatter has no description. Without a description, Claude Code leaves it out of the list Claude chooses from. Typing /harness-claude:gof-proxy-pattern still runs it.
What the skill costs in Claude's context, stage by stage
No description Claude Code can read, so Claude's list leaves it out: only you can start it.
SKILL.md joins the conversation and stays.
Control access to an object using virtual, protection, logging, and caching proxy patterns.
Caching proxy:
interface UserRepository {
findById(id: string): Promise<User | null>;
findAll(): Promise<User[]>;
}
class DatabaseUserRepository implements UserRepository {
async findById(id: string): Promise<User | null> {
console.log(`[DB] Fetching user ${id}`);
return db.query('SELECT * FROM users WHERE id = $1', [id]);
}
async findAll(): Promise<User[]> {
console.log('[DB] Fetching all users');
return db.query('SELECT * FROM users');
}
}
class CachingUserRepository implements UserRepository {
private cache = new Map<string, { user: User | null; expiresAt: number }>();
private readonly ttl = 60_000; // 1 minute
constructor(private readonly real: UserRepository) {}
async findById(id: string): Promise<User | null> {
const cached = this.cache.get(id);
if (cached && Date.now() < cached.expiresAt) {
console.log(`[Cache HIT] user ${id}`);
return cached.user;
}
const user = await this.real.findById(id);
this.cache.set(id, { user, expiresAt: Date.now() + this.ttl });
return user;
}
async findAll(): Promise<User[]> {
return this.real.findAll(); // don't cache collection queries
}
invalidate(id: string): void {
this.cache.delete(id);
}
}
// Wire it up — callers don't know about the cache
const repo: UserRepository = new CachingUserRepository(new DatabaseUserRepository());
Authorization proxy:
interface DocumentService {
getDocument(id: string): Promise<Document>;
updateDocument(id: string, content: string): Promise<void>;
deleteDocument(id: string): Promise<void>;
}
class AuthorizationProxy implements DocumentService {
constructor(
private readonly real: DocumentService,
private readonly getCurrentUser: () => User
) {}
async getDocument(id: string): Promise<Document> {
const user = this.getCurrentUser();
if (!user.permissions.includes('document:read')) {
throw new ForbiddenError('Read permission required');
}
return this.real.getDocument(id);
}
async updateDocument(id: string, content: string): Promise<void> {
const user = this.getCurrentUser();
if (!user.permissions.includes('document:write')) {
throw new ForbiddenError('Write permission required');
}
return this.real.updateDocument(id, content);
}
async deleteDocument(id: string): Promise<void> {
const user = this.getCurrentUser();
if (!user.permissions.includes('document:delete')) {
throw new ForbiddenError('Delete permission required');
}
return this.real.deleteDocument(id);
}
}
ES6 Proxy object (meta-programming proxy):
function createLoggingProxy<T extends object>(target: T, label: string): T {
return new Proxy(target, {
get(obj, prop: string | symbol) {
const value = Reflect.get(obj, prop);
if (typeof value === 'function') {
return (...args: unknown[]) => {
console.log(`[${label}] ${String(prop)}(${JSON.stringify(args)})`);
const result = value.apply(obj, args);
if (result instanceof Promise) {
return result.then((r) => {
console.log(`[${label}] ${String(prop)} → resolved`);
return r;
});
}
return result;
};
}
return value;
},
});
}
const loggingRepo = createLoggingProxy(new DatabaseUserRepository(), 'UserRepo');
await loggingRepo.findById('user-123');
// [UserRepo] findById(["user-123"])
// [DB] Fetching user user-123
// [UserRepo] findById → resolved
Virtual proxy (lazy initialization):
class LazyPDFDocument {
private realDoc: PDFDocument | null = null;
private async getDoc(): Promise<PDFDocument> {
if (!this.realDoc) {
this.realDoc = await PDFDocument.load(this.path); // expensive
}
return this.realDoc;
}
async getPageCount(): Promise<number> {
return (await this.getDoc()).getPageCount();
}
}
Proxy vs. Decorator: Both implement the same interface and wrap an object. The Proxy controls access or lifecycle (authorization, lazy load, caching). The Decorator adds features (stacking behaviors). When your intent is "protect" or "delay", use Proxy. When your intent is "enhance", use Decorator.
Anti-patterns:
refactoring.guru/design-patterns/proxy
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeRead when SKILL.md points to them.
793 skills in this plugin
/a11y-aria-patternsARIA Patterns> Apply ARIA roles, states, and properties correctly to enhance assistive technology support for custom widgets/a11y-color-contrastColor Contrast and Color Independence> Ensure sufficient color contrast ratios and never use color as the sole means of conveying information/a11y-form-patternsAccessible Form Patterns> Build accessible forms with proper labeling, grouped controls, inline validation, and clear error communicationOther plugins' skills for the same job