skills/refactoring/composing-methods/SKILL.md
Streamline methods by extracting, inlining, and decomposing long or complex logic. Trigger: When methods are too long, contain complex expressions, or mix multiple levels of abstraction.
npx skillsauth add johnnystefan/test-saas-business refactoring/composing-methodsInstall 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 streamline methods, remove code duplication, and simplify execution logic. It addresses the root of all evil in code: excessively long methods that conceal execution logic and are hard to change.
// BEFORE: Logic mixed in one method
function printOwing() {
printBanner();
console.log('name: ' + name);
console.log('amount: ' + getOutstanding());
}
// AFTER: Details extracted into their own method
function printOwing() {
printBanner();
printDetails(getOutstanding());
}
function printDetails(outstanding: number) {
console.log('name: ' + name);
console.log('amount: ' + outstanding);
}
// BEFORE: Complex conditional hard to parse
function renderBanner() {
if (
platform.toUpperCase().indexOf('MAC') > -1 &&
browser.toUpperCase().indexOf('IE') > -1 &&
wasInitialized() &&
resize > 0
) {
// do something
}
}
// AFTER: Self-explanatory variables
function renderBanner() {
const isMacOs = platform.toUpperCase().indexOf('MAC') > -1;
const isIE = browser.toUpperCase().indexOf('IE') > -1;
const wasResized = resize > 0;
if (isMacOs && isIE && wasInitialized() && wasResized) {
// do something
}
}
// BEFORE: Using local variable for calculation
function calculateTotal(): number {
const basePrice = quantity * itemPrice;
if (basePrice > 1000) return basePrice * 0.95;
return basePrice * 0.98;
}
// AFTER: Calculation extracted to a query method
function calculateTotal(): number {
if (getBasePrice() > 1000) return getBasePrice() * 0.95;
return getBasePrice() * 0.98;
}
function getBasePrice(): number {
return quantity * itemPrice;
}
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.