From harness-claude
Implements JavaScript Factory pattern via factory functions to encapsulate complex object creation, determine types at runtime, and hide direct instantiation from callers.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Create objects via a factory function without exposing instantiation logic to callers
Implements Factory Method design pattern in TypeScript with class-based creators, functional switches, and registered generics. Use when object types are runtime-determined, subclasses control instantiation, or to follow Open/Closed Principle.
Generates DDD-compliant factories for PHP 8.4 domain objects, encapsulating complex creation logic with input validation and unit tests. Ideal for intricate entity instantiation, aggregates, and reconstruction from persistence.
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.
Create objects via a factory function without exposing instantiation logic to callers
new to callersnew directly — they call the factory.function createUser(type, name) {
const roles = {
admin: { permissions: ['read', 'write', 'delete'] },
editor: { permissions: ['read', 'write'] },
viewer: { permissions: ['read'] },
};
if (!roles[type]) throw new Error(`Unknown user type: ${type}`);
return {
name,
type,
...roles[type],
greet() {
return `Hi, I'm ${name} (${type})`;
},
};
}
const admin = createUser('admin', 'Alice');
console.log(admin.permissions); // ['read', 'write', 'delete']
The Factory pattern is one of the most common patterns in JavaScript. Unlike new ClassName(), a factory function can return different types, apply caching, run validation, or perform async initialization.
Trade-offs:
instanceof to check the type (unless the factory returns a class instance)When NOT to use:
new directlyhttps://patterns.dev/javascript/factory-pattern