skills/refactoring/moving-features/SKILL.md
Safely redistribute functionality among classes — move methods/fields, extract/inline classes, hide delegates. Trigger: When redistributing responsibilities, improving class cohesion, or reducing coupling between objects.
npx skillsauth add johnnystefan/test-saas-business refactoring/moving-featuresInstall 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 safely redistribute functionality among classes, create new classes, and hide implementation details from public access. It addresses architectural issues where classes have become less coherent or where dependencies between classes are unnecessarily high.
// BEFORE: Client is dependent on the Department class structure
const manager = person.getDepartment().getManager();
// AFTER: Person hides the delegation to Department
class Person {
private department: Department;
getManager(): Manager {
return this.department.getManager();
}
}
const manager = person.getManager();
// BEFORE: Account has logic better suited for AccountType
class Account {
private type: AccountType;
private daysOverdrawn: number;
overdraftCharge(): number {
if (this.type.isPremium()) {
let result = 10;
if (this.daysOverdrawn > 7) result += (this.daysOverdrawn - 7) * 0.85;
return result;
}
return this.daysOverdrawn * 1.75;
}
}
// AFTER: Logic moved to AccountType where it belongs
class AccountType {
overdraftCharge(daysOverdrawn: number): number {
if (this.isPremium()) {
let result = 10;
if (daysOverdrawn > 7) result += (daysOverdrawn - 7) * 0.85;
return result;
}
return daysOverdrawn * 1.75;
}
}
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.