skills/refactoring/generalization/SKILL.md
Manage class hierarchies by pulling up, pushing down, extracting interfaces, and switching between inheritance and delegation. Trigger: When refactoring class hierarchies, extracting superclasses/interfaces, or resolving Liskov violations.
npx skillsauth add johnnystefan/test-saas-business refactoring/generalizationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill enables the agent to manage software abstraction and class hierarchies. It provides instructions for moving fields and methods between superclasses and subclasses, extracting interfaces, and switching between inheritance and delegation to ensure a clean, maintainable architecture.
super().// BEFORE: High coupling to the concrete class
class Employee {
getRate(): number {
return 100;
}
getName(): string {
return 'John';
}
getDepartment(): string {
return 'IT';
}
}
// AFTER: Interface allows for more flexible client usage
interface Billable {
getRate(): number;
}
class Employee implements Billable {
getRate(): number {
return 100;
}
getName(): string {
return 'John';
}
getDepartment(): string {
return 'IT';
}
}
// BEFORE: Stack inherits many unneeded methods from Vector
class Stack extends Vector {
push(item: unknown) {
this.add(item);
}
pop() {
return this.remove(this.size() - 1);
}
}
// AFTER: Stack uses Vector as a helper, not a parent
class Stack {
private vector: Vector = new Vector();
push(item: unknown) {
this.vector.add(item);
}
pop() {
return this.vector.remove(this.vector.size() - 1);
}
isEmpty() {
return this.vector.isEmpty();
}
}
// AFTER: Algorithm structure moved to the superclass
abstract class Site {
// Template Method — algorithm skeleton defined here
getBillableAmount(): number {
return this.getBaseAmount() + this.getTaxAmount();
}
abstract getBaseAmount(): number;
abstract getTaxAmount(): number;
}
class ResidentialSite extends Site {
getBaseAmount() {
return this.units * this.rate;
}
getTaxAmount() {
return this.getBaseAmount() * 0.05;
}
}
tools
Zustand 5 state management patterns. Trigger: When implementing client-side state with Zustand (stores, selectors, persist middleware, slices).
databases
Zod 4 schema validation patterns. Trigger: When creating or updating Zod v4 schemas for validation/parsing (forms, request payloads, adapters), including v3 -> v4 migration patterns.
development
Vitest unit testing patterns with React Testing Library. Trigger: When writing unit tests for React components, hooks, or utilities.
tools
Vite 8 (Rolldown-powered) build tool configuration, plugin API, SSR, and migration guide. Trigger: When working with vite.config.ts, Vite plugins, building libraries, or SSR apps with Vite.