claude.symlink/skills/refactor/SKILL.md
Refactor code for quality, reduce technical debt, and improve maintainability. Use for cleanup tasks and code improvements.
npx skillsauth add htlin222/dotfiles refactorInstall 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.
Improve code quality without changing behavior.
// Before
function processOrder(order) {
// 50 lines of validation
// 30 lines of calculation
// 20 lines of notification
}
// After
function processOrder(order) {
validateOrder(order);
const total = calculateTotal(order);
notifyCustomer(order, total);
}
// Before
function getPrice(type) {
if (type === "regular") return basePrice;
if (type === "premium") return basePrice * 1.5;
if (type === "vip") return basePrice * 0.8;
}
// After
const pricingStrategies = {
regular: (base) => base,
premium: (base) => base * 1.5,
vip: (base) => base * 0.8,
};
const getPrice = (type) => pricingStrategies[type](basePrice);
// Before
function getUserName(user) {
return user?.profile?.name ?? "Unknown";
}
function getOrderName(order) {
return order?.customer?.name ?? "Unknown";
}
// After
const getName = (obj, path) => path.reduce((o, k) => o?.[k], obj) ?? "Unknown";
const getUserName = (user) => getName(user, ["profile", "name"]);
const getOrderName = (order) => getName(order, ["customer", "name"]);
| Smell | Symptom | Refactoring | | ------------------- | ----------------------- | -------------------- | | Long Function | >20 lines | Extract Function | | Large Class | >200 lines | Extract Class | | Duplicate Code | Same logic repeated | Extract and reuse | | Long Parameter | >3 params | Use object/builder | | Feature Envy | Uses other class's data | Move method | | Primitive Obsession | Strings for everything | Create value objects |
Input: "This function is too long" Action: Identify logical sections, extract into focused functions, verify tests pass
Input: "Reduce duplication in these files" Action: Find common patterns, extract shared utilities, update call sites
testing
Converts narrative medical text into Pocket Medicine bullet-style notes with proper abbreviations, then modularizes sections exceeding 20 lines into linked standalone files.
devops
Use when deploying Docker services on the local VM (hostname: vm, Pop!_OS) with Traefik reverse proxy and Homepage dashboard. Covers crane image workflow, Traefik file-provider registration, Homepage services.yaml entries, and compose templates on the traefik-proxy network.
development
Use when reviewing a data visualization or figure for clarity, checking if a graph communicates its message without additional context, or iterating on R/Python plot scripts until a naive reader can fully understand the figure.
development
Runs Vale prose linter on markdown/text files and auto-fixes issues. Use when the user asks to lint, proofread, or improve writing quality of markdown or text files.