Refactoring Specialist logo

Refactoring Specialist

Community
zhaono1
refactoring-specialist

Code refactoring expert for improving code structure, readability, and maintainability. Use when user asks to refactor, clean up, or improve code quality.

Overview

Publisherzhaono1
Repositoryagent-playbook
Skill namerefactoring-specialist
Stars
79
Forks
12
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by zhaono1 on GitHub. Read the source before you install it.

Installation

Install the Refactoring Specialist AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/zhaono1/agent-playbook.git /tmp/agent-playbook
mkdir -p .claude/skills
cp -r /tmp/agent-playbook/skills/refactoring-specialist .claude/skills/refactoring-specialist
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Refactoring Specialist in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Refactoring Specialist on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Refactoring Specialist is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Refactoring Specialist

Expert guidance on refactoring code to improve structure, readability, and maintainability while preserving functionality.

When This Skill Activates

Activates when you:

  • Ask to refactor code
  • Request cleanup or improvement
  • Mention "technical debt" or "code smell"
  • Want to improve code quality

Refactoring Principles

  1. Preserve Behavior: Refactoring must not change external behavior
  2. Small Steps: Make small, incremental changes
  3. Test Coverage: Ensure tests pass before and after
  4. Commit Often: Commit after each successful refactoring

Code Smells to Address

1. Long Method

Symptom: Function > 20-30 lines

Refactoring: Extract Method

typescript
// Before:
function processOrder(order) {
  // 50 lines of code
}

// After:
function processOrder(order) {
  validateOrder(order);
  calculateTotals(order);
  saveOrder(order);
  sendConfirmation(order);
}

2. Duplicate Code

Symptom: Similar code in multiple places

Refactoring: Extract Method / Template Method

typescript
// Before:
class UserService {
  async validateEmail(email) {
    if (!email || !email.includes('@')) return false;
    const domain = email.split('@')[1];
    return domain.length > 0;
  }
}
class AdminService {
  async validateEmail(email) {
    if (!email || !email.includes('@')) return false;
    const domain = email.split('@')[1];
    return domain.length > 0;
  }
}

// After:
class EmailValidator {
  async validate(email) {
    if (!email || !email.includes('@')) return false;
    return email.split('@')[1].length > 0;
  }
}

3. Large Class

Symptom: Class doing too many things

Refactoring: Extract Class

typescript
// Before:
class User {
  // Authentication
  // Profile management
  // Notifications
  // Reporting
}

// After:
class User { /* Core user data */ }
class UserAuth { /* Authentication */ }
class UserProfile { /* Profile management */ }
class UserNotifier { /* Notifications */ }

4. Long Parameter List

Symptom: Function with 4+ parameters

Refactoring: Introduce Parameter Object

typescript
// Before:
function createUser(name, email, age, address, phone, role) { ... }

// After:
function createUser(user: UserData) { ... }

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

5. Feature Envy

Symptom: Method uses more data from other classes

Refactoring: Move Method

typescript
// Before:
class Report {
  formatSummary(formatter) {
    const options = formatter.getFormattingOptions();
    // ...
  }
}

// After:
class Formatter {
  formatReport(report) {
    const discount = this.discountLevel;
    // ...
  }
}

6. Data Clumps

Symptom: Same data appearing together

Refactoring: Extract Value Object

typescript
// Before:
function drawShape(x, y, width, height) { ... }
function moveShape(x, y, width, height, dx, dy) { ... }

// After:
class Rectangle {
  constructor(x, y, width, height) { ... }
}
function drawShape(rect: Rectangle) { ... }

7. Primitive Obsession

Symptom: Using primitives instead of small objects

Refactoring: Replace Primitive with Object

typescript
// Before:
function createUser(name, email, phone) { ... }

// After:
class Email {
  constructor(value) {
    if (!this.isValid(value)) throw new Error('Invalid email');
    this.value = value;
  }
  // ...
}

8. Switch Statements

Symptom: Large switch on type

Refactoring: Replace Conditional with Polymorphism

typescript
// Before:
function calculatePay(employee) {
  switch (employee.type) {
    case 'engineer': return employee.salary * 1.2;
    case 'manager': return employee.salary * 1.5;
    case 'sales': return employee.salary * 1.1;
  }
}

// After:
interface Employee {
  calculatePay(): number;
}
class Engineer implements Employee {
  calculatePay() { return this.salary * 1.2; }
}

9. Temporary Field

Symptom: Variables only used in certain scenarios

Refactoring: Extract Class

typescript
// Before:
class User {
  calculateRefund() {
    this.tempRefundAmount = 0;
    // complex calculation
    return this.tempRefundAmount;
  }
}

// After:
class RefundCalculator {
  calculate(user) {
    // ...
  }
}

10. Comments

Symptom: Code needs extensive comments

Refactoring: Extract Method with clear name

typescript
// Before:
// Calculate the total price including discounts
// and tax based on user location
function calc(u, i) {
  let t = 0;
  // discount logic
  if (u.vip) t *= 0.9;
  // tax logic
  if (u.state === 'CA') t *= 1.08;
  return t;
}

// After:
function calculateTotalPrice(user: User, items: Item[]): number {
  let total = items.sum(i => i.price);
  if (user.isVIP) {
    total = applyVIPDiscount(total);
  }
  return applyTax(total, user.state);
}

Refactoring Steps

  1. Identify the smell - What makes this code hard to work with?
  2. Determine the refactoring - Which technique applies?
  3. Ensure tests pass - Green before starting
  4. Apply the refactoring - Make the change
  5. Run tests - Verify behavior unchanged
  6. Commit - Small, atomic commits

Safe Refactoring Practices

  • Use your IDE's refactoring tools (Rename, Extract, Move)
  • Run tests frequently (after each change)
  • Keep commits small and focused
  • Write a descriptive commit message
  • Consider code reviews for complex refactorings

Before Refactoring

  • Tests are passing
  • I understand what the code does
  • I have identified the specific code smell
  • I know which refactoring to apply
  • I have a rollback plan

After Refactoring

  • Tests still pass
  • Code is more readable
  • Code is easier to maintain
  • No new code smells introduced
  • Documentation updated if needed

References

  • references/smells.md - Complete code smell catalog
  • references/techniques.md - Refactoring techniques
  • references/checklist.md - Refactoring checklist

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Refactoring Specialist AI skill do?

Code refactoring expert for improving code structure, readability, and maintainability. Use when user asks to refactor, clean up, or improve code quality.

Why use Refactoring Specialist on TypingMind?

Because you install it once and use it with any model. Refactoring Specialist is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Refactoring Specialist in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/zhaono1/agent-playbook/tree/main/skills/refactoring-specialist. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Refactoring Specialist?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Refactoring Specialist?

As many as you like. As long as a model supports skills, you can use Refactoring Specialist with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Refactoring Specialist AI skill free?

Yes. It is published on GitHub by zhaono1 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇