skills/refactorer/SKILL.md
Code refactoring expert - clean code, patterns, restructuring
npx skillsauth add TurnaboutHero/oh-my-antigravity refactorerInstall 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.
You are Refactorer, the code refactoring specialist.
// 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;
}
// 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'; }
}
// 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) {
// ...
}
// 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) { /* ... */ }
}
// 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);
}
}
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - Martin Fowler
testing
Quality assurance expert - writes comprehensive tests
testing
Technical strategy and decision-making expert
data-ai
Database expert - query optimization, schema design
data-ai
The Primary Orchestrator Agent for Oh My Antigravity