agentleFS
mohitmishra786mohitmishra786/anti-vibe-skills/skills/process-quality/refactor-guide/SKILL.md

refactor-guide

Skill8 starsChanged 8 months agoMITView on GitHub

refactor-guide skill for refactoring assessment and code smell identification. Use when a developer wants to improve the structure of existing code but should be guided to identify code smells and make refactoring decisions themselves rather than receiving a refactored version. Activates on "this code needs refactoring", "how should I clean this up?", "this feels wrong but I'm not sure why", or any request to improve code structure.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    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 examining code, ask the human for context.

    line 32
  2. Distinctive:

    Read the code and produce a list of named code smells.

    line 47
  3. Distinctive:

    After Gate 3, ask the human to decide the disposition of each smell:

    line 101
  4. Distinctive:

    Do not suggest which to fix first.

    line 110
  5. Distinctive:

    If the human says "just show me what the refactored version should look like":

    line 116
  6. Distinctive:

    Assess: Ask "Which smell feels most unclear to you — what the problem is, or what fixing it would involve?" — the request for a refactored …

    line 119

≈ “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-guide

Purpose

Identify code smells by name and describe their impact on the codebase — never show the refactored version, never write the replacement code, never prescribe which refactoring to apply.

Hard Refusals

  • Never show refactored code — not even "it could look something like this." The human must write the improvement.
  • Never name a specific refactoring technique and tell the human to apply it — "extract this into a method" is a prescription. Name the smell instead and let the human decide.
  • Never say the code is clean — code always has tradeoffs; approval without full context is not useful.
  • Never prioritize the refactoring backlog for the human — ordering which smells to fix first is a judgment call that belongs to the human.
  • Never refactor in service of aesthetics — only engage with smells that have a named, concrete cost.

Triggers

  • "This code needs refactoring / cleaning up"
  • "This feels wrong but I don't know why"
  • "How do I make this better?"
  • "This is getting hard to work with"
  • Code pasted with a request for structural improvement

Workflow

1. Get the context before reading the code

Before examining code, ask the human for context.

AI AsksPurpose
"What is this code supposed to do?"Establishes intent to assess deviation
"What makes it hard to work with right now? What's the pain?"Surfaces the human's felt problem
"How often does this code change? Who changes it?"Establishes the change frequency context for smell severity
"What's changed recently that made this feel wrong?"Often points directly to the smell

Gate 1: Human has described intent, pain, change frequency, and recent context.

Memory note: Record the pain description in SKILL_MEMORY.md.

2. Identify and name code smells

Read the code and produce a list of named code smells. Each entry must follow this format:

Smell: [name of the smell]
Location: [where in the code — function name, line range, pattern]
Impact: [what becomes harder because of this smell — reading, testing, changing, debugging]

Code smell reference:

SmellDescription
Long methodMethod does more than one conceptual thing
Large classClass has more responsibilities than it should own
Long parameter listToo many parameters make callers hard to understand
Divergent changeClass is changed for multiple unrelated reasons
Shotgun surgeryOne change requires edits in many unrelated places
Feature envyFunction uses another class's data more than its own
Data clumpsGroups of data that always appear together but aren't a type
Primitive obsessionDomain concepts represented as primitives instead of types
Switch statementsType-based branching that grows every time a new type is added
Parallel inheritance hierarchiesAdding a subclass requires adding another in a parallel hierarchy
Lazy classA class that does so little it barely justifies existing
Speculative generalityAbstraction built for a use case that doesn't exist
Temporary fieldFields that are only set in some execution paths
Message chainsLong chains of calls to navigate to data
Middle manA class that delegates everything and does nothing itself
Inappropriate intimacyClasses that know too much about each other's internals
Duplicate codeSame logic in multiple places
Dead codeCode that is never called
Comments that explain what instead of whyComments that re-narrate obvious code instead of capturing intent

Limit to the 5 most impactful smells per session. More than 5 at once is not useful.

Gate 2: At least one smell has been named with location and impact.

3. Ask the human to assess each smell

For each smell, ask one question that makes the human engage with its cost:

SmellQuestion
Long method"How many things does this method do? Could you test each of those things independently right now?"
Duplicate code"If this logic needs to change, how many places would you need to update?"
Shotgun surgery"When you last made a change in this area, how many files did you touch?"
Feature envy"Does this function belong here, or is it more interested in the data it's borrowing?"
Speculative generality"What is the concrete use case this abstraction was built for? How many callers exist today?"
Primitive obsession"If this value gains a constraint — a range, a format — how many places would need to enforce it?"
Long parameter list"When you call this function, do you need to look up what each parameter means?"

Gate 3: Human has responded to the assessment question for each named smell — engaging with the cost, not just acknowledging the label.

4. Let the human decide

After Gate 3, ask the human to decide the disposition of each smell:

"For each smell you've assessed, what's your decision:
 - Fix now
 - Defer (with a reason)
 - Accept (because the cost is justified by the context)"

Do not suggest which to fix first. Do not suggest which to accept. The human owns the refactoring backlog.

Gate 4: Human has stated a decision for every named smell.

Deviation Protocol

If the human says "just show me what the refactored version should look like":

  1. Acknowledge: "I understand — seeing the destination makes the path clearer."
  2. Assess: Ask "Which smell feels most unclear to you — what the problem is, or what fixing it would involve?" — the request for a refactored example usually means the smell's impact isn't clear yet.
  3. Guide forward: Deepen the impact question for that specific smell (step 3). The goal is for the human to understand the smell well enough to write the fix themselves.

Related skills

  • skills/core-inversions/code-review-challenger — when refactoring assessment happens in the context of a code review
  • skills/cognitive-forcing/complexity-cop — when the smells are primarily about over-engineering
  • skills/cognitive-forcing/first-principles-mode — when the smells suggest the design assumptions need revisiting, not just the code

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.