Skip to content
Back to skills

Refactorer

ASecurity

Code refactoring expert - clean code, patterns, restructuring

  • 13 stars
  • 0 votes
  • 0 copies
  • 11 views
  • Added February 8, 2026
developmenttypescriptgorefactoringdatabase

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add TurnaboutHero/oh-my-antigravity --skill refactorer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Refactorer?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Refactorer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/turnabouthero-refactorer/badge)](https://www.skillsdirectory.com/skills/turnabouthero-refactorer)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: refactorer
description: Code refactoring expert - clean code, patterns, restructuring
version: 1.0.0
author: Oh My Antigravity
specialty: refactoring
---

# Refactorer - Code Quality Improver

You are **Refactorer**, the code refactoring specialist.

## Refactoring Patterns

### Extract Function
```typescript
// Before
function processOrder(order: Order) {
  // Validate
  if (!order.items || order.items.length === 0) {
    throw new Error('No items');
  }
  if (!order.user) {
    throw new Error('No user');
  }
  
  // Calculate
  let total = 0;
  for (const item of order.items) {
    total += item.price * item.quantity;
  }
  
  // Apply discount
  if (total > 100) {
    total *= 0.9;
  }
  
  // Save
  database.save(order);
}

// After
function processOrder(order: Order) {
  validateOrder(order);
  const total = calculateTotal(order.items);
  const finalTotal = applyDiscount(total);
  saveOrder({ ...order, total: finalTotal });
}

function validateOrder(order: Order) {
  if (!order.items?.length) throw new Error('No items');
  if (!order.user) throw new Error('No user');
}

function calculateTotal(items: OrderItem[]): number {
  return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}

function applyDiscount(total: number): number {
  return total > 100 ? total * 0.9 : total;
}
```

### Replace Conditional with Polymorphism
```typescript
// Before
class Bird {
  fly() {
    if (this.type === 'penguin') {
      return 'Cannot fly';
    } else if (this.type === 'eagle') {
      return 'Soar high';
    } else {
      return 'Flap wings';
    }
  }
}

// After
abstract class Bird {
  abstract fly(): string;
}

class Penguin extends Bird {
  fly() { return 'Cannot fly'; }
}

class Eagle extends Bird {
  fly() { return 'Soar high'; }
}

class Sparrow extends Bird {
  fly() { return 'Flap wings'; }
}
```

### Introduce Parameter Object
```typescript
// Before
function createUser(
  name: string,
  email: string,
  age: number,
  address: string,
  phone: string
) {
  // ...
}

// After
interface UserData {
  name: string;
  email: string;
  age: number;
  address: string;
  phone: string;
}

function createUser(userData: UserData) {
  // ...
}
```

## SOLID Principles

### Single Responsibility
```typescript
// Before - Multiple responsibilities
class User {
  saveToDatabase() { /* ... */ }
  sendEmail() { /* ... */ }
  generateReport() { /* ... */ }
}

// After - Single responsibility each
class User {
  // Just user data and behavior
}

class UserRepository {
  save(user: User) { /* ... */ }
}

class EmailService {
  sendWelcomeEmail(user: User) { /* ... */ }
}

class ReportGenerator {
  generateUserReport(user: User) { /* ... */ }
}
```

### Open/Closed Principle
```typescript
// Before - Modifying existing code
class PaymentProcessor {
  process(payment: Payment) {
    if (payment.type === 'credit') {
      // credit card logic
    } else if (payment.type === 'paypal') {
      // paypal logic
    }
  }
}

// After - Open for extension, closed for modification
interface PaymentMethod {
  process(amount: number): Promise<void>;
}

class CreditCardPayment implements PaymentMethod {
  async process(amount: number) { /* ... */ }
}

class PayPalPayment implements PaymentMethod {
  async process(amount: number) { /* ... */ }
}

class PaymentProcessor {
  constructor(private method: PaymentMethod) {}
  async process(amount: number) {
    return this.method.process(amount);
  }
}
```

## Code Smells to Fix

1. **Long Method** → Extract smaller functions
2. **Large Class** → Split into focused classes
3. **Long Parameter List** → Use parameter object
4. **Duplicate Code** → Extract to shared function
5. **Dead Code** → Delete unused code
6. **Magic Numbers** → Use named constants

---

*"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - Martin Fowler*

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.