skillZs
★ LIVE SKILL TAGS ★
>>> LIVE SKILLS INDEX <<<
* OPEN SOURCE *
NO LOGIN, NO TRACKING
※ REAL INSTALL DATA ※
← back to all skills
htlin222/dotfiles99 installs

refactor

Refactor code for quality and maintainability. Use for cleanup and tech debt reduction.

How do I install this agent skill?

npx skills add https://github.com/htlin222/dotfiles --skill refactor
view source ↗

Is this agent skill safe to install?

  • Gen Agent Trust Hubpass

    The skill provides educational content and best practices for code refactoring. It contains only documentation and static code examples, with no executable logic, network requests, or security risks.

  • Socketpass

    No alerts

  • Snykpass

    Risk: LOW · No issues

  • Runlayerwarn

    1/1 file flagged

  • ZeroLeakspass

    Score: 93/100 · 2 sections analyzed

What does this agent skill do?

Code Refactoring

Improve code quality without changing behavior.

When to Use

  • Code is hard to understand or modify
  • Duplicated logic across files
  • Functions/classes are too large
  • Technical debt reduction
  • Before adding new features

Refactoring Process

  1. Ensure tests exist - Add tests before refactoring
  2. Small steps - Make incremental changes
  3. Run tests - Verify after each change
  4. Commit often - Keep changes reversible

Common Refactorings

Extract Function

// 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);
}

Replace Conditionals with Polymorphism

// 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);

Remove Duplication

// 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"]);

Code Smells

SmellSymptomRefactoring
Long Function>20 linesExtract Function
Large Class>200 linesExtract Class
Duplicate CodeSame logic repeatedExtract and reuse
Long Parameter>3 paramsUse object/builder
Feature EnvyUses other class's dataMove method
Primitive ObsessionStrings for everythingCreate value objects

Quality Metrics

  • Cyclomatic Complexity - Keep under 10 per function
  • Nesting Depth - Max 3 levels
  • Function Length - Under 20 lines preferred
  • File Length - Under 300 lines preferred

Safety Checklist

  • Tests exist and pass
  • No behavior changes intended
  • Changes are incremental
  • Each step is committed
  • Code review requested

Examples

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

Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.

<a href="https://skillzs.dev/skills/htlin222/dotfiles/refactor">View refactor on skillZs</a>