/harness-claude:gof-abstract-factoryfrom harness-claude
Teaches the Abstract Factory pattern to create families of related objects without coupling to concrete types, with TypeScript UI theme examples.
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-abstract-factory 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.
Create families of related objects through factory interfaces without coupling to concrete types.
Define the abstract factory and product interfaces first:
// Abstract product interfaces
interface Button {
render(): string;
onClick(handler: () => void): void;
}
interface TextField {
render(): string;
getValue(): string;
}
// Abstract factory interface
interface UIFactory {
createButton(label: string): Button;
createTextField(placeholder: string): TextField;
}
Implement concrete families:
// --- Dark theme family ---
class DarkButton implements Button {
constructor(private label: string) {}
render() {
return `<button class="dark">${this.label}</button>`;
}
onClick(handler: () => void) {
/* attach event */
}
}
class DarkTextField implements TextField {
private value = '';
constructor(private placeholder: string) {}
render() {
return `<input class="dark" placeholder="${this.placeholder}" />`;
}
getValue() {
return this.value;
}
}
class DarkThemeFactory implements UIFactory {
createButton(label: string): Button {
return new DarkButton(label);
}
createTextField(placeholder: string): TextField {
return new DarkTextField(placeholder);
}
}
// --- Light theme family ---
class LightButton implements Button {
constructor(private label: string) {}
render() {
return `<button class="light">${this.label}</button>`;
}
onClick(handler: () => void) {
/* attach event */
}
}
class LightTextField implements TextField {
private value = '';
constructor(private placeholder: string) {}
render() {
return `<input class="light" placeholder="${this.placeholder}" />`;
}
getValue() {
return this.value;
}
}
class LightThemeFactory implements UIFactory {
createButton(label: string): Button {
return new LightButton(label);
}
createTextField(placeholder: string): TextField {
return new LightTextField(placeholder);
}
}
Client code depends only on the abstract factory:
class LoginForm {
private submitButton: Button;
private emailField: TextField;
constructor(factory: UIFactory) {
this.submitButton = factory.createButton('Log In');
this.emailField = factory.createTextField('Email address');
}
render(): string {
return `<form>${this.emailField.render()}${this.submitButton.render()}</form>`;
}
}
// Swap families by changing the factory
const theme = process.env.THEME === 'dark' ? new DarkThemeFactory() : new LightThemeFactory();
const form = new LoginForm(theme);
console.log(form.render());
Cloud provider example (more realistic for backend):
interface StorageProvider {
upload(key: string, data: Buffer): Promise<string>;
download(key: string): Promise<Buffer>;
}
interface QueueProvider {
publish(topic: string, message: object): Promise<void>;
subscribe(topic: string, handler: (msg: object) => void): void;
}
interface CloudFactory {
createStorage(bucket: string): StorageProvider;
createQueue(): QueueProvider;
}
class AWSFactory implements CloudFactory {
createStorage(bucket: string): StorageProvider {
return new S3Storage(bucket);
}
createQueue(): QueueProvider {
return new SQSQueue();
}
}
class GCPFactory implements CloudFactory {
createStorage(bucket: string): StorageProvider {
return new GCSStorage(bucket);
}
createQueue(): QueueProvider {
return new PubSubQueue();
}
}
Abstract Factory vs. Factory Method: Factory Method uses inheritance — one factory method per subclass. Abstract Factory uses composition — inject a factory object that produces a whole family. Abstract Factory is the better choice when you have multiple products that vary together.
Adding a new product to an existing family breaks the Open/Closed Principle — every concrete factory must implement the new method. This is the main drawback. Mitigate by providing a default implementation in an abstract base factory.
Anti-patterns:
Testing tip: Inject a MockFactory that returns stub implementations for every product type. This decouples all component tests from real infrastructure.
refactoring.guru/design-patterns/abstract-factory
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
abstract-factory, gof, design-patterns, ui-themes, factory-pattern, type-safe
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