skills/refactoring/organizing-data/SKILL.md
Improve data handling by encapsulating fields, replacing primitives with objects, and managing type codes. Trigger: When refactoring primitive obsession, encapsulating public fields/collections, or replacing magic numbers.
npx skillsauth add johnnystefan/test-saas-business refactoring/organizing-dataInstall 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 improve how data is handled within a program. It focuses on replacing primitive types with specialized objects, ensuring proper encapsulation of fields and collections, and managing object relationships to reduce complexity and improve maintainability.
add/remove methods.// BEFORE: The meaning of 9.81 is not immediately obvious
function potentialEnergy(mass: number, height: number): number {
return mass * height * 9.81;
}
// AFTER: Named constant provides context
const GRAVITATIONAL_CONSTANT = 9.81;
function potentialEnergy(mass: number, height: number): number {
return mass * height * GRAVITATIONAL_CONSTANT;
}
// BEFORE: Clients can modify the courses array directly
class Student {
public courses: string[] = [];
}
// AFTER: Access is controlled through methods
class Student {
private _courses: string[] = [];
get courses(): ReadonlyArray<string> {
return this._courses;
}
addCourse(course: string): void {
this._courses.push(course);
}
removeCourse(course: string): void {
this._courses = this._courses.filter((c) => c !== course);
}
}
// BEFORE: Customer is just a primitive string with no behavior
class Order {
constructor(public customer: string) {}
}
// AFTER: Customer is an object that can grow with its own behavior
class Customer {
constructor(private name: string) {}
getName(): string {
return this.name;
}
}
class Order {
private customer: Customer;
constructor(customerName: string) {
this.customer = new Customer(customerName);
}
}
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.