agentleFS
suxiao1824308603suxiao1824308603/Qoder-devtools-skills/skills/refactor-assistant/SKILL.md

refactor-assistant

Skill3 starsChanged 9 months agoMITView on GitHub

Guide code refactoring with proven patterns and techniques. Use when the user wants to refactor code, improve code structure, extract functions, or apply design patterns.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. nek1987/auto-agent-harness★ 4same name
    2. poorvith-mp/skills-developer★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before adding a feature, make the change easy:

    line 67
  2. Distinctive:

    Add the new feature

    line 71
  3. Distinctive:

    Measure again: - Verify improvement

    line 81
  4. Distinctive:

    Use appropriate data structures

    line 86

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Refactor Assistant

Guide safe, incremental code refactoring.

Identify Refactoring Type

First, determine what kind of refactoring is needed:

Code smells? -> See "Smell-Based Refactoring" below Adding feature? -> See "Preparatory Refactoring" below Performance issue? -> See "Performance Refactoring" below Improving design? -> See "Design Pattern Refactoring" below


Smell-Based Refactoring

Long Function

Symptoms: Function > 30 lines, multiple responsibilities Solution: Extract Method

# Before
def process_order(order):
    # validate (10 lines)
    # calculate (15 lines)  
    # save (10 lines)

# After
def process_order(order):
    validate_order(order)
    total = calculate_total(order)
    save_order(order, total)

Duplicate Code

Symptoms: Same logic in multiple places Solution: Extract and reuse

Long Parameter List

Symptoms: Function has > 4 parameters Solution: Introduce Parameter Object

# Before
def create_user(name, email, age, city, country, phone):
    ...

# After
def create_user(user_data: UserData):
    ...

Feature Envy

Symptoms: Method uses another class's data extensively Solution: Move Method to that class


Preparatory Refactoring

Before adding a feature, make the change easy:

  1. Identify where new code will go
  2. Refactor existing code to create clean insertion point
  3. Add the new feature
  4. Clean up if needed

Performance Refactoring

  1. Measure first - Profile before optimizing
  2. Find bottleneck - Focus on hot paths
  3. Apply fix - One change at a time
  4. Measure again - Verify improvement

Common fixes:

  • Cache repeated calculations
  • Batch database queries
  • Use appropriate data structures
  • Lazy load expensive resources

Design Pattern Refactoring

See patterns/ for detailed guides:

  • strategy.md - Replace conditionals with polymorphism
  • factory.md - Centralize object creation
  • decorator.md - Add behavior without modification

Safety Rules

  1. Run tests before refactoring
  2. Make small, incremental changes
  3. Run tests after each change
  4. Commit working states frequently

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.